text: !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("three"),require("three/examples/jsm/loaders/GLTFLoader.js"),require("three/examples/jsm/loaders/DRACOLoader.js"),require("three/examples/jsm/loaders/KTX2Loader.js")):"function"==typeof define&&define.amd?define(["exports","three","three/examples/jsm/loaders/GLTFLoader.js","three/examples/jsm/loaders/DRACOLoader.js","three/examples/jsm/loaders/KTX2Loader.js"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ThreeLoader3DTiles={},e.THREE,e.THREE,e.THREE,e.THREE)}(this,(function(e,t,r,s,n){"use strict";
  /*! *****************************************************************************
      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 i(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 o(e,t){if(!e)throw new Error(t||"loader assertion failed.")}const a={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:"undefined"!=typeof global&&global,document:"undefined"!=typeof document&&document},c=a.global||a.self||a.window||{},u="object"!=typeof process||"[object process]"!==String(process)||process.browser,h="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);h&&parseFloat(h[1]);function l(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}const d={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:"undefined"!=typeof global&&global,document:"undefined"!=typeof document&&document},f=d.global||d.self||d.window||{},p="object"!=typeof process||"[object process]"!==String(process)||process.browser,m="function"==typeof importScripts,g="undefined"!=typeof window&&void 0!==window.orientation,y="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);function w(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}y&&parseFloat(y[1]);class b{constructor(e,t){w(this,"name",void 0),w(this,"workerThread",void 0),w(this,"isRunning",void 0),w(this,"result",void 0),w(this,"_resolve",void 0),w(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){l(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){l(this.isRunning),this.isRunning=!1,this._reject(e)}}const T=new Map;function v(e){l(e.source&&!e.url||!e.source&&e.url);let t=T.get(e.source||e.url);return t||(e.url&&(t=function(e){if(!e.startsWith("http"))return e;return _((t=e,`try {\n  importScripts('${t}');\n} catch (error) {\n  console.error(error);\n  throw error;\n}`));var t}(e.url),T.set(e.url,t)),e.source&&(t=_(e.source),T.set(e.source,t))),l(t),t}function _(e){const t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function E(e,t=!0,r){const s=r||new Set;if(e){if(x(e))s.add(e);else if(x(e.buffer))s.add(e.buffer);else if(ArrayBuffer.isView(e));else if(t&&"object"==typeof e)for(const r in e)E(e[r],t,s)}else;return void 0===r?Array.from(s):[]}function x(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 S=()=>{};class M{static isSupported(){return"undefined"!=typeof Worker}constructor(e){w(this,"name",void 0),w(this,"source",void 0),w(this,"url",void 0),w(this,"terminated",!1),w(this,"worker",void 0),w(this,"onMessage",void 0),w(this,"onError",void 0),w(this,"_loadableURL","");const{name:t,source:r,url:s}=e;l(r||s),this.name=t,this.source=r,this.url=s,this.onMessage=S,this.onError=e=>console.log(e),this.worker=this._createBrowserWorker()}destroy(){this.onMessage=S,this.onError=S,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,t){t=t||E(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=v({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 A{constructor(e){w(this,"name","unnamed"),w(this,"source",void 0),w(this,"url",void 0),w(this,"maxConcurrency",1),w(this,"maxMobileConcurrency",1),w(this,"onDebug",(()=>{})),w(this,"reuseWorkers",!0),w(this,"props",{}),w(this,"jobQueue",[]),w(this,"idleQueue",[]),w(this,"count",0),w(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 b(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 M({name:e,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return g?this.maxMobileConcurrency:this.maxConcurrency}}const R={maxConcurrency:3,maxMobileConcurrency:1,onDebug:()=>{},reuseWorkers:!0};class O{static isSupported(){return M.isSupported()}static getWorkerFarm(e={}){return O._workerFarm=O._workerFarm||new O({}),O._workerFarm.setProps(e),O._workerFarm}constructor(e){w(this,"props",void 0),w(this,"workerPools",new Map),this.props={...R},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 A({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}}}w(O,"_workerFarm",void 0);var I={};const C={};async function L(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(!p)return`modules/${t}/dist/libs/${e}`;if(r.CDN)return l(r.CDN.startsWith("http")),`${r.CDN}/${t}@3.0.10/dist/libs/${e}`;if(m)return`../src/libs/${e}`;return`modules/${t}/src/libs/${e}`}(e,t,r)),C[e]=C[e]||async function(e){if(e.endsWith("wasm")){const t=await fetch(e);return await t.arrayBuffer()}if(!p)return I.requireFromFile&&await I.requireFromFile(e);if(m)return importScripts(e);const t=await fetch(e);return function(e,t){if(!p)return I.requireFromString&&I.requireFromString(e,t);if(m)return eval.call(f,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 C[e]}async function N(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 l(n),n}(e,r),a=O.getWorkerFarm(r).getWorkerPool({name:i,url:o});r=JSON.parse(JSON.stringify(r));const c=await a.startJob("process-on-worker",P.bind(null,n));c.postMessage("process",{input:t,options:r});const u=await c.result;return await u.result}async function P(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 U(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 D(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 U(e.buffer,e.byteOffset,t);if(e instanceof ArrayBuffer)return U(e,0,t);return""}(e)}"`)}}function k(e){if(I.toArrayBuffer&&(e=I.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 B(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 j(e,t){return o(e>=0),o(t>0),e+(t-1)&~(t-1)}function F(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+j(s.byteLength,4)}async function V(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 q(){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 z{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=q(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(q()-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 G{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 z?e:new z(t,r)),this.stats[t]}}const H={id:"request-scheduler",throttleRequests:!0,maxRequests:6};class W{constructor(e={}){w(this,"props",void 0),w(this,"stats",void 0),w(this,"activeRequestCount",0),w(this,"requestQueue",[]),w(this,"requestMap",new Map),w(this,"deferredUpdate",null),this.props={...H,...e},this.stats=new G({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 $(e){const t=e&&e.lastIndexOf("/");return t>=0?e.substr(0,t):""}const K={};const Q=e=>"function"==typeof e,X=e=>null!==e&&"object"==typeof e,Y=e=>X(e)&&e.constructor==={}.constructor,Z=e=>"undefined"!=typeof Response&&e instanceof Response||e&&e.arrayBuffer&&e.text&&e.json,J=e=>"undefined"!=typeof Blob&&e instanceof Blob,ee=e=>(e=>"undefined"!=typeof ReadableStream&&e instanceof ReadableStream||X(e)&&Q(e.tee)&&Q(e.cancel)&&Q(e.getReader))(e)||(e=>X(e)&&Q(e.read)&&Q(e.pipe)&&(e=>"boolean"==typeof e)(e.readable))(e),te=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,re=/^([-\w.]+\/[-\w.+]+)/;function se(e){const t=re.exec(e);return t?t[1]:e}function ne(e){const t=te.exec(e);return t?t[1]:""}const ie=/\?.*/;function oe(e){if(Z(e)){const t=ae(e.url||"");return{url:t,type:se(e.headers.get("content-type")||"")||ne(t)}}return J(e)?{url:ae(e.name||""),type:e.type||""}:"string"==typeof e?{url:ae(e),type:ne(e)}:{url:"",type:""}}function ae(e){return e.replace(ie,"")}async function ce(e){if(Z(e))return e;const t={},r=function(e){return Z(e)?e.headers["content-length"]||-1:J(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}=oe(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 ue(e,t){if("string"==typeof e){e=function(e){for(const t in K)if(e.startsWith(t)){const r=K[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 ce(e)}const he={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},le=he.window||he.self||he.global,de=he.process||{},fe="undefined"!=typeof __VERSION__?__VERSION__:"untranspiled source",pe=!("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 me{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 ge(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 ye={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 we(e){return"string"==typeof e?ye[e.toUpperCase()]||ye.WHITE:e}function be(e,t){if(!e)throw new Error(t||"Assertion failed")}function Te(){let e;if(pe&&le.performance)e=le.performance.now();else if(de.hrtime){const t=de.hrtime();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}const ve={debug:pe&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},_e={enabled:!0,level:0};function Ee(){}const xe={},Se={once:!0};function Me(e){for(const t in e)for(const r in e[t])return r||"untitled";return"empty"}class Ae{constructor({id:e}={id:""}){this.id=e,this.VERSION=fe,this._startTs=Te(),this._deltaTs=Te(),this.LOG_THROTTLE_TIMEOUT=0,this._storage=new me("__probe-".concat(this.id,"__"),_e),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((Te()-this._startTs).toPrecision(10))}getDelta(){return Number((Te()-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){be(e,t)}warn(e){return this._getLogFunction(0,e,ve.warn,arguments,Se)}error(e){return this._getLogFunction(0,e,ve.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,ve.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,ve.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,ve.debug||ve.info,arguments,Se)}table(e,t,r){return t?this._getLogFunction(e,t,console.table||Ee,r&&[r],{tag:Me(t)}):Ee}image({logLevel:e,priority:t,image:r,message:s="",scale:n=1}){return this._shouldLog(e||t)?pe?function({image:e,message:t="",scale:r=1}){if("string"==typeof e){const s=new Image;return s.onload=()=>{const e=ge(s,t,r);console.log(...e)},s.src=e,Ee}const s=e.nodeName||"";if("img"===s.toLowerCase())return console.log(...ge(e,t,r)),Ee;if("canvas"===s.toLowerCase()){const s=new Image;return s.onload=()=>console.log(...ge(s,t,r)),s.src=e.toDataURL(),Ee}return Ee}({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 Ee}({image:r,message:s,scale:n}):Ee}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||Ee)}group(e,t,r={collapsed:!1}){r=Oe({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||Ee)}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()>=Re(e)}_getLogFunction(e,t,r,s=[],n){if(this._shouldLog(e)){n=Oe({logLevel:e,message:t,args:s,opts:n}),be(r=r||n.method),n.total=this.getTotal(),n.delta=this.getDelta(),this._deltaTs=Te();const i=n.tag||n.message;if(n.once){if(xe[i])return Ee;xe[i]=Te()}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,pe||"string"!=typeof s||(n&&(n=we(n),s="[".concat(n,"m").concat(s,"[39m")),i&&(n=we(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 Ee}}function Re(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 be(Number.isFinite(t)&&t>=0),t}function Oe(e){const{logLevel:t,message:r}=e;e.logLevel=Re(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 be("string"===n||"object"===n),Object.assign(e,e.opts)}Ae.VERSION=fe;const Ie=new Ae({id:"loaders.gl"});class Ce{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}const Le={fetch:null,mimeType:void 0,nothrow:!1,log:new class{constructor(){w(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:[]},Ne={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 Pe(){c.loaders=c.loaders||{};const{loaders:e}=c;return e._state=e._state||{},e._state}const Ue=()=>{const e=Pe();return e.globalOptions=e.globalOptions||{...Le},e.globalOptions};function De(e,t,r,s){return r=r||[],function(e,t){Be(e,null,Le,Ne,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]||{};Be(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 Ce);return Fe(s,Ue()),Fe(s,t),s}(t,e,s)}function ke(e,t){const r=Ue(),s=e||r;return"function"==typeof s.fetch?s.fetch:X(s.fetch)?e=>ue(e,s):null!=t&&t.fetch?null==t?void 0:t.fetch:ue}function Be(e,t,r,s,n){const i=t||"Top level",o=t?`${t}.`:"";for(const a in e){const c=!t&&X(e[a]),u="baseUri"===a&&!t,h="workerUrl"===a&&t;if(!(a in r)&&!u&&!h)if(a in s)Ie.warn(`${i} loader option '${o}${a}' no longer supported, use '${s[a]}'`)();else if(!c){const e=je(a,n);Ie.warn(`${i} loader option '${o}${a}' not recognized. ${e}`)()}}}function je(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 Fe(e,t){for(const r in t)if(r in t){const s=t[r];Y(s)&&Y(e[r])?e[r]={...e[r],...t[r]}:e[r]=t[r]}}function Ve(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 qe(e){var t,r;let s;return o(e,"null loader"),o(Ve(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 ze(){return(()=>{const e=Pe();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry})()}const Ge=/\.([^.]+)$/;function He(e,t=[],r,s){if(!We(e))return null;if(t&&!Array.isArray(t))return qe(t);let n=[];t&&(n=n.concat(t)),null!=r&&r.ignoreRegisteredLoaders||n.push(...ze()),function(e){for(const t of e)qe(t)}(n);const i=function(e,t,r,s){const{url:n,type:i}=oe(e),o=n||(null==s?void 0:s.url);let a=null;null!=r&&r.mimeType&&(a=Ke(t,null==r?void 0:r.mimeType));return a=a||function(e,t){const r=t&&Ge.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||Ke(t,i),a=a||function(e,t){if(!t)return null;for(const r of e)if("string"==typeof t){if(Qe(t,r))return r}else if(ArrayBuffer.isView(t)){if(Xe(t.buffer,t.byteOffset,r))return r}else if(t instanceof ArrayBuffer){if(Xe(t,0,r))return r}return null}(t,e),a=a||Ke(t,null==r?void 0:r.fallbackMimeType),a}(e,n,r,s);if(!(i||null!=r&&r.nothrow))throw new Error($e(e));return i}function We(e){return!(e instanceof Response&&204===e.status)}function $e(e){const{url:t,type:r}=oe(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 Ye(e.buffer,e.byteOffset,t);if(e instanceof ArrayBuffer){return Ye(e,0,t)}return""}(e)}", contentType: "${r}"`),t&&(s+=` url: ${t}`),s}function Ke(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 Qe(e,t){if(t.testText)return t.testText(e);return(Array.isArray(t.tests)?t.tests:[t.tests]).some((t=>e.startsWith(t)))}function Xe(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===Ye(e,t,s.length);default:return!1}}(e,t,r,s)))}function Ye(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 Ze=262144;function Je(e,t){return u?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 k(i)}}catch(e){r.releaseLock()}}(e,t):async function*(e,t){for await(const t of e)yield k(t)}(e)}function et(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=Ze}=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(J(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(ee(e))return Je(e,t);if(Z(e)){return Je(e.body,t)}throw new Error("makeIterator")}const tt="Cannot convert supplied data type";async function rt(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(tt)}(e,t);if(J(e)&&(e=await ce(e)),Z(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(ee(e)&&(e=et(e,r)),(n=e)&&"function"==typeof n[Symbol.iterator]||(e=>e&&"function"==typeof e[Symbol.asyncIterator])(e))return V(e);var n;throw new Error(tt)}async function st(e,t,r,s){l(!s||"object"==typeof s),!t||Array.isArray(t)||Ve(t)||(s=void 0,r=t,t=void 0),e=await e,r=r||{};const{url:n}=oe(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(!We(e))return null;let n=He(e,t,{...r,nothrow:!0},s);if(n)return n;if(J(e)&&(n=He(e=await e.slice(0,10).arrayBuffer(),t,r,s)),!(n||null!=r&&r.nothrow))throw new Error($e(e));return n}(e,i,r);return o?(s=function(e,t,r=null){if(r)return r;const s={fetch:ke(t,e),...e};return Array.isArray(s.loaders)||(s.loaders=null),s}({url:n,parse:st,loaders:i},r=De(r,o,i,n),s),await async function(e,t,r,s){if(function(e,t="3.0.10"){l(e,"no worker provided");const r=e.version}(e),t=await rt(t,e,r),e.parseTextSync&&"string"==typeof t)return r.dataType="text",e.parseTextSync(t,r,s,e);if(function(e,t){return!!O.isSupported()&&e.worker&&(null==t?void 0:t.worker)}(e,r))return await N(e,t,r,0,st);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 l(!e.parseSync),new Error(`${e.id} loader - no parser found and worker is disabled`)}(o,e,r,s)):null}async function nt(e,t,r,s){Array.isArray(t)||Ve(t)||(r=t,t=void 0);const n=ke(r);let i=e;return"string"==typeof e&&(i=await n(e)),J(e)&&(i=await n(e)),await st(i,t,r)}function it(e,t){if(!e)throw new Error("math.gl assertion ".concat(t))}const ot=1/Math.PI*180,at=1/180*Math.PI,ct={};function ut(e,{precision:t=ct.precision||4}={}){return e=function(e){return Math.round(e/ct.EPSILON)*ct.EPSILON}(e),"".concat(parseFloat(e.toPrecision(t)))}function ht(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function lt(e,t,r){if(ht(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 dt(e){return function(e,t){return lt(e,(e=>e*at),t)}(e)}function ft(e,t){return lt(e,(e=>e*ot),t)}function pt(e,t,r){const s=ct.EPSILON;r&&(ct.EPSILON=r);try{if(e===t)return!0;if(ht(e)&&ht(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;++r)if(!pt(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)<=ct.EPSILON*Math.max(1,Math.abs(e),Math.abs(t))}finally{ct.EPSILON=s}}ct.EPSILON=1e-12,ct.debug=!1,ct.precision=4,ct.printTypes=!1,ct.printDegrees=!1,ct.printRowMajor=!0;class mt 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 it(!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:ht(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(ct)}formatString(e){let t="";for(let r=0;r<this.ELEMENTS;++r)t+=(r>0?", ":"")+ut(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(!pt(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(ct.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 gt(e){if(!Number.isFinite(e))throw new Error("Invalid number ".concat(e));return e}function yt(e,t,r=""){if(ct.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 wt={};function bt(e,t){wt[e]||(wt[e]=!0,console.warn("".concat(e," has been removed in version ").concat(t,", see upgrade guide for more information")))}class Tt extends mt{get ELEMENTS(){return it(!1),0}copy(e){return it(!1),this}get x(){return this[0]}set x(e){this[0]=gt(e)}get y(){return this[1]}set y(e){this[1]=gt(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 gt(t)}dot(e){let t=0;for(let r=0;r<this.ELEMENTS;++r)t+=this[r]*e[r];return gt(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 it(e>=0&&e<this.ELEMENTS,"index is out of range"),gt(this[e])}setComponent(e,t){return it(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 vt,_t=1e-6,Et="undefined"!=typeof Float32Array?Float32Array:Array;function xt(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 St(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 Mt(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 At(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)}),vt=new Et(2),Et!=Float32Array&&(vt[0]=0,vt[1]=0);class Rt extends Tt{constructor(e=0,t=0){super(2),ht(e)&&1===arguments.length?this.copy(e):(ct.debug&&(gt(e),gt(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 ct.debug&&(gt(e.x),gt(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 St(this,this,e),this.check()}transformAsVector(e){return Mt(this,this,e),this.check()}transformByMatrix3(e){return xt(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 Ot(){var e=new Et(3);return Et!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function It(e){var t=e[0],r=e[1],s=e[2];return Math.hypot(t,r,s)}function Ct(e,t,r){var s=new Et(3);return s[0]=e,s[1]=t,s[2]=r,s}function Lt(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Nt(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 Pt(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 Ut(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 Dt(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 kt(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 Bt(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 jt(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 Ft(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&&Lt(e,t)/c;return Math.acos(Math.min(Math.max(u,-1),1))}var Vt=It;!function(){var e=Ot()}();const qt=[0,0,0],zt={};class Gt extends Tt{static get ZERO(){return zt.ZERO=zt.ZERO||Object.freeze(new Gt(0,0,0,0))}constructor(e=0,t=0,r=0){super(-0,-0,-0),1===arguments.length&&ht(e)?this.copy(e):(ct.debug&&(gt(e),gt(t),gt(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 ct.debug&&(gt(e.x),gt(e.y),gt(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]=gt(e)}angle(e){return Ft(this,e)}cross(e){return Nt(this,this,e),this.check()}rotateX({radians:e,origin:t=qt}){return kt(this,this,t,e),this.check()}rotateY({radians:e,origin:t=qt}){return Bt(this,this,t,e),this.check()}rotateZ({radians:e,origin:t=qt}){return jt(this,this,t,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return Pt(this,this,e),this.check()}transformAsVector(e){return At(this,this,e),this.check()}transformByMatrix3(e){return Ut(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 Dt(this,this,e),this.check()}}class Ht extends mt{get ELEMENTS(){return it(!1),0}get RANK(){return it(!1),0}toString(){let e="[";if(ct.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]=gt(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 Wt(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 $t(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 Kt=Object.freeze([1,0,0,0,1,0,0,0,1]),Qt=Object.freeze([0,0,0,0,0,0,0,0,0]),Xt=Object.freeze({COL0ROW0:0,COL0ROW1:1,COL0ROW2:2,COL1ROW0:3,COL1ROW1:4,COL1ROW2:5,COL2ROW0:6,COL2ROW1:7,COL2ROW2:8}),Yt={};class Zt extends Ht{static get IDENTITY(){return Yt.IDENTITY=Yt.IDENTITY||Object.freeze(new Zt(Kt)),Yt.IDENTITY}static get ZERO(){return Yt.ZERO=Yt.ZERO||Object.freeze(new Zt(Qt)),Yt.ZERO}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return Xt}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(Kt)}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 Wt(this,e,this),this.check()}multiplyRight(e){return Wt(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)?$t(this,this,e):$t(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=xt(t||[-0,-0],e,this);break;case 3:t=Ut(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 yt(t,e.length),t}transformVector(e,t){return bt("Matrix3.transformVector"),this.transform(e,t)}transformVector2(e,t){return bt("Matrix3.transformVector"),this.transform(e,t)}transformVector3(e,t){return bt("Matrix3.transformVector"),this.transform(e,t)}}function Jt(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 er(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,M=h*y-f*p,A=l*g-d*m,R=l*y-f*m,O=d*y-f*g,I=w*O-b*R+T*A+v*M-_*S+E*x;return I?(I=1/I,e[0]=(a*O-c*R+u*A)*I,e[1]=(n*R-s*O-i*A)*I,e[2]=(m*E-g*_+y*v)*I,e[3]=(d*_-l*E-f*v)*I,e[4]=(c*M-o*O-u*S)*I,e[5]=(r*O-n*M+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*M+u*x)*I,e[9]=(s*M-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*A-c*x)*I,e[13]=(r*A-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 tr(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 rr(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 sr(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 nr(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 ir(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,M,A,R=s[0],O=s[1],I=s[2],C=Math.hypot(R,O,I);return C<_t?null:(R*=C=1/C,O*=C,I*=C,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,M=O*I*o-R*n,A=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*M+m*A,e[9]=c*S+d*M+g*A,e[10]=u*S+f*M+y*A,e[11]=h*S+p*M+w*A,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function or(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 ar(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 cr(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 ur(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 hr(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 lr(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 dr(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 fr(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)<_t&&Math.abs(m-v)<_t&&Math.abs(g-_)<_t?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 pr(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 Et(4);return Et!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}()}();const mr=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),gr=Object.freeze([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),yr=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}),wr={};class br extends Ht{static get IDENTITY(){return wr.IDENTITY=wr.IDENTITY||Object.freeze(new br(mr)),wr.IDENTITY}static get ZERO(){return wr.ZERO=wr.ZERO||Object.freeze(new br(gr)),wr.ZERO}get INDICES(){return yr}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(mr)}fromQuaternion(e){return ur(this,e),this.check()}frustum({left:e,right:t,bottom:r,top:s,near:n,far:i}){return i===1/0?br._computeInfinitePerspectiveOffCenter(this,e,t,r,s,n):hr(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),fr(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 dr(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 br).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 lr(this,e,r,s,n),this.check()}determinant(){return tr(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 Jt(this,this),this.check()}invert(){return er(this,this),this.check()}multiplyLeft(e){return rr(this,e,this),this.check()}multiplyRight(e){return rr(this,this,e),this.check()}rotateX(e){return or(this,this,e),this.check()}rotateY(e){return ar(this,this,e),this.check()}rotateZ(e){return cr(this,this,e),this.check()}rotateXYZ([e,t,r]){return this.rotateX(e).rotateY(t).rotateZ(r)}rotateAxis(e,t){return ir(this,this,e,t),this.check()}scale(e){return Array.isArray(e)?nr(this,this,e):nr(this,this,[e,e,e]),this.check()}translate(e){return sr(this,this,e),this.check()}transform(e,t){return 4===e.length?(yt(t=pr(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=St(t||[-0,-0],e,this);break;case 3:t=Pt(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return yt(t,e.length),t}transformAsVector(e,t){switch(e.length){case 2:t=Mt(t||[-0,-0],e,this);break;case 3:t=At(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return yt(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 bt("Matrix4.transformPoint","3.0"),this.transformAsPoint(e,t)}transformVector(e,t){return bt("Matrix4.transformVector","3.0"),this.transformAsPoint(e,t)}transformDirection(e,t){return bt("Matrix4.transformDirection","3.0"),this.transformAsVector(e,t)}}function Tr(){var e=new Et(4);return Et!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function vr(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 _r(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 Er(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>_t?(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 xr(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 Sr,Mr,Ar,Rr=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},Or=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},Ir=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},Cr=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},Lr=function(e){var t=e[0],r=e[1],s=e[2],n=e[3];return Math.hypot(t,r,s,n)},Nr=function(e){var t=e[0],r=e[1],s=e[2],n=e[3];return t*t+r*r+s*s+n*n},Pr=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},Ur=(Sr=Ot(),Mr=Ct(1,0,0),Ar=Ct(0,1,0),function(e,t,r){var s=Lt(t,r);return s<-.999999?(Nt(Sr,Mr,t),Vt(Sr)<1e-6&&Nt(Sr,Ar,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}(Sr,Sr),vr(e,Sr,Math.PI),e):s>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(Nt(Sr,t,r),e[0]=Sr[0],e[1]=Sr[1],e[2]=Sr[2],e[3]=1+s,Pr(e,e))});Tr(),Tr(),function(){var e=new Et(9);Et!=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 Dr=[0,0,0,1];class kr extends mt{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 xr(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 vr(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]=gt(e)}get y(){return this[1]}set y(e){this[1]=gt(e)}get z(){return this[2]}set z(e){this[2]=gt(e)}get w(){return this[3]}set w(e){this[3]=gt(e)}len(){return Lr(this)}lengthSquared(){return Nr(this)}dot(e,t){if(void 0!==t)throw new Error("Quaternion.dot only takes one argument");return Ir(this,e)}rotationTo(e,t){return Ur(this,e,t),this.check()}add(e,t){if(void 0!==t)throw new Error("Quaternion.add only takes one argument");return Rr(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 Cr(this,e,t,r),this.check()}multiplyRight(e,t){return it(!t),_r(this,this,e),this.check()}multiplyLeft(e,t){return it(!t),_r(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 Or(this,this,e),this.check()}slerp(e,t,r){switch(arguments.length){case 1:({start:e=Dr,target:t,ratio:r}=arguments[0]);break;case 2:[t,r]=arguments,e=this}return Er(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),yt(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 Br(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}const jr=1/Math.PI*180,Fr=1/180*Math.PI,Vr={};function qr(e,{precision:t=Vr.precision||4}={}){return e=function(e){return Math.round(e/Vr.EPSILON)*Vr.EPSILON}(e),`${parseFloat(e.toPrecision(t))}`}function zr(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Gr(e,t,r){if(zr(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 Hr(e){return function(e,t){return Gr(e,(e=>e*Fr),t)}(e)}function Wr(e){return function(e,t){return Gr(e,(e=>e*jr),t)}(e)}function $r(e,t,r){const s=Vr.EPSILON;r&&(Vr.EPSILON=r);try{if(e===t)return!0;if(zr(e)&&zr(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;++r)if(!$r(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)<=Vr.EPSILON*Math.max(1,Math.abs(e),Math.abs(t))}finally{Vr.EPSILON=s}}Vr.EPSILON=1e-12,Vr.debug=!1,Vr.precision=4,Vr.printTypes=!1,Vr.printDegrees=!1,Vr.printRowMajor=!0;class Kr 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:zr(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(Vr)}formatString(e){let t="";for(let r=0;r<this.ELEMENTS;++r)t+=(r>0?", ":"")+qr(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(!$r(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(Vr.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 Qr(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${e}`);return e}function Xr(e,t,r=""){if(Vr.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 Yr={};function Zr(e,t){Yr[e]||(Yr[e]=!0,console.warn(`${e} has been removed in version ${t}, see upgrade guide for more information`))}class Jr extends Kr{get ELEMENTS(){return Br(!1),0}copy(e){return Br(!1),this}get x(){return this[0]}set x(e){this[0]=Qr(e)}get y(){return this[1]}set y(e){this[1]=Qr(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 Qr(t)}dot(e){let t=0;for(let r=0;r<this.ELEMENTS;++r)t+=this[r]*e[r];return Qr(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"),Qr(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))}}function es(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 ts=[0,0,0],rs={};class ss extends Jr{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&&zr(e)?this.copy(e):(Vr.debug&&(Qr(e),Qr(t),Qr(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 Vr.debug&&(Qr(e.x),Qr(e.y),Qr(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]=Qr(e)}angle(e){return Ft(this,e)}cross(e){return Nt(this,this,e),this.check()}rotateX({radians:e,origin:t=ts}){return kt(this,this,t,e),this.check()}rotateY({radians:e,origin:t=ts}){return Bt(this,this,t,e),this.check()}rotateZ({radians:e,origin:t=ts}){return jt(this,this,t,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return Pt(this,this,e),this.check()}transformAsVector(e){return es(this,this,e),this.check()}transformByMatrix3(e){return Ut(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 Dt(this,this,e),this.check()}}class ns extends Kr{get ELEMENTS(){return Br(!1),0}get RANK(){return Br(!1),0}toString(){let e="[";if(Vr.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]=Qr(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 is=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]),as=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}),cs={};class us extends ns{static get IDENTITY(){return cs.IDENTITY=cs.IDENTITY||Object.freeze(new us(is)),cs.IDENTITY}static get ZERO(){return cs.ZERO=cs.ZERO||Object.freeze(new us(os)),cs.ZERO}get INDICES(){return as}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(is)}fromQuaternion(e){return ur(this,e),this.check()}frustum({left:e,right:t,bottom:r,top:s,near:n,far:i}){return i===1/0?us._computeInfinitePerspectiveOffCenter(this,e,t,r,s,n):hr(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),fr(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 dr(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 us).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 lr(this,e,r,s,n),this.check()}determinant(){return tr(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 Jt(this,this),this.check()}invert(){return er(this,this),this.check()}multiplyLeft(e){return rr(this,e,this),this.check()}multiplyRight(e){return rr(this,this,e),this.check()}rotateX(e){return or(this,this,e),this.check()}rotateY(e){return ar(this,this,e),this.check()}rotateZ(e){return cr(this,this,e),this.check()}rotateXYZ([e,t,r]){return this.rotateX(e).rotateY(t).rotateZ(r)}rotateAxis(e,t){return ir(this,this,e,t),this.check()}scale(e){return Array.isArray(e)?nr(this,this,e):nr(this,this,[e,e,e]),this.check()}translate(e){return sr(this,this,e),this.check()}transform(e,t){return 4===e.length?(Xr(t=pr(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=St(t||[-0,-0],e,this);break;case 3:t=Pt(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Xr(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=es(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Xr(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 Zr("Matrix4.transformPoint","3.0"),this.transformAsPoint(e,t)}transformVector(e,t){return Zr("Matrix4.transformVector","3.0"),this.transformAsPoint(e,t)}transformDirection(e,t){return Zr("Matrix4.transformDirection","3.0"),this.transformAsVector(e,t)}}var hs=.1,ls=1e-12,ds=1e-15;Math.PI,Math.PI,Math.PI,Math.PI;const fs=e=>e,ps=new ss;function ms(e,t=ps){return function(e,t,r=fs){return zr(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,Vr._cartographicRadians?fs:Hr)}function gs(e,t){return function(e,t,r=fs){return zr(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,Vr._cartographicRadians?fs:Wr)}const ys=new ss,ws=new ss,bs=new ss;const Ts=new ss,vs={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"}},_s={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},Es={east:new ss,north:new ss,up:new ss,west:new ss,south:new ss,down:new ss},xs=new ss,Ss=new ss,Ms=new ss;function As(e,t,r,s,n,i){const o=vs[t]&&vs[t][r];let a,c,u;Br(o&&(!s||s===o));const h=Ts.copy(n);if($r(h.x,0,1e-14)&&$r(h.y,0,1e-14)){const e=Math.sign(h.z);a=xs.fromArray(_s[t]),"east"!==t&&"west"!==t&&a.scale(e),c=Ss.fromArray(_s[r]),"east"!==r&&"west"!==r&&c.scale(e),u=Ms.fromArray(_s[s]),"east"!==s&&"west"!==s&&u.scale(e)}else{const{up:n,east:i,north:o}=Es;i.set(-h.y,h.x,0).normalize(),e.geodeticSurfaceNormal(h,n),o.copy(n).cross(i);const{down:l,west:d,south:f}=Es;l.copy(n).scale(-1),d.copy(i).scale(-1),f.copy(o).scale(-1),a=Es[t],c=Es[r],u=Es[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 Rs=new ss,Os=new ss,Is=new ss,Cs=new ss,Ls=new ss,Ns=new ss;let Ps;class Us{static get WGS84(){return Ps=Ps||new Us(6378137,6378137,6356752.314245179),Ps}constructor(e=0,t=0,r=0){Br(e>=0),Br(t>=0),Br(r>=0),this.radii=new ss(e,t,r),this.radiiSquared=new ss(e*e,t*t,r*r),this.radiiToTheFourth=new ss(e*e*e*e,t*t*t*t,r*r*r*r),this.oneOverRadii=new ss(0===e?0:1/e,0===t?0:1/t,0===r?0:1/r),this.oneOverRadiiSquared=new ss(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=hs,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=Os,s=Is,[,,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]){Ns.from(e);const r=this.scaleToGeodeticSurface(Ns,Cs);if(!r)return;const s=this.geodeticSurfaceNormal(r,Os),n=Ls;n.copy(Ns).subtract(r);return gs([Math.atan2(s.y,s.x),Math.asin(s.z),Math.sign(Lt(n,Ns))*It(n)],t)}eastNorthUpToFixedFrame(e,t=new us){return As(this,"east","north","up",e,t)}localFrameToFixedFrame(e,t,r,s,n=new us){return As(this,e,t,r,s,n)}geocentricSurfaceNormal(e,t=[0,0,0]){return Rs.from(e).normalize().to(t)}geodeticSurfaceNormalCartographic(e,t=[0,0,0]){const r=ms(e),s=r[0],n=r[1],i=Math.cos(n);return Rs.set(i*Math.cos(s),i*Math.sin(s),Math.sin(n)).normalize(),Rs.to(t)}geodeticSurfaceNormal(e,t=[0,0,0]){return Rs.from(e).scale(this.oneOverRadiiSquared).normalize().to(t)}scaleToGeodeticSurface(e,t){return function(e,t,r=new ss){const{oneOverRadii:s,oneOverRadiiSquared:n,centerToleranceSquared:i}=t;ys.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=ws;if(y.copy(e).scale(g),m<i)return y.to(r);const w=n.x,b=n.y,T=n.z,v=bs;v.set(y.x*w*2,y.y*b*2,y.z*T*2);let _,E,x,S,M=(1-g)*e.len()/(.5*v.len()),A=0;do{M-=A,_=1/(1+M*w),E=1/(1+M*b),x=1/(1+M*T);const e=_*_,t=E*E,r=x*x;S=d*e+f*t+p*r-1,A=S/(-2*(d*(e*_)*w+f*(t*E)*b+p*(r*x)*T))}while(Math.abs(S)>ls);return ys.scale([_,E,x]).to(r)}(e,this,t)}scaleToGeocentricSurface(e,t=[0,0,0]){Cs.from(e);const r=Cs.x,s=Cs.y,n=Cs.z,i=this.oneOverRadiiSquared,o=1/Math.sqrt(r*r*i.x+s*s*i.y+n*n*i.z);return Cs.multiplyScalar(o).to(t)}transformPositionToScaledSpace(e,t=[0,0,0]){return Cs.from(e).scale(this.oneOverRadii).to(t)}transformPositionFromScaledSpace(e,t=[0,0,0]){return Cs.from(e).scale(this.radii).to(t)}getSurfaceNormalIntersectionWithZAxis(e,t=0,r=[0,0,0]){Br($r(this.radii.x,this.radii.y,ds)),Br(this.radii.z>0),Cs.from(e);const s=Cs.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(s)>=this.radii.z-t))return Cs.set(0,0,s).to(r)}}class Ds{constructor(e,t,r){this.item=e,this.previous=t,this.next=r}}class ks{constructor(){this.head=null,this.tail=null,this._length=0}get length(){return this._length}add(e){const t=new Ds(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 Bs(e){return null!=e}class js{constructor(){w(this,"_list",void 0),w(this,"_sentinel",void 0),w(this,"_trimTiles",void 0),this._list=new ks,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(e){const t=e._cacheNode;Bs(t)&&this._list.splice(this._sentinel,t)}add(e,t,r){Bs(t._cacheNode)||(t._cacheNode=this._list.add(t),r&&r(e,t))}unloadTile(e,t,r){const s=t._cacheNode;Bs(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 Fs=Object.freeze({OUTSIDE:-1,INTERSECTING:0,INSIDE:1});new Gt,new Gt;const Vs=new Gt,qs=new Gt;class zs{constructor(e=[0,0,0],t=0){this.radius=-0,this.center=new Gt,this.fromCenterRadius(e,t)}fromCenterRadius(e,t){return this.center.from(e),this.radius=t,this}fromCornerPoints(e,t){return t=Vs.from(t),this.center=(new Gt).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 zs(this.center,this.radius)}union(e){const t=this.center,r=this.radius,s=e.center,n=e.radius,i=Vs.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 qs.copy(i).scale((-r+a)/o).add(t),this.center.copy(qs),this.radius=a,this}expand(e){const t=(e=Vs.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}(Vs,e);return this.radius=Math.max(t[0],Math.max(t[1],t[2]))*this.radius,this}distanceSquaredTo(e){return(e=Vs.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?Fs.OUTSIDE:s<r?Fs.INTERSECTING:Fs.INSIDE}}const Gs=new Gt,Hs=new Gt,Ws=new Gt,$s=new Gt,Ks=new Gt,Qs=new Gt,Xs=new Gt,Ys=0,Zs=1,Js=2,en=3,tn=4,rn=5,sn=6,nn=7,on=8;class an{constructor(e=[0,0,0],t=[0,0,0,0,0,0,0,0,0]){this.center=(new Gt).from(e),this.halfAxes=new Zt(t)}get halfSize(){const e=this.halfAxes.getColumn(0),t=this.halfAxes.getColumn(1),r=this.halfAxes.getColumn(2);return[new Gt(e).len(),new Gt(t).len(),new Gt(r).len()]}get quaternion(){const e=this.halfAxes.getColumn(0),t=this.halfAxes.getColumn(1),r=this.halfAxes.getColumn(2),s=new Gt(e).normalize(),n=new Gt(t).normalize(),i=new Gt(r).normalize();return(new kr).fromMatrix3(new Zt([...s,...n,...i]))}fromCenterHalfSizeQuaternion(e,t,r){const s=new kr(r),n=(new Zt).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 Gt).from(e),this.halfAxes=n,this}clone(){return new an(this.center,this.halfAxes)}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.halfAxes.equals(e.halfAxes)}getBoundingSphere(e=new zs){const t=this.halfAxes,r=t.getColumn(0,Ws),s=t.getColumn(1,$s),n=t.getColumn(2,Ks),i=Gs.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[Ys]+i*s[Zs]+o*s[Js])+Math.abs(n*s[en]+i*s[tn]+o*s[rn])+Math.abs(n*s[sn]+i*s[nn]+o*s[on]),c=r.dot(t)+e.distance;return c<=-a?Fs.OUTSIDE:c>=a?Fs.INSIDE:Fs.INTERSECTING}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){const t=Hs.from(e).subtract(this.center),r=this.halfAxes,s=r.getColumn(0,Ws),n=r.getColumn(1,$s),i=r.getColumn(2,Ks),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,Ws),c=o.getColumn(1,$s),u=o.getColumn(2,Ks),h=Qs.copy(a).add(c).add(u).add(i),l=Xs.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,Ws);t.transformAsPoint(e);const r=this.halfAxes.getColumn(1,$s);r.transformAsPoint(e);const s=this.halfAxes.getColumn(2,Ks);return s.transformAsPoint(e),this.halfAxes=new Zt([...t,...r,...s]),this}getTransform(){throw new Error("not implemented")}}const cn=new Gt,un=new Gt;class hn{constructor(e=[0,0,1],t=0){this.normal=new Gt,this.distance=-0,this.fromNormalDistance(e,t)}fromNormalDistance(e,t){return it(Number.isFinite(t)),this.normal.from(e).normalize(),this.distance=t,this}fromPointNormal(e,t){e=cn.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),it(pt(this.normal.len(),1)),this.distance=s,this}clone(e){return new hn(this.normal,this.distance)}equals(e){return pt(this.distance,e.distance)&&pt(this.normal,e.normal)}getPointDistance(e){return this.normal.dot(e)+this.distance}transform(e){const t=un.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=cn.from(e);const r=this.getPointDistance(e),s=un.copy(this.normal).scale(r);return e.subtract(s).to(t)}}const ln=[new Gt([1,0,0]),new Gt([0,1,0]),new Gt([0,0,1])],dn=new Gt,fn=new Gt;new hn(new Gt(1,0,0),0);class pn{static get MASK_OUTSIDE(){return 4294967295}static get MASK_INSIDE(){return 0}static get MASK_INDETERMINATE(){return 2147483647}constructor(e=[]){this.planes=e,it(this.planes.every((e=>e instanceof hn)))}fromBoundingSphere(e){this.planes.length=2*ln.length;const t=e.center,r=e.radius;let s=0;for(const e of ln){let n=this.planes[s],i=this.planes[s+1];n||(n=this.planes[s]=new hn),i||(i=this.planes[s+1]=new hn);const o=dn.copy(e).scale(-r).add(t);e.dot(o),n.fromPointNormal(o,e);const a=dn.copy(e).scale(r).add(t),c=fn.copy(e).negate();c.dot(a),i.fromPointNormal(a,c),s+=2}return this}computeVisibility(e){it(e);let t=Fs.INSIDE;for(const r of this.planes){switch(e.intersectPlane(r)){case Fs.OUTSIDE:return Fs.OUTSIDE;case Fs.INTERSECTING:t=Fs.INTERSECTING}}return t}computeVisibilityWithPlaneMask(e,t){if(it(e,"boundingVolume is required."),it(Number.isFinite(t),"parentPlaneMask is required."),t===pn.MASK_OUTSIDE||t===pn.MASK_INSIDE)return t;let r=pn.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===Fs.OUTSIDE)return pn.MASK_OUTSIDE;a===Fs.INTERSECTING&&(r|=i)}return r}}const mn=new Gt,gn=new Gt,yn=new Gt,wn=new Gt,bn=new Gt;class Tn{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 pn([new hn,new hn,new hn,new hn,new hn,new hn]),this._perspectiveMatrix=new br,this._infinitePerspective=new br}clone(){return new Tn({right:this.right,left:this.left,top:this.top,bottom:this.bottom,near:this.near,far:this.far})}equals(e){return e&&e instanceof Tn&&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 vn(this),this._perspectiveMatrix}get infiniteProjectionMatrix(){return vn(this),this._infinitePerspective}computeCullingVolume(e,t,r){it(e,"position is required."),it(t,"direction is required."),it(r,"up is required.");const s=this._cullingVolume.planes;r=mn.copy(r).normalize();const n=gn.copy(t).cross(r).normalize(),i=yn.copy(t).multiplyByScalar(this.near).add(e),o=wn.copy(t).multiplyByScalar(this.far).add(e);let a=bn;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 Gt).copy(t),s[4].fromPointNormal(i,a),a.negate(),s[5].fromPointNormal(o,a),this._cullingVolume}getPixelDimensions(e,t,r,s){vn(this),it(Number.isFinite(e)&&Number.isFinite(t)),it(e>0),it(t>0),it(r>0),it(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 vn(e){it(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||(it(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 br).frustum({left:n,right:s,bottom:r,top:t,near:i,far:o}),e._infinitePerspective=(new br).frustum({left:n,right:s,bottom:r,top:t,near:i,far:1/0}))}class _n{constructor(e={}){e={near:1,far:5e8,xOffset:0,yOffset:0,...e},this._offCenterFrustum=new Tn,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 _n({aspectRatio:this.aspectRatio,fov:this.fov,near:this.near,far:this.far})}equals(e){return null!=e&&e instanceof _n&&(En(this),En(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 En(this),this._offCenterFrustum.projectionMatrix}get infiniteProjectionMatrix(){return En(this),this._offCenterFrustum.infiniteProjectionMatrix}get fovy(){return En(this),this._fovy}get sseDenominator(){return En(this),this._sseDenominator}computeCullingVolume(e,t,r){return En(this),this._offCenterFrustum.computeCullingVolume(e,t,r)}getPixelDimensions(e,t,r,s){return En(this),this._offCenterFrustum.getPixelDimensions(e,t,r,s)}}function En(e){it(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||(it(e.fov>=0&&e.fov<Math.PI),it(e.aspectRatio>0),it(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 Gt,new Gt,new Gt,new Gt,new Gt,new Gt,new Gt,new Gt,new Gt,new Gt,new Gt,new Gt,new Zt,new Zt,new Zt,new Zt,new Zt,new Gt,new Gt,new Gt,new Gt,new Gt,new Zt,new Zt,new Zt;const xn=new Gt,Sn=new Gt,Mn=new pn([new hn,new hn,new hn,new hn,new hn,new hn]);function An(e,t){const{cameraDirection:r,cameraUp:s,height:n}=e,{metersPerUnit:i}=e.distanceScales,o=[e.longitude,e.latitude,0],a=Us.WGS84.cartographicToCartesian(o,new Gt),c=Us.WGS84.eastNorthUpToFixedFrame(a),u=e.unprojectPosition(e.cameraPosition),h=Us.WGS84.cartographicToCartesian(u,new Gt),l=new Gt(c.transformAsVector(new Gt(r).scale(i))).normalize(),d=new Gt(c.transformAsVector(new Gt(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);Sn.copy(i.normal).scale(i.distance-o).add(e.center);const a=e.unprojectPosition(Sn),c=Us.WGS84.cartographicToCartesian(a,new Gt);Mn.planes[s++].fromPointNormal(c,xn.copy(t).subtract(c))}}(e,a),{camera:{position:h,direction:l,up:d},viewport:e,height:n,cullingVolume:Mn,frameNumber:t,sseDenominator:1.15}}const Rn=6356752.314245179,On=new Gt;function In(e){const{halfAxes:t,radius:r,width:s,height:n}=e;if(t){const e=function(e){e.getColumn(0,On);const t=e.getColumn(1),r=e.getColumn(2),s=On.add(t).add(r);return s.len()}(t);return Math.log2(Rn/e)}if(r)return Math.log2(Rn/r);if(n&&s){return(Math.log2(6378137/s)+Math.log2(6378137/n))/2}return 1}const Cn=0,Ln=1,Nn=3,Pn=4,Un=5,Dn=1,kn=2,Bn="empty",jn="scenegraph",Fn="pointcloud",Vn="mesh",qn="I3S",zn="TILES3D",Gn="geometricError",Hn=1;function Wn(e){return null!=e}const $n=new Gt,Kn=new Gt,Qn=new Gt;function Xn(e,t,r){if(o(e,"3D Tile: boundingVolume must be defined"),e.box)return function(e,t,r){const s=new Gt(e[0],e[1],e[2]);t.transform(s,s);let n=[];if(10===e.length){const t=e.slice(3,6),r=new kr;r.fromArray(e,6);const s=new Gt([1,0,0]),i=new Gt([0,1,0]),o=new Gt([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 Zt([i[0],i[1],i[2],o[0],o[1],o[2],a[0],a[1],a[2]]);if(Wn(r))return r.center=s,r.halfAxes=c,r;return new an(s,c)}(e.box,t,r);if(e.region){const[t,r,s,n,i,o]=e.region,a=Us.WGS84.cartographicToCartesian([ft(t),ft(n),i],Kn),c=Us.WGS84.cartographicToCartesian([ft(s),ft(r),o],Qn),u=(new Gt).addVectors(a,c).multiplyScalar(.5),h=(new Gt).subVectors(a,c).len()/2;return Yn([u[0],u[1],u[2],h],new br)}if(e.sphere)return Yn(e.sphere,t,r);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function Yn(e,t,r){const s=new Gt(e[0],e[1],e[2]);t.transform(s,s);const n=t.getScale($n),i=Math.max(Math.max(n[0],n[1]),n[2]),o=e[3]*i;return Wn(r)?(r.center=s,r.radius=o,r):new zs(s,o)}function Zn(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 Gt,new Gt,new br,new Gt,new Gt,new Gt;const Jn=6378137,ei=Math.PI/2;function ti([e,t,r]){const s=dt(e),n=dt(t),i=1+r/Jn,o=i*Math.cos(n);return[e=o*Math.cos(s),t=o*Math.sin(s),r=i*Math.sin(n)]}function ri(e,t){const[r,s,n=0]=e,[i,o,a=0]=t,c=ti([i,o,a]),u=ti([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 si(e,t){const r=t.viewport,s=e.header.mbs[1],n=e.header.mbs[0],i=e.header.mbs[2],o=e.header.mbs[3],a=[n,s,i],c=ri(r.unprojectPosition(r.cameraPosition),a),u=o/Jn,h=c-u*u;if(h<=0)return 170141175e30;return function(e){const{projectionMatrix:t}=e.viewport;return t[5]}(t)*u/Math.sqrt(h)*300}class ni{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 o(e<this._array.length),this._array[e]}set(e,t){o(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){o(e>=0),e>this._array.length&&(this._array.length=e)}resize(e){o(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 ii={loadSiblings:!1,skipLevelOfDetail:!1,maximumScreenSpaceError:2,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""};class oi{constructor(e){w(this,"options",void 0),w(this,"root",void 0),w(this,"requestedTiles",void 0),w(this,"selectedTiles",void 0),w(this,"emptyTiles",void 0),w(this,"_traversalStack",void 0),w(this,"_emptyTraversalStack",void 0),w(this,"_frameNumber",void 0),this.options={...ii,...e},this._traversalStack=new ni,this._emptyTraversalStack=new ni,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===Dn?(this.loadTile(e,t),this.selectTile(e,t)):e.refine===kn&&(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===kn&&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 ai=new Gt;class ci{constructor(e,t,r,s=""){w(this,"tileset",void 0),w(this,"header",void 0),w(this,"id",void 0),w(this,"url",void 0),w(this,"parent",void 0),w(this,"refine",void 0),w(this,"type",void 0),w(this,"contentUrl",void 0),w(this,"lodMetricType",void 0),w(this,"lodMetricValue",void 0),w(this,"boundingVolume",void 0),w(this,"content",void 0),w(this,"contentState",void 0),w(this,"gpuMemoryUsageInBytes",void 0),w(this,"children",void 0),w(this,"depth",void 0),w(this,"viewportIds",void 0),w(this,"transform",void 0),w(this,"userData",void 0),w(this,"computedTransform",void 0),w(this,"hasEmptyContent",void 0),w(this,"hasTilesetContent",void 0),w(this,"traverser",void 0),w(this,"_cacheNode",void 0),w(this,"_frameNumber",void 0),w(this,"_lodJudge",void 0),w(this,"_expireDate",void 0),w(this,"_expiredContent",void 0),w(this,"_shouldRefine",void 0),w(this,"_distanceToCamera",void 0),w(this,"_centerZDepth",void 0),w(this,"_screenSpaceError",void 0),w(this,"_visibilityPlaneMask",void 0),w(this,"_visible",void 0),w(this,"_inRequestVolume",void 0),w(this,"_stackLength",void 0),w(this,"_selectionDepth",void 0),w(this,"_touchedFrame",void 0),w(this,"_visitedFrame",void 0),w(this,"_selectedFrame",void 0),w(this,"_requestedFrame",void 0),w(this,"_priority",void 0),w(this,"_contentBoundingVolume",void 0),w(this,"_viewerRequestVolume",void 0),w(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=Cn,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 oi({}),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 br,this.transform=new br,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===Nn||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===Cn}get contentExpired(){return this.contentState===Pn}get contentFailed(){return this.contentState===Un}getScreenSpaceError(e,t){switch(this.tileset.type){case qn:return si(this,e);case zn: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-=Zn(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===Dn||t;if(r&&!this.isVisible&&void 0!==this._visible)return-1;if(this.tileset._frameNumber-this._touchedFrame>=1)return-1;if(this.contentState===Cn)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=Ln;const e=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!e)return this.contentState=Cn,!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 nt(t,r,s),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=Nn,this._onContentLoaded(),!0}catch(e){throw this.contentState=Un,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=Cn,!0}updateVisibility(e,t){if(this._frameNumber===e.frameNumber)return;const r=this.parent,s=r?r._visibilityPlaneMask:pn.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!==pn.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 ai.subVectors(t.center,e.position),e.direction.dot(ai)}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=Pn,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 br(e.transform):new br;const t=this.parent,r=this.tileset,s=t&&t.computedTransform?t.computedTransform.clone():r.modelMatrix.clone();this.computedTransform=new br(s).multiplyRight(this.transform);const n=t&&t._initialTransform?t._initialTransform.clone():new br;this._initialTransform=new br(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=Cn,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=pn.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||kn}_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=Xn(e.boundingVolume,this.computedTransform,this.boundingVolume);const t=e.content;t&&(t.boundingVolume&&(this._contentBoundingVolume=Xn(t.boundingVolume,this.computedTransform,this._contentBoundingVolume)),e.viewerRequestVolume&&(this._viewerRequestVolume=Xn(e.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(e=new br){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 ui extends oi{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===kn,n=e._optimChildrenWithinParent===Hn;s&&n&&r&&!this.anyChildrenVisible(e,t)&&(e._visible=!1)}meetsScreenSpaceErrorEarly(e,t){const{parent:r}=e;return!(!r||r.hasTilesetContent||r.refine!==Dn)&&!this.shouldRefine(e,t,!0)}}const hi="REQUESTED",li="COMPLETED",di="ERROR";class fi{constructor(){w(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:hi},e().then((e=>{this._statusMap[t].status=li,this._statusMap[t].callback(e,s)})).catch((e=>{this._statusMap[t].status=di,r(e)})))}update(e,t){this._statusMap[e]&&(this._statusMap[e].frameState=t)}find(e){return this._statusMap[e]}}class pi extends oi{constructor(e){super(e),w(this,"_tileManager",void 0),this._tileManager=new fi}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=ri(d,f),w=.5*c+a/Jn,b=.5*u+a/Jn;if(y>g+a/Jn)return"OUT";if(ri(d,p)>w)return"OUT";if(ri(d,m)>b)return"OUT";if(0===e.lodMetricValue)return"DIG";let T=si(e,t);return T*=ei,T<.5?"OUT":!e.header.children||T<=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 nt(s,r,n)}_onTileLoad(e,t,r){const s=new ci(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 mi={description:"",ellipsoid:Us.WGS84,modelMatrix:new br,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:{}},gi="Tiles In Tileset(s)",yi="Tiles In Memory",wi="Tiles In View",bi="Tiles To Render",Ti="Tiles Loaded",vi="Tiles Loading",_i="Tiles Unloaded",Ei="Failed Tile Loads",xi="Points",Si="Tile Memory Use";class Mi{constructor(e,t){w(this,"options",void 0),w(this,"loadOptions",void 0),w(this,"type",void 0),w(this,"tileset",void 0),w(this,"loader",void 0),w(this,"url",void 0),w(this,"basePath",void 0),w(this,"modelMatrix",void 0),w(this,"ellipsoid",void 0),w(this,"lodMetricType",void 0),w(this,"lodMetricValue",void 0),w(this,"refine",void 0),w(this,"root",void 0),w(this,"roots",void 0),w(this,"asset",void 0),w(this,"description",void 0),w(this,"properties",void 0),w(this,"extras",void 0),w(this,"attributions",void 0),w(this,"credits",void 0),w(this,"stats",void 0),w(this,"traverseCounter",void 0),w(this,"geometricError",void 0),w(this,"selectedTiles",void 0),w(this,"cartographicCenter",void 0),w(this,"cartesianCenter",void 0),w(this,"zoom",void 0),w(this,"boundingVolume",void 0),w(this,"gpuMemoryUsageInBytes",void 0),w(this,"dynamicScreenSpaceErrorComputedDensity",void 0),w(this,"_traverser",void 0),w(this,"_cache",void 0),w(this,"_requestScheduler",void 0),w(this,"_frameNumber",void 0),w(this,"_queryParamsString",void 0),w(this,"_queryParams",void 0),w(this,"_extensionsUsed",void 0),w(this,"_tiles",void 0),w(this,"_pendingCount",void 0),w(this,"lastUpdatedVieports",void 0),w(this,"_requestedTiles",void 0),w(this,"_emptyTiles",void 0),w(this,"frameStateData",void 0),w(this,"maximumMemoryUsage",void 0),o(e),this.options={...mi,...t},this.tileset=e,this.loader=e.loader,this.type=e.type,this.url=e.url,this.basePath=e.basePath||$(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 js,this._requestScheduler=new W({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 G({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=An(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(wi).count=this.selectedTiles.length,this.stats.get(bi).count=e,this.stats.get(xi).count=t}_initializeTileSet(e){this.root=this._initializeTileHeaders(e,null),this.type===zn&&this._initializeCesiumTileset(e),this.type===qn&&this._initializeI3STileset(),this._calculateViewProps()}_calculateViewProps(){const e=this.root;o(e);const{center:t}=e.boundingVolume;if(!t)return console.warn("center was not pre-calculated for the root tile"),this.cartographicCenter=new Gt,void(this.zoom=1);this.cartographicCenter=Us.WGS84.cartesianToCartographic(t,new Gt),this.cartesianCenter=t,this.zoom=In(e.boundingVolume)}_initializeStats(){this.stats.get(gi),this.stats.get(vi),this.stats.get(yi),this.stats.get(wi),this.stats.get(bi),this.stats.get(Ti),this.stats.get(_i),this.stats.get(Ei),this.stats.get(xi,"memory"),this.stats.get(Si,"memory")}_initializeTileHeaders(e,t){const r=new ci(this,e.root,t);if(t&&(t.children.push(r),r.depth=t.depth+1),this.type===zn){const e=[];for(e.push(r);e.length>0;){const t=e.pop();this.stats.get(gi).incrementCount();const r=t.header.children||[];for(const s of r){const r=new ci(this,s,t);t.children.push(r),r.depth=t.depth+1,e.push(r)}}}return r}_initializeTraverser(){let e;switch(this.type){case zn:e=ui;break;case qn:e=pi;break;default:e=oi}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(Ei).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){o(e),o(t);const{rtcCenter:r,gltfUpAxis:s}=t,{computedTransform:n,boundingVolume:{center:i}}=e;let a=new br(n);switch(r&&a.translate(r),s){case"Z":break;case"Y":const e=(new br).rotateX(Math.PI/2);a=a.multiplyRight(e);break;case"X":const t=(new br).rotateY(-Math.PI/2);a=a.multiplyRight(t)}t.isQuantized&&a.translate(t.quantizedVolumeOffset).scale(t.quantizedVolumeScale);const c=new Gt(i);t.cartesianModelMatrix=a,t.cartesianOrigin=c;const u=Us.WGS84.cartesianToCartographic(c,new Gt),h=Us.WGS84.eastNorthUpToFixedFrame(c).invert();t.cartographicModelMatrix=h.multiplyRight(a),t.cartographicOrigin=u,t.modelMatrix=t.cartographicModelMatrix}(e,e.content),this._addTileToCache(e),this.options.onTileLoad(e))}_onStartTileLoading(){this._pendingCount++,this.stats.get(vi).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(vi).decrementCount()}_addTileToCache(e){this._cache.add(this,e,(t=>t._updateCacheStats(e)))}_updateCacheStats(e){this.stats.get(Ti).incrementCount(),this.stats.get(yi).incrementCount(),this.gpuMemoryUsageInBytes+=e.content.byteLength||0,this.stats.get(Si).count=this.gpuMemoryUsageInBytes}_unloadTile(e){this.gpuMemoryUsageInBytes-=e.content&&e.content.byteLength||0,this.stats.get(yi).decrementCount(),this.stats.get(_i).incrementCount(),this.stats.get(Si).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 Ai="cmpt",Ri="pnts",Oi="b3dm",Ii="i3dm";function Ci(e,t,r){o(e instanceof ArrayBuffer);const s=new TextDecoder("utf8"),n=new Uint8Array(e,t,r);return s.decode(n)}const Li={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 Ni{constructor(e,t){w(this,"fields",void 0),w(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 Ni(r,this.metadata)}selectAt(...e){const t=e.map((e=>this.fields[e])).filter(Boolean);return new Ni(t,this.metadata)}assign(e){let t,r=this.metadata;if(e instanceof Ni){const s=e;t=s.fields,r=Pi(Pi(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 Ni(n,r)}}function Pi(e,t){return new Map([...e||new Map,...t||new Map])}class Ui{constructor(e,t,r=!1,s=new Map){w(this,"name",void 0),w(this,"type",void 0),w(this,"nullable",void 0),w(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 Ui(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 Di,ki,Bi,ji;!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"}(Di||(Di={}));class Fi{static isNull(e){return e&&e.typeId===Di.Null}static isInt(e){return e&&e.typeId===Di.Int}static isFloat(e){return e&&e.typeId===Di.Float}static isBinary(e){return e&&e.typeId===Di.Binary}static isUtf8(e){return e&&e.typeId===Di.Utf8}static isBool(e){return e&&e.typeId===Di.Bool}static isDecimal(e){return e&&e.typeId===Di.Decimal}static isDate(e){return e&&e.typeId===Di.Date}static isTime(e){return e&&e.typeId===Di.Time}static isTimestamp(e){return e&&e.typeId===Di.Timestamp}static isInterval(e){return e&&e.typeId===Di.Interval}static isList(e){return e&&e.typeId===Di.List}static isStruct(e){return e&&e.typeId===Di.Struct}static isUnion(e){return e&&e.typeId===Di.Union}static isFixedSizeBinary(e){return e&&e.typeId===Di.FixedSizeBinary}static isFixedSizeList(e){return e&&e.typeId===Di.FixedSizeList}static isMap(e){return e&&e.typeId===Di.Map}static isDictionary(e){return e&&e.typeId===Di.Dictionary}get typeId(){return Di.NONE}compareTo(e){return this===e}}ki=Symbol.toStringTag;class Vi extends Fi{constructor(e,t){super(),w(this,"isSigned",void 0),w(this,"bitWidth",void 0),this.isSigned=e,this.bitWidth=t}get typeId(){return Di.Int}get[ki](){return"Int"}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}class qi extends Vi{constructor(){super(!0,8)}}class zi extends Vi{constructor(){super(!0,16)}}class Gi extends Vi{constructor(){super(!0,32)}}class Hi extends Vi{constructor(){super(!1,8)}}class Wi extends Vi{constructor(){super(!1,16)}}class $i extends Vi{constructor(){super(!1,32)}}const Ki=32,Qi=64;Bi=Symbol.toStringTag;class Xi extends Fi{constructor(e){super(),w(this,"precision",void 0),this.precision=e}get typeId(){return Di.Float}get[Bi](){return"Float"}toString(){return`Float${this.precision}`}}class Yi extends Xi{constructor(){super(Ki)}}class Zi extends Xi{constructor(){super(Qi)}}ji=Symbol.toStringTag;class Ji extends Fi{constructor(e,t){super(),w(this,"listSize",void 0),w(this,"children",void 0),this.listSize=e,this.children=[t]}get typeId(){return Di.FixedSizeList}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get[ji](){return"FixedSizeList"}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}function eo(e,t,r){const s=r?to(r.metadata):void 0,n=function(e){switch(e.constructor){case Int8Array:return new qi;case Uint8Array:return new Hi;case Int16Array:return new zi;case Uint16Array:return new Wi;case Int32Array:return new Gi;case Uint32Array:return new $i;case Float32Array:return new Yi;case Float64Array:return new Zi;default:throw new Error("array type not supported")}}(t.value);return new Ui(e,new Ji(t.size,new Ui("value",n)),!1,s)}function to(e){const t=new Map;for(const r in e)t.set(`${r}.string`,JSON.stringify(e[r]));return t}const ro={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},so={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array};class no{constructor(e){w(this,"draco",void 0),w(this,"decoder",void 0),w(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=to(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=eo(t,e[t],i[t]);n.push(r)}if(r){const e=eo("indices",r);n.push(e)}return new Ni(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=so[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 ro){if(this.draco[e]===s)return ro[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 io="https://www.gstatic.com/draco/versioned/decoders/1.4.1/draco_decoder.js",oo="https://www.gstatic.com/draco/versioned/decoders/1.4.1/draco_wasm_wrapper.js",ao="https://www.gstatic.com/draco/versioned/decoders/1.4.1/draco_decoder.wasm";let co;async function uo(e){const t=e.modules||{};return co=t.draco3d?co||t.draco3d.createDecoderModule({}).then((e=>({draco:e}))):co||async function(e){let t,r;switch(e.draco&&e.draco.decoderType){case"js":t=await L(io,"draco",e);break;case"wasm":default:[t,r]=await Promise.all([await L(oo,"draco",e),await L(ao,"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 co}const ho={...Li,parse:async function(e,t){const{draco:r}=await uo(t),s=new no(r);try{return s.parseSync(e,null==t?void 0:t.draco)}finally{s.destroy()}}};const lo={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},fo={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,...lo},po={[lo.DOUBLE]:Float64Array,[lo.FLOAT]:Float32Array,[lo.UNSIGNED_SHORT]:Uint16Array,[lo.UNSIGNED_INT]:Uint32Array,[lo.UNSIGNED_BYTE]:Uint8Array,[lo.BYTE]:Int8Array,[lo.SHORT]:Int16Array,[lo.INT]:Int32Array},mo={DOUBLE:lo.DOUBLE,FLOAT:lo.FLOAT,UNSIGNED_SHORT:lo.UNSIGNED_SHORT,UNSIGNED_INT:lo.UNSIGNED_INT,UNSIGNED_BYTE:lo.UNSIGNED_BYTE,BYTE:lo.BYTE,SHORT:lo.SHORT,INT:lo.INT},go="Failed to convert GL type";class yo{static fromTypedArray(e){e=ArrayBuffer.isView(e)?e.constructor:e;for(const t in po){if(po[t]===e)return t}throw new Error(go)}static fromName(e){const t=mo[e];if(!t)throw new Error(go);return t}static getArrayType(e){switch(e){case lo.UNSIGNED_SHORT_5_6_5:case lo.UNSIGNED_SHORT_4_4_4_4:case lo.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:const t=po[e];if(!t)throw new Error(go);return t}}static getByteSize(e){return yo.getArrayType(e).BYTES_PER_ELEMENT}static validate(e){return Boolean(yo.getArrayType(e))}static createTypedArray(e,t,r=0,s){void 0===s&&(s=(t.byteLength-r)/yo.getByteSize(e));return new(yo.getArrayType(e))(t,r,s)}}function wo(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 bo(e,t=255){return function(e,t,r){return lt(e,(e=>Math.max(t,Math.min(r,e))))}(e,0,t)/t*2-1}function To(e){return e<0?-1:1}function vo(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=bo(e,r),s.y=bo(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))*To(e),s.y=(1-Math.abs(e))*To(s.y)}return s.normalize()}new Rt,new Gt,new Rt,new Rt;class _o{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=fo.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=yo.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=yo.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=yo.createTypedArray(t,r),s[e]=n),n}}const Eo={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},xo={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]]},So={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 Mo=e=>void 0!==e;function Ao(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;Mo(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(Mo(u))for(Mo(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];Mo(h)&&Mo(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)Oo(e,r,stack)}(m),m}(s,r):null}function Ro(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(Mo(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(Mo(n))return n;const i=e.parentIds[t];s=i!==t,t=i}throw new Error("traverseHierarchySingleParent")}(e,t,r)}function Oo(e,t,r){const s=e.parentCounts,n=e.parentIds,i=e.parentIndexes,o=e.classIds.length;if(!Mo(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=Mo(s)?s[t]:1,c=Mo(s)?i[t]:t;for(let s=0;s<a;++s){const i=n[c+s];i!==t&&Oo(e,i,r)}r.pop(t)}function Io(e){return null!=e}const Co=(e,t)=>e,Lo={HIERARCHY:!0,extensions:!0,extras:!0};class No{constructor(e,t,r,s={}){var n;o(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)Lo[e]||(this._properties[e]=this.json[e]);this._binaryProperties=this._initializeBinaryProperties(),s["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=Ao(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),o("string"==typeof t,t),this._hierarchy){return Io(Ro(this._hierarchy,e,((e,r)=>{const s=e.classIds[r];return e.classes[s].name===t})))}return!1}isExactClass(e,t){return o("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),o("string"==typeof t,t),Io(this._properties[t])||this._hasPropertyInHierarchy(e,t)}getPropertyNames(e,t){this._checkBatchId(e),(t=Io(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),o("string"==typeof t,t),this._binaryProperties){const r=this._binaryProperties[t];if(Io(r))return this._getBinaryProperty(r,e)}const r=this._properties[t];if(Io(r))return Co(r[e]);if(this._hierarchy){const r=this._getHierarchyProperty(e,t);if(Io(r))return r}}setProperty(e,t,r){const s=this.featureCount;if(this._checkBatchId(e),o("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];Io(n)||(this._properties[t]=new Array(s),n=this._properties[t]),n[e]=Co(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;o(this.binary,`Property ${e} requires a batch table binary.`),o(r.type,`Property ${e} requires a type.`);const s=function(e,t,r,s){const{componentType:n}=e;o(e.componentType);const i="string"==typeof n?yo.fromName(n):n,a=Eo[e.type],c=xo[e.type],u=So[e.type];return r+=e.byteOffset,{values:yo.createTypedArray(i,t,r,a*s),type:i,size:a,unpacker:c,packer:u}}(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=Ro(this._hierarchy,e,((e,r)=>{const s=e.classIds[r];return Io(e.classes[s].instances[t])}));return Io(r)}_getPropertyNamesInHierarchy(e,t){Ro(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 Ro(this._hierarchy,e,((e,r)=>{const s=e.classIds[r],n=e.classes[s],i=e.classIndexes[r],o=n.instances[t];return Io(o)?Io(o.typedArray)?this._getBinaryProperty(o,i):Co(o[i]):null}))}_setHierarchyProperty(e,t,r,s){const n=Ro(this._hierarchy,t,((e,n)=>{const i=e.classIds[n],a=e.classes[i],c=e.classIndexes[n],u=a.instances[r];return!!Io(u)&&(o(n===t,`Inherited property "${r}" is read-only.`),Io(u.typedArray)?this._setBinaryProperty(u,c,s):u[c]=Co(s),!0)}));return Io(n)}}function Po(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}const Uo="b3dm tile in legacy format.";function Do(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(Uo)):c>=570425344&&(r-=4,n=a,a=i,c=o,i=0,o=0,console.warn(Uo)),e.header.featureTableJsonByteLength=i,e.header.featureTableBinaryByteLength=o,e.header.batchTableJsonByteLength=a,e.header.batchTableBinaryByteLength=c,e.header.batchLength=n,r}function ko(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=Ci(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=Ci(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 Bo(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:fo.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=wo(t[r]);e[3*r]=s[0],e[3*r+1]=s[1],e[3*r+2]=s[2]}return{type:fo.UNSIGNED_BYTE,value:e,size:3,normalized:!0}}return t&&t.length===3*i?{type:fo.UNSIGNED_BYTE,value:t,size:3,normalized:!0}:{type:fo.UNSIGNED_BYTE,value:t,size:4,normalized:!0}}const jo=new Gt;function Fo(e,t,r){return e.isQuantized?r["3d-tiles"]&&r["3d-tiles"].decodeQuantizedPositions?(e.isQuantized=!1,function(e,t){const r=new Gt,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:fo.UNSIGNED_SHORT,value:t,size:3,normalized:!0}:t}async function Vo(e,t,r,s,n){r=ko(e,t,r=Do(e,t,r=Po(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 _o(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",fo.FLOAT,3);const s=function(e,t){let r=null;if(!e.batchIds&&t.hasProperty("BATCH_ID")&&(e.batchIds=t.getPropertyArray("BATCH_ID",fo.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 No(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,ho,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 Gt(r,r,r),e.quantizedVolumeOffset=new Gt(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:Bo(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",fo.FLOAT,3);else if(t.hasProperty("POSITION_QUANTIZED")){const s=t.getPropertyArray("POSITION_QUANTIZED",fo.UNSIGNED_SHORT,3);if(e.isQuantized=!0,e.quantizedRange=65535,e.quantizedVolumeScale=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",fo.FLOAT,3),!e.quantizedVolumeScale)throw new Error("QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");if(e.quantizedVolumeOffset=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",fo.FLOAT,3),!e.quantizedVolumeOffset)throw new Error("QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");e.attributes.positions=Fo(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",fo.UNSIGNED_BYTE,4),e.isTranslucent=!0):t.hasProperty("RGB")?s=t.getPropertyArray("RGB",fo.UNSIGNED_BYTE,3):t.hasProperty("RGB565")&&(s=t.getPropertyArray("RGB565",fo.UNSIGNED_SHORT,1),e.isRGB565=!0),e.attributes.colors=Bo(e,s,r)}t.hasProperty("CONSTANT_RGBA")&&(e.constantRGBA=t.getGlobalProperty("CONSTANT_RGBA",fo.UNSIGNED_BYTE,4))}(e,i,o),function(e,t){if(!e.attributes.normals){let r=null;t.hasProperty("NORMAL")?r=t.getPropertyArray("NORMAL",fo.FLOAT,3):t.hasProperty("NORMAL_OCT16P")&&(r=t.getPropertyArray("NORMAL_OCT16P",fo.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++)vo(t[2*s],t[2*s+1],255,jo),jo.toArray(r,3*s);return{type:fo.FLOAT,size:2,value:r}}return{type:fo.FLOAT,size:2,value:t}}(e,r)}}(e,i),r}const qo="KHR_binary_glTF",zo="KHR_draco_mesh_compression",Go="KHR_lights_punctual",Ho="KHR_materials_unlit",Wo="KHR_techniques_webgl";function $o(e,t){if(!e)throw new Error(t)}const Ko={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:"undefined"!=typeof global&&global,document:"undefined"!=typeof document&&document},Qo=Ko.global||Ko.self||Ko.window,Xo="object"!=typeof process||"[object process]"!==String(process)||process.browser,Yo="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);Yo&&parseFloat(Yo[1]);const{_parseImageNode:Zo}=Qo,Jo="undefined"!=typeof Image,ea="undefined"!=typeof ImageBitmap,ta=Boolean(Zo),ra=!!Xo||ta;function sa(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 na=/^data:image\/svg\+xml/,ia=/\.svg((\?|#).*)?$/;function oa(e){return e&&(na.test(e)||ia.test(e))}function aa(e,t){if(oa(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function ca(e,t,r){const s=function(e,t){if(oa(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 aa(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 ua={};let ha=!0;async function la(e,t,r){let s;if(oa(r)){s=await ca(e,t,r)}else s=aa(e,r);const n=t&&t.imagebitmap;return await async function(e,t=null){!function(e){for(const t in e||ua)return!1;return!0}(t)&&ha||(t=null);if(t)try{return await createImageBitmap(e,t)}catch(e){console.warn(e),ha=!1}return await createImageBitmap(e)}(s,n)}const da=!1,fa=!0;function pa(e){const t=ma(e);return function(e){const t=ma(e);if(!(t.byteLength>=24&&2303741511===t.getUint32(0,da)))return null;return{mimeType:"image/png",width:t.getUint32(16,da),height:t.getUint32(20,da)}}(t)||function(e){const t=ma(e);if(!(t.byteLength>=3&&65496===t.getUint16(0,da)&&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,da);if(s.has(e))return{mimeType:"image/jpeg",height:t.getUint16(n+5,da),width:t.getUint16(n+7,da)};if(!r.has(e))return null;n+=2,n+=t.getUint16(n,da)}return null}(t)||function(e){const t=ma(e);if(!(t.byteLength>=10&&1195984440===t.getUint32(0,da)))return null;return{mimeType:"image/gif",width:t.getUint16(6,fa),height:t.getUint16(8,fa)}}(t)||function(e){const t=ma(e);if(!(t.byteLength>=14&&16973===t.getUint16(0,da)&&t.getUint32(2,fa)===t.byteLength))return null;return{mimeType:"image/bmp",width:t.getUint32(18,fa),height:t.getUint32(22,fa)}}(t)}function ma(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 ga={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(ea)return"imagebitmap";if(Jo)return"image";if(ra)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}();default:return function(e){switch(e){case"auto":return ea||Jo||ra;case"imagebitmap":return ea;case"image":return Jo;case"data":return ra;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}(e),e}}(s)){case"imagebitmap":i=await la(e,t,n);break;case"image":i=await ca(e,t,n);break;case"data":i=await function(e,t){const{mimeType:r}=pa(e)||{},{_parseImageNode:s}=Qo;return $o(s),s(e,r,t)}(e,t);break;default:$o(!1)}return"data"===s&&(i=function(e){switch(sa(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(pa(new DataView(e)))],options:{image:{type:"auto",decode:!0}}};function ya(e,t){if(!e)throw new Error(t||"assert failed: gltf")}function wa(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 ba=["SCALAR","VEC2","VEC3","VEC4"],Ta=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],va=new Map(Ta),_a={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Ea={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},xa={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Sa(e){return ba[e-1]||ba[0]}function Ma(e){const t=va.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function Aa(e,t){const r=xa[e.componentType],s=_a[e.type],n=Ea[e.componentType],i=e.count*s,o=e.count*s*n;return ya(o>=0&&o<=t.byteLength),{ArrayType:r,length:i,byteLength:o}}const Ra={asset:{version:"2.0",generator:"loaders.gl"},buffers:[]};class Oa{constructor(e){w(this,"gltf",void 0),w(this,"sourceBuffers",void 0),w(this,"byteLength",void 0),this.gltf=e||{json:{...Ra},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];ya(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}=Aa(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 ya(t),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=t,this.registerUsedExtension(e),t}addRequiredExtension(e,t={}){return ya(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=pa(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;ya(Number.isFinite(t)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const r={buffer:0,byteOffset:this.byteLength,byteLength:t};return this.byteLength+=j(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:Sa(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:Ma(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=F(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 Ia(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:Sa(r),componentType:Ma(t)}}async function Ca(e,t,r,s){const n=e.getObjectExtension(t,zo);if(!n)return;const i=e.getTypedArrayForBufferView(n.bufferView),o=B(i.buffer,i.byteOffset),{parse:a}=s,c={...r};delete c["3d-tiles"];const u=await a(o,ho,c,s),h=function(e){const t={};for(const r in e){const s=e[r];if("indices"!==r){const e=Ia(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=Ia(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 La(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),u=s.addBufferView(o);return{primitives:[{attributes:c,mode:r,extensions:{[zo]:{bufferView:u,attributes:c}}}]}}function Na(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 Pa={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 Oa(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,zo)&&i.push(Ca(n,e,t,r));await Promise.all(i),n.removeExtension(zo)},encode:function(e,t={}){const r=new Oa(e);for(const e of r.json.meshes||[])La(e),r.addRequiredExtension(zo)}}),KHR_materials_unlit:Object.freeze({__proto__:null,decode:async function(e){const t=new Oa(e),{json:r}=t;t.removeExtension(Ho);for(const e of r.materials||[]){e.extensions&&e.extensions.KHR_materials_unlit&&(e.unlit=!0),t.removeObjectExtension(e,Ho)}},encode:function(e){const t=new Oa(e),{json:r}=t;if(t.materials)for(const e of r.materials||[])e.unlit&&(delete e.unlit,t.addObjectExtension(e,Ho,{}),t.addExtension(Ho))}}),KHR_lights_punctual:Object.freeze({__proto__:null,decode:async function(e){const t=new Oa(e),{json:r}=t,s=t.getExtension(Go);s&&(t.json.lights=s.lights,t.removeExtension(Go));for(const e of r.nodes||[]){const r=t.getObjectExtension(e,Go);r&&(e.light=r.light),t.removeObjectExtension(e,Go)}},encode:async function(e){const t=new Oa(e),{json:r}=t;if(r.lights){const e=t.addExtension(Go);ya(!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,Go,e)}delete t.json.lights}}}),KHR_techniques_webgl:Object.freeze({__proto__:null,decode:async function(e){const t=new Oa(e),{json:r}=t,s=t.getExtension(Wo);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,Wo);r&&(s.technique=Object.assign({},r,e[r.technique]),s.technique.values=Na(s.technique,t)),t.removeObjectExtension(s,Wo)}t.removeExtension(Wo)}},encode:async function(e,t){}})};const Ua={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},Da={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 ka{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 Oa(e),{json:r}=t;for(const e of r.images||[]){const r=t.removeObjectExtension(e,qo);r&&Object.assign(e,r)}r.buffers&&r.buffers[0]&&delete r.buffers[0].uri,t.removeExtension(qo)}(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 Ua)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 Ua)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=Da[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 Ba={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ja={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Fa={TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,REPEAT:10497,LINEAR:9729,NEAREST_MIPMAP_LINEAR:9986},Va={magFilter:Fa.TEXTURE_MAG_FILTER,minFilter:Fa.TEXTURE_MIN_FILTER,wrapS:Fa.TEXTURE_WRAP_S,wrapT:Fa.TEXTURE_WRAP_T},qa={[Fa.TEXTURE_MAG_FILTER]:Fa.LINEAR,[Fa.TEXTURE_MIN_FILTER]:Fa.NEAREST_MIPMAP_LINEAR,[Fa.TEXTURE_WRAP_S]:Fa.REPEAT,[Fa.TEXTURE_WRAP_]:Fa.REPEAT};class za{postProcess(e,t={}){const{json:r,buffers:s=[],images:n=[],baseUri:i=""}=e;return ya(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,ja[r]),e.components=(s=e.type,Ba[s]),e.bytesPerElement=e.bytesPerComponent*e.components,e.bufferView){const t=e.bufferView.buffer,{ArrayType:r,byteLength:s}=Aa(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):qa,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 Va[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 Ga=1735152710,Ha=1313821514,Wa=5130562,$a=!0;function Ka(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),a=n.getUint32(r+4,$a),c=n.getUint32(r+8,$a);switch(Object.assign(e,{header:{byteOffset:r,byteLength:c,hasBinChunk:!1},type:i,version:a,json:{},binChunks:[]}),r+=12,e.version){case 1:return function(e,t,r){o(e.header.byteLength>20);const s=t.getUint32(r+0,$a),n=t.getUint32(r+4,$a);return r+=8,o(0===n),Qa(e,t,r,s),r+=s,r+=Xa(e,t,r,e.header.byteLength)}(e,n,r);case 2:return function(e,t,r,s){return o(e.header.byteLength>20),function(e,t,r,s){for(;r+8<=e.header.byteLength;){const n=t.getUint32(r+0,$a),i=t.getUint32(r+4,$a);switch(r+=8,i){case Ha:Qa(e,t,r,n);break;case Wa:Xa(e,t,r,n);break;case 0:s.strict||Qa(e,t,r,n);break;case 1:s.strict||Xa(e,t,r,n)}r+=j(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 Qa(e,t,r,s){const n=new Uint8Array(t.buffer,r,s),i=new TextDecoder("utf8").decode(n);return e.json=JSON.parse(i),j(s,4)}function Xa(e,t,r,s){return e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:r,byteLength:s,arrayBuffer:t.buffer}),j(s,4)}async function Ya(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=Ga}=r,i=s.getUint32(t,!1);return i===n||i===Ga}(t,r,s)){t=(new TextDecoder).decode(t)}if("string"==typeof t)e.json=D(t);else if(t instanceof ArrayBuffer){const n={};r=Ka(n,t,r,s.glb),ya("glTF"===n.type,`Invalid GLB magic string ${n.type}`),e._glb=n,e.json=n.json}else ya(!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 ka).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;ya(a);const c=wa(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(Za(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 Pa){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=Pa[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 za).postProcess(e,t)}(e,s):e}async function Za(e,t,r,s,n){const{fetch:i,parse:o}=n;let a;if(t.uri){const e=wa(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];ya(s);const n=t[s.buffer];ya(n);const i=(s.byteOffset||0)+n.byteOffset;return new Uint8Array(n.arrayBuffer,i,s.byteLength)}(e.json,e.buffers,t.bufferView);a=B(r.buffer,r.byteOffset,r.byteLength)}ya(a,"glTF image has no data");const c=await o(a,ga,{},n);e.images[r]=c}const Ja={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={...Ja.options,...t}).gltf={...Ja.options.gltf,...t.gltf};const{byteOffset:s=0}=t;return await Ya({},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 ec=0,tc=1;function rc(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=B(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 sc(e,t,r,s){const n=r["3d-tiles"]||{};if(function(e,t,r){switch(t){case ec: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 tc: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,Ja,r,s),delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength)}}async function nc(e,t,r,s,n){var i;r=function(e,t,r,s,n){r=Po(e,t,r),r=Do(e,t,r),r=ko(e,t,r),r=rc(e,t,r,s);const i=new _o(e.featureTableJson,e.featureTableBinary);return e.rtcCenter=i.getGlobalProperty("RTC_CENTER",fo.FLOAT,3),r}(e,t,r,s),await sc(e,tc,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 ic(e,t,r,s,n){return r=function(e,t,r,s,n){if(r=Po(e,t,r),1!==e.version)throw new Error(`Instanced 3D Model version ${e.version} is not supported`);r=Do(e,t,r);const i=new DataView(t);if(e.gltfFormat=i.getUint32(r,!0),r=ko(e,t,r+=4),r=rc(e,t,r,s),0===e.featureTableJsonByteLength)throw new Error("i3dm parser: featureTableJsonByteLength is zero.");const o=new _o(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",fo.FLOAT,3);new No(e.batchTableJson,e.batchTableBinary,a);return function(e,t,r,s){const n=[new Array(s),e._batchTable][0],i=new Gt;new Gt,new Gt,new Gt;const o=new Zt,a=new kr,c=new Gt,u={},h=new br,l=[],d=[],f=new Gt,p=new Gt;for(let r=0;r<s;r++){let s;if(t.hasProperty("POSITION"))s=t.getProperty("POSITION",fo.FLOAT,3,r,i);else if(t.hasProperty("POSITION_QUANTIZED")){s=t.getProperty("POSITION_QUANTIZED",fo.UNSIGNED_SHORT,3,r,i);const e=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",fo.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",fo.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",fo.FLOAT,3,r,l),e.normalRight=t.getProperty("NORMAL_RIGHT",fo.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",fo.UNSIGNED_SHORT,2,l),e.octNormalRight=t.getProperty("NORMAL_RIGHT_OCT32P",fo.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?(Us.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",fo.FLOAT,1,r);Number.isFinite(m)&&c.multiplyByScalar(m);const g=t.getProperty("SCALE_NON_UNIFORM",fo.FLOAT,3,r,l);g&&c.scale(g),u.scale=c;let y=t.getProperty("BATCH_ID",fo.UNSIGNED_SHORT,1,r);void 0===y&&(y=r);const w=(new br).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 sc(e,e.gltfFormat,s,n),r}async function oc(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 Ai:return await async function(e,t,r,s,n,i){r=Po(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,oc);case Oi:return await nc(n,e,t,r,s);case Ii:return await ic(n,e,t,r,s);case Ri:return await Vo(n,e,t,r,s);default:throw new Error(`3DTileLoader: unknown type ${n.type}`)}}function ac(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=Gn,e.lodMetricValue=e.geometricError,e.transformMatrix=e.transform,e.type=function(e){if(!e.contentUrl)return Bn;const t=e.contentUrl.split(".").pop();switch(t){case"pnts":return Fn;case"i3dm":case"b3dm":return jn;default:return t}}(e),e.refine=function(e){switch(e){case"REPLACE":case"replace":return kn;case"ADD":case"add":return Dn;default:return e}}(e.refine),e}const cc={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||cc,s.url=r.url,s.basePath=function(e){return $(e.url)}(s),s.root=function(e){const t=e.basePath,r=ac(e.root,e),s=[];for(s.push(r);s.length>0;){const e=s.pop().children||[];for(const r of e)ac(r,{basePath:t}),s.push(r)}return r}(s),s.type=zn,s.lodMetricType=Gn,s.lodMetricValue=s.root.lodMetricValue,s}(e,t,r):await async function(e,t,r){const s={content:{featureIds:null}},n=0;return await oc(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 uc="https://api.cesium.com/v1/assets";async function hc(e,t){if(!t){const r=await async function(e){o(e);const t=uc,r={Authorization:`Bearer ${e}`},s=await ue(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){o(e,t);const r={Authorization:`Bearer ${e}`},s=`${uc}/${t}`;let n=await ue(`${s}`,{fetch:{headers:r}});if(!n.ok)throw new Error(n.statusText);let i=await n.json();if(n=await ue(`${s}/endpoint`,{fetch:{headers:r}}),!n.ok)throw new Error(n.statusText);const a=await n.json();return i={...i,...a},i}(e,t),{type:s,url:n}=r;return o("3DTILES"===s&&n),r.headers={Authorization:`Bearer ${r.accessToken}`},r}const lc={...cc,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 hc(r,s)},parse:async(e,t,r)=>((t={...t})["3d-tiles"]=t["cesium-ion"],t.loader=lc,cc.parse(e,t,r)),options:{"cesium-ion":{...cc.options["3d-tiles"],accessToken:null}}};function dc(e){const r=64,s=document.createElement("canvas");s.width=r,s.height=r;const n=s.getContext("2d");n.rect(0,0,r,r);const i=n.createLinearGradient(0,0,r,r);for(let t=0;t<e.length;t++){const r=e[t];i.addColorStop(r[0],"#"+r[1].getHexString())}n.fillStyle=i,n.fill();const o=new t.CanvasTexture(s);return o.needsUpdate=!0,o.minFilter=t.LinearFilter,o.wrapS=t.RepeatWrapping,o.wrapT=t.RepeatWrapping,o.repeat.set(2,2),o}function fc(e){e.updateMatrix(),e.updateMatrixWorld(),e.matrixWorldInverse.copy(e.matrixWorld).invert();const r=new t.Frustum;return r.setFromProjectionMatrix((new t.Matrix4).multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse)),r}function pc(e){const r=e.boundingVolume;let s=0;e.content&&(s=Math.min(e.content.byteLength/5e5,1));const n=new t.Color(s,1,0),i=new t.BoxGeometry(1,1,1),o=function(e){const r=e;return(new t.Matrix4).fromArray([2*r[0],2*r[1],2*r[2],0,2*r[3],2*r[4],2*r[5],0,2*r[6],2*r[7],2*r[8],0,0,0,0,1])}(r.halfAxes);i.applyMatrix4(o);const a=new t.EdgesGeometry(i),c=new t.LineSegments(a,new t.LineBasicMaterial({color:n}));return c.position.copy(new t.Vector3(...r.center)),c}class mc extends t.Loader{constructor(e){super(e),this.dracoLoader=null,this.ddsLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new vc(e)})),this.register((function(e){return new Ec(e)})),this.register((function(e){return new xc(e)})),this.register((function(e){return new _c(e)})),this.register((function(e){return new bc(e)})),this.register((function(e){return new Sc(e)}))}load(e,r,s,n){var i,o=this;i=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:t.LoaderUtils.extractUrlBase(e),this.manager.itemStart(e);var a=function(t){n?n(t):console.error(t),o.manager.itemError(e),o.manager.itemEnd(e)},c=new t.FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,(function(t){try{o.parse(t,i,(function(t){r(t),o.manager.itemEnd(e)}),a)}catch(e){a(e)}}),s,a)}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,r,s,n){var i,o={},a={};if("string"==typeof e)i=e;else if(t.LoaderUtils.decodeText(new Uint8Array(e,0,4))===Mc){try{o[yc.KHR_BINARY_GLTF]=new Oc(e)}catch(e){return void(n&&n(e))}i=o[yc.KHR_BINARY_GLTF].content}else i=t.LoaderUtils.decodeText(new Uint8Array(e));var c=e instanceof ArrayBuffer?JSON.parse(i):e;if(void 0===c.asset||c.asset.version[0]<2)n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));else{var u=new iu(c,{path:r||this.resourcePath||"",crossOrigin:this.crossOrigin,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});u.fileLoader.setRequestHeader(this.requestHeader);for(var h=0;h<this.pluginCallbacks.length;h++){var l=this.pluginCallbacks[h](u);a[l.name]=l,o[l.name]=!0}if(c.extensionsUsed)for(h=0;h<c.extensionsUsed.length;++h){var d=c.extensionsUsed[h],f=c.extensionsRequired||[];switch(d){case yc.KHR_MATERIALS_UNLIT:o[d]=new Tc;break;case yc.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:o[d]=new Nc;break;case yc.KHR_DRACO_MESH_COMPRESSION:o[d]=new Ic(c,this.dracoLoader);break;case yc.MSFT_TEXTURE_DDS:o[d]=new wc(this.ddsLoader);break;case yc.KHR_TEXTURE_TRANSFORM:o[d]=new Cc;break;case yc.KHR_MESH_QUANTIZATION:o[d]=new Pc;break;default:f.indexOf(d)>=0&&void 0===a[d]&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}u.setExtensions(o),u.setPlugins(a),u.parse(s,n)}}}function gc(){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 yc={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 wc(e){if(!e)throw new Error("THREE.GLTFLoader: Attempting to load .dds texture without importing DDSLoader");this.name=yc.MSFT_TEXTURE_DDS,this.ddsLoader=e}function bc(e){this.parser=e,this.name=yc.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}function Tc(){this.name=yc.KHR_MATERIALS_UNLIT}function vc(e){this.parser=e,this.name=yc.KHR_MATERIALS_CLEARCOAT}function _c(e){this.parser=e,this.name=yc.KHR_MATERIALS_TRANSMISSION}function Ec(e){this.parser=e,this.name=yc.KHR_TEXTURE_BASISU}function xc(e){this.parser=e,this.name=yc.EXT_TEXTURE_WEBP,this.isSupported=null}function Sc(e){this.name=yc.EXT_MESHOPT_COMPRESSION,this.parser=e}bc.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)}},bc.prototype._loadLight=function(e){var r=this.parser,s="light:"+e,n=r.cache.get(s);if(n)return n;var i,o=r.json,a=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e],c=new t.Color(16777215);void 0!==a.color&&c.fromArray(a.color);var u=void 0!==a.range?a.range:0;switch(a.type){case"directional":(i=new t.DirectionalLight(c)).target.position.set(0,0,-1),i.add(i.target);break;case"point":(i=new t.PointLight(c)).distance=u;break;case"spot":(i=new t.SpotLight(c)).distance=u,a.spot=a.spot||{},a.spot.innerConeAngle=void 0!==a.spot.innerConeAngle?a.spot.innerConeAngle:0,a.spot.outerConeAngle=void 0!==a.spot.outerConeAngle?a.spot.outerConeAngle:Math.PI/4,i.angle=a.spot.outerConeAngle,i.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,i.target.position.set(0,0,-1),i.add(i.target);break;default:throw new Error('THREE.GLTFLoader: Unexpected light type, "'+a.type+'".')}return i.position.set(0,0,0),i.decay=2,void 0!==a.intensity&&(i.intensity=a.intensity),i.name=r.createUniqueName(a.name||"light_"+e),n=Promise.resolve(i),r.cache.add(s,n),n},bc.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)}))},Tc.prototype.getMaterialType=function(){return t.MeshBasicMaterial},Tc.prototype.extendParams=function(e,r,s){var n=[];e.color=new t.Color(1,1,1),e.opacity=1;var i=r.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){var o=i.baseColorFactor;e.color.fromArray(o),e.opacity=o[3]}void 0!==i.baseColorTexture&&n.push(s.assignTexture(e,"map",i.baseColorTexture))}return Promise.all(n)},vc.prototype.getMaterialType=function(e){var r=this.parser.json.materials[e]||e;return r.extensions&&r.extensions[this.name]?t.MeshPhysicalMaterial:null},vc.prototype.extendMaterialParams=function(e,r){var s=this.parser,n=s.json.materials[e]||e;if(!n.extensions||!n.extensions[this.name])return Promise.resolve();var i=[],o=n.extensions[this.name];if(void 0!==o.clearcoatFactor&&(r.clearcoat=o.clearcoatFactor),void 0!==o.clearcoatTexture&&i.push(s.assignTexture(r,"clearcoatMap",o.clearcoatTexture)),void 0!==o.clearcoatRoughnessFactor&&(r.clearcoatRoughness=o.clearcoatRoughnessFactor),void 0!==o.clearcoatRoughnessTexture&&i.push(s.assignTexture(r,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),void 0!==o.clearcoatNormalTexture&&(i.push(s.assignTexture(r,"clearcoatNormalMap",o.clearcoatNormalTexture)),void 0!==o.clearcoatNormalTexture.scale)){var a=o.clearcoatNormalTexture.scale;r.clearcoatNormalScale=new t.Vector2(a,a)}return Promise.all(i)},_c.prototype.getMaterialType=function(e){var r=this.parser.json.materials[e]||e;return r.extensions&&r.extensions[this.name]?t.MeshPhysicalMaterial:null},_c.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)},Ec.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)},xc.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)}))},xc.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},Sc.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 Mc="glTF",Ac=1313821514,Rc=5130562;function Oc(e){this.name=yc.KHR_BINARY_GLTF,this.content=null,this.body=null;var r=new DataView(e,0,12);if(this.header={magic:t.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:r.getUint32(4,!0),length:r.getUint32(8,!0)},this.header.magic!==Mc)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 s=new DataView(e,12),n=0;n<s.byteLength;){var i=s.getUint32(n,!0);n+=4;var o=s.getUint32(n,!0);if(n+=4,o===Ac){var a=new Uint8Array(e,12+n,i);this.content=t.LoaderUtils.decodeText(a)}else if(o===Rc){var c=12+n;this.body=e.slice(c,c+i)}n+=i}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}function Ic(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=yc.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}function Cc(){this.name=yc.KHR_TEXTURE_TRANSFORM}function Lc(e){t.MeshStandardMaterial.call(this),this.isGLTFSpecularGlossinessMaterial=!0;var r=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),s=["#ifdef USE_GLOSSINESSMAP","\tuniform sampler2D glossinessMap;","#endif"].join("\n"),n=["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"),i=["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"),o=["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"),a={specular:{value:(new t.Color).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=a,this.onBeforeCompile=function(e){for(var t in a)e.uniforms[t]=a[t];e.fragmentShader=e.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",r).replace("#include <metalnessmap_pars_fragment>",s).replace("#include <roughnessmap_fragment>",n).replace("#include <metalnessmap_fragment>",i).replace("#include <lights_physical_fragment>",o)},Object.defineProperties(this,{specular:{get:function(){return a.specular.value},set:function(e){a.specular.value=e}},specularMap:{get:function(){return a.specularMap.value},set:function(e){a.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return a.glossiness.value},set:function(e){a.glossiness.value=e}},glossinessMap:{get:function(){return a.glossinessMap.value},set:function(e){a.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 Nc(){return{name:yc.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 Lc},extendParams:function(e,r,s){var n=r.extensions[this.name];e.color=new t.Color(1,1,1),e.opacity=1;var i=[];if(Array.isArray(n.diffuseFactor)){var o=n.diffuseFactor;e.color.fromArray(o),e.opacity=o[3]}if(void 0!==n.diffuseTexture&&i.push(s.assignTexture(e,"map",n.diffuseTexture)),e.emissive=new t.Color(0,0,0),e.glossiness=void 0!==n.glossinessFactor?n.glossinessFactor:1,e.specular=new t.Color(1,1,1),Array.isArray(n.specularFactor)&&e.specular.fromArray(n.specularFactor),void 0!==n.specularGlossinessTexture){var a=n.specularGlossinessTexture;i.push(s.assignTexture(e,"glossinessMap",a)),i.push(s.assignTexture(e,"specularMap",a))}return Promise.all(i)},createMaterial:function(e){var r=new Lc(e);return r.fog=!0,r.color=e.color,r.map=void 0===e.map?null:e.map,r.lightMap=null,r.lightMapIntensity=1,r.aoMap=void 0===e.aoMap?null:e.aoMap,r.aoMapIntensity=1,r.emissive=e.emissive,r.emissiveIntensity=1,r.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,r.bumpMap=void 0===e.bumpMap?null:e.bumpMap,r.bumpScale=1,r.normalMap=void 0===e.normalMap?null:e.normalMap,r.normalMapType=t.TangentSpaceNormalMap,e.normalScale&&(r.normalScale=e.normalScale),r.displacementMap=null,r.displacementScale=1,r.displacementBias=0,r.specularMap=void 0===e.specularMap?null:e.specularMap,r.specular=e.specular,r.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,r.glossiness=e.glossiness,r.alphaMap=null,r.envMap=void 0===e.envMap?null:e.envMap,r.envMapIntensity=1,r.refractionRatio=.98,r}}}function Pc(){this.name=yc.KHR_MESH_QUANTIZATION}function Uc(e,r,s,n){t.Interpolant.call(this,e,r,s,n)}Ic.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=$c[u]||u.toLowerCase();o[h]=i[u]}for(u in e.attributes){h=$c[u]||u.toLowerCase();if(void 0!==i[u]){var l=r.accessors[e.attributes[u]],d=zc[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)}))}))},Cc.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},Lc.prototype=Object.create(t.MeshStandardMaterial.prototype),Lc.prototype.constructor=Lc,Lc.prototype.copy=function(e){return t.MeshStandardMaterial.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},Uc.prototype=Object.create(t.Interpolant.prototype),Uc.prototype.constructor=Uc,Uc.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},Uc.prototype.beforeStart_=Uc.prototype.copySampleValue_,Uc.prototype.afterEnd_=Uc.prototype.copySampleValue_,Uc.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 Dc=0,kc=1,Bc=2,jc=3,Fc=4,Vc=5,qc=6,zc={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Gc={9728:t.NearestFilter,9729:t.LinearFilter,9984:t.NearestMipmapNearestFilter,9985:t.LinearMipmapNearestFilter,9986:t.NearestMipmapLinearFilter,9987:t.LinearMipmapLinearFilter},Hc={33071:t.ClampToEdgeWrapping,33648:t.MirroredRepeatWrapping,10497:t.RepeatWrapping},Wc={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},$c={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Kc={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Qc={CUBICSPLINE:void 0,LINEAR:t.InterpolateLinear,STEP:t.InterpolateDiscrete},Xc="OPAQUE",Yc="MASK",Zc="BLEND";function Jc(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 eu(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new t.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:t.FrontSide})),e.DefaultMaterial}function tu(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 ru(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 su(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 nu(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 iu(e,r){this.json=e||{},this.extensions={},this.plugins={},this.options=r||{},this.cache=new gc,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 t.ImageBitmapLoader(this.options.manager):this.textureLoader=new t.TextureLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.fileLoader=new t.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}function ou(e,r,s){var n=r.attributes,i=[];function o(t,r){return s.getDependency("accessor",t).then((function(t){e.setAttribute(r,t)}))}for(var a in n){var c=$c[a]||a.toLowerCase();c in e.attributes&&null!=e.attributes[c]||i.push(o(n[a],c))}if(void 0!==r.indices&&!e.index){var u=s.getDependency("accessor",r.indices).then((function(t){e.setIndex(t)}));i.push(u)}return ru(e,r),function(e,r,s){var n=r.attributes,i=new t.Box3;if(void 0!==n.POSITION){var o=(f=s.json.accessors[n.POSITION]||n.POSITION).min,a=f.max;if(void 0!==o&&void 0!==a){i.set(new t.Vector3(o[0],o[1],o[2]),new t.Vector3(a[0],a[1],a[2]));var c=r.targets;if(void 0!==c){for(var u=new t.Vector3,h=new t.Vector3,l=0,d=c.length;l<d;l++){var f,p=c[l];if(void 0!==p.POSITION)o=(f=s.json.accessors[p.POSITION]).min,a=f.max,void 0!==o&&void 0!==a?(h.setX(Math.max(Math.abs(o[0]),Math.abs(a[0]))),h.setY(Math.max(Math.abs(o[1]),Math.abs(a[1]))),h.setZ(Math.max(Math.abs(o[2]),Math.abs(a[2]))),u.max(h)):console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}i.expandByVector(u)}e.boundingBox=i;var m=new t.Sphere;i.getCenter(m.center),m.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=m}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}(e,r,s),Promise.all(i).then((function(){return void 0!==r.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,r.targets,s):e}))}function au(e,r){var s=e.getIndex();if(null===s){var n=[],i=e.getAttribute("position");if(void 0===i)return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(var o=0;o<i.count;o++)n.push(o);e.setIndex(n),s=e.getIndex()}var a=s.count-2,c=[];if(r===t.TriangleFanDrawMode)for(o=1;o<=a;o++)c.push(s.getX(0)),c.push(s.getX(o)),c.push(s.getX(o+1));else for(o=0;o<a;o++)o%2==0?(c.push(s.getX(o)),c.push(s.getX(o+1)),c.push(s.getX(o+2))):(c.push(s.getX(o+2)),c.push(s.getX(o+1)),c.push(s.getX(o)));c.length/3!==a&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");var u=e.clone();return u.setIndex(c),u}iu.prototype.setExtensions=function(e){this.extensions=e},iu.prototype.setPlugins=function(e){this.plugins=e},iu.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:{}};tu(n,i,s),ru(i,s),e(i)})).catch(t)},iu.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)}},iu.prototype._addNodeRef=function(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)},iu.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},iu.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}},iu.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},iu.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},iu.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},iu.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[yc.KHR_BINARY_GLTF])return Promise.resolve(this.extensions[yc.KHR_BINARY_GLTF].body);var s=this.options;return new Promise((function(e,n){r.load(Jc(t.uri,s.path),e,void 0,(function(){n(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))},iu.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)}))},iu.prototype.loadAccessor=function(e){var r=this,s=this.json,n=this.json.accessors[e]||e;if((void 0===n.bufferView||null===n.bufferView)&&void 0===n.sparse&&!n.value)return Promise.resolve(null);var i=[];return void 0===n.bufferView||n.value?i.push(null):i.push(this.getDependency("bufferView",n.bufferView)),void 0!==n.sparse&&(i.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(i).then((function(e){var i,o,a=e[0],c=Wc[n.type],u=zc[n.componentType],h=u.BYTES_PER_ELEMENT,l=h*c,d=n.byteOffset||0,f=void 0===n.bufferView||n.value?void 0:s.bufferViews[n.bufferView].byteStride,p=!0===n.normalized;if(f&&f!==l){var m=Math.floor(d/f),g="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+m+":"+n.count,y=r.cache.get(g);y||(i=new u(a,m*f,n.count*f/h),y=new t.InterleavedBuffer(i,f/h),r.cache.add(g,y)),o=new t.InterleavedBufferAttribute(y,c,d%f/h,p)}else i=n.value?n.value:null===a?new u(n.count*c):new u(a,d,n.count*c),o=new t.BufferAttribute(i,c,p);if(void 0!==n.sparse){var w=Wc.SCALAR,b=zc[n.sparse.indices.componentType],T=n.sparse.indices.byteOffset||0,v=n.sparse.values.byteOffset||0,_=new b(e[1],T,n.sparse.count*w),E=new u(e[2],v,n.sparse.count*c);null!==a&&(o=new t.BufferAttribute(o.array.slice(),o.itemSize,o.normalized));for(var x=0,S=_.length;x<S;x++){var M=_[x];if(o.setX(M,E[x*c]),c>=2&&o.setY(M,E[x*c+1]),c>=3&&o.setZ(M,E[x*c+2]),c>=4&&o.setW(M,E[x*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return o}))},iu.prototype.loadTexture=function(e){var t,r,s=this.json,n=this.options,i=s.textures[e]||e,o=i.extensions||{};return(t=o[yc.MSFT_TEXTURE_DDS]?s.images[o[yc.MSFT_TEXTURE_DDS].source]:s.images[i.source]||i.source).uri&&(r=n.manager.getHandler(t.uri)),r||(r=o[yc.MSFT_TEXTURE_DDS]?this.extensions[yc.MSFT_TEXTURE_DDS].ddsLoader:this.textureLoader),this.loadTextureImage(e,t,r)},iu.prototype.loadTextureImage=function(e,r,s){var n,i=this,o=this.json,a=this.options,c=o.textures[e]||e,u=self.URL||self.webkitURL,h=r.uri,l=!1,d=!0;return"image/jpeg"===r.mimeType&&(d=!1),void 0!==r.bufferView&&(h=i.getDependency("bufferView",r.bufferView).then((function(e){if("image/png"===r.mimeType){var t=new DataView(e,25,1).getUint8(0,!1);d=6===t||4===t||3===t}return new Blob([e],{type:r.mimeType})}))),n=s.isImageBitmapLoader?Promise.resolve(h).then((function(e){return createImageBitmap(e,{premultiplyAlpha:"none"})})).then((function(e){return new t.CanvasTexture(e)})):Promise.resolve(h).then((function(e){return l=!0,h=u.createObjectURL(e)})).then((function(e){return new Promise((function(t,r){var n=t;s.load(Jc(e,a.path),n,void 0,r)}))})),Promise.resolve(n).then((function(r){!0===l&&u.revokeObjectURL(h),r.flipY=!1,c.name&&(r.name=c.name),d||(r.format=t.RGBFormat);var s=(o.samplers||{})[c.sampler]||{};return r.magFilter=Gc[s.magFilter]||t.LinearFilter,r.minFilter=Gc[s.minFilter]||t.LinearMipmapLinearFilter,r.wrapS=Hc[s.wrapS]||t.RepeatWrapping,r.wrapT=Hc[s.wrapT]||t.RepeatWrapping,i.associations.set(r,{type:"textures",index:e}),r}))},iu.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[yc.KHR_TEXTURE_TRANSFORM]){var i=void 0!==r.extensions?r.extensions[yc.KHR_TEXTURE_TRANSFORM]:void 0;if(i){var o=s.associations.get(n);n=s.extensions[yc.KHR_TEXTURE_TRANSFORM].extendTexture(n,i),s.associations.set(n,o)}}e[t]=n}))},iu.prototype.assignFinalMaterial=function(e){var r=e.geometry,s=e.material,n=void 0!==r.attributes.tangent,i=void 0!==r.attributes.color,o=void 0===r.attributes.normal,a=!0===e.isSkinnedMesh,c=Object.keys(r.morphAttributes).length>0,u=c&&void 0!==r.morphAttributes.normal;if(e.isPoints){var h="PointsMaterial:"+s.uuid,l=this.cache.get(h);l||(l=new t.PointsMaterial,t.Material.prototype.copy.call(l,s),l.color.copy(s.color),l.map=s.map,l.sizeAttenuation=!1,this.cache.add(h,l)),s=l}else if(e.isLine){h="LineBasicMaterial:"+s.uuid;var d=this.cache.get(h);d||(d=new t.LineBasicMaterial,t.Material.prototype.copy.call(d,s),d.color.copy(s.color),this.cache.add(h,d)),s=d}if(n||i||o||a||c){h="ClonedMaterial:"+s.uuid+":";s.isGLTFSpecularGlossinessMaterial&&(h+="specular-glossiness:"),a&&(h+="skinning:"),n&&(h+="vertex-tangents:"),i&&(h+="vertex-colors:"),o&&(h+="flat-shading:"),c&&(h+="morph-targets:"),u&&(h+="morph-normals:");var f=this.cache.get(h);f||(f=s.clone(),a&&(f.skinning=!0),n&&(f.vertexTangents=!0),i&&(f.vertexColors=!0),o&&(f.flatShading=!0),c&&(f.morphTargets=!0),u&&(f.morphNormals=!0),this.cache.add(h,f),this.associations.set(f,this.associations.get(s))),s=f}s.aoMap&&void 0===r.attributes.uv2&&void 0!==r.attributes.uv&&r.setAttribute("uv2",r.attributes.uv),s.normalScale&&!n&&(s.normalScale.y=-s.normalScale.y),s.clearcoatNormalScale&&!n&&(s.clearcoatNormalScale.y=-s.clearcoatNormalScale.y),e.material=s},iu.prototype.getMaterialType=function(){return t.MeshStandardMaterial},iu.prototype.loadMaterial=function(e){var r,s=this,n=this.json,i=this.extensions,o=n.materials[e]||e,a={},c=o.extensions||{},u=[];if(c[yc.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){var h=i[yc.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];r=h.getMaterialType(),u.push(h.extendParams(a,o,s))}else if(c[yc.KHR_MATERIALS_UNLIT]){var l=i[yc.KHR_MATERIALS_UNLIT];r=l.getMaterialType(),u.push(l.extendParams(a,o,s))}else{var d=o.pbrMetallicRoughness||{};if(a.color=new t.Color(1,1,1),a.opacity=1,Array.isArray(d.baseColorFactor)){var f=d.baseColorFactor;a.color.fromArray(f),a.opacity=f[3]}void 0!==d.baseColorTexture&&u.push(s.assignTexture(a,"map",d.baseColorTexture)),a.metalness=void 0!==d.metallicFactor?d.metallicFactor:1,a.roughness=void 0!==d.roughnessFactor?d.roughnessFactor:1,void 0!==d.metallicRoughnessTexture&&(u.push(s.assignTexture(a,"metalnessMap",d.metallicRoughnessTexture)),u.push(s.assignTexture(a,"roughnessMap",d.metallicRoughnessTexture))),r=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),u.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)}))))}!0===o.doubleSided&&(a.side=t.DoubleSide);var p=o.alphaMode||Xc;return p===Zc?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,p===Yc&&(a.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&r!==t.MeshBasicMaterial&&(u.push(s.assignTexture(a,"normalMap",o.normalTexture)),a.normalScale=new t.Vector2(1,1),void 0!==o.normalTexture.scale&&a.normalScale.set(o.normalTexture.scale,o.normalTexture.scale)),void 0!==o.occlusionTexture&&r!==t.MeshBasicMaterial&&(u.push(s.assignTexture(a,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(a.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&r!==t.MeshBasicMaterial&&(a.emissive=(new t.Color).fromArray(o.emissiveFactor)),void 0!==o.emissiveTexture&&r!==t.MeshBasicMaterial&&u.push(s.assignTexture(a,"emissiveMap",o.emissiveTexture)),Promise.all(u).then((function(){var n;return n=r===Lc?i[yc.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(a):new r(a),o.name&&(n.name=o.name),n.map&&(n.map.encoding=t.sRGBEncoding),n.emissiveMap&&(n.emissiveMap.encoding=t.sRGBEncoding),ru(n,o),s.associations.set(n,{type:"materials",index:e}),o.extensions&&tu(i,n,o),n}))},iu.prototype.createUniqueName=function(e){for(var r=t.PropertyBinding.sanitizeNodeName(e||""),s=1;this.nodeNamesUsed[r];++s)r=e+"_"+s;return this.nodeNamesUsed[r]=!0,r},iu.prototype.loadGeometries=function(e){var r=this,s=this.extensions,n=this.primitiveCache;function i(e){return s[yc.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,r).then((function(t){return ou(t,e,r)}))}for(var o,a,c=[],u=0,h=e.length;u<h;u++){var l,d=e[u],f=null,p=null;if("number"==typeof d.indices&&(a=void 0,p=n[f=(a=(o=d).extensions&&o.extensions[yc.KHR_DRACO_MESH_COMPRESSION])?"draco:"+a.bufferView+":"+a.indices+":"+nu(a.attributes):o.indices+":"+nu(o.attributes)+":"+o.mode]),p)c.push(p.promise);else l=d.extensions&&d.extensions[yc.KHR_DRACO_MESH_COMPRESSION]&&"number"==typeof d.indices?i(d):ou(new t.BufferGeometry,d,r),f&&(n[f]={primitive:d,promise:l}),c.push(l)}return Promise.all(c)},iu.prototype.loadMesh=function(e){for(var r=this,s=this.json.meshes[e]||e,n=s.primitives,i=[],o=0,a=n.length;o<a;o++){var c=void 0===n[o].material?eu(this.cache):this.getDependency("material",n[o].material);i.push(c)}return i.push(r.loadGeometries(n)),Promise.all(i).then((function(i){for(var o=i.slice(0,i.length-1),a=i[i.length-1],c=[],u=0,h=a.length;u<h;u++){var l,d=a[u],f=n[u],p=o[u];if(f.mode===Fc||f.mode===Vc||f.mode===qc||void 0===f.mode)!0!==(l=!0===s.isSkinnedMesh?new t.SkinnedMesh(d,p):new t.Mesh(d,p)).isSkinnedMesh||l.geometry.attributes.skinWeight.normalized||l.normalizeSkinWeights(),f.mode===Vc?l.geometry=au(l.geometry,t.TriangleStripDrawMode):f.mode===qc&&(l.geometry=au(l.geometry,t.TriangleFanDrawMode));else if(f.mode===kc)l=new t.LineSegments(d,p);else if(f.mode===jc)l=new t.Line(d,p);else if(f.mode===Bc)l=new t.LineLoop(d,p);else{if(f.mode!==Dc)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+f.mode);l=new t.Points(d,p)}Object.keys(l.geometry.morphAttributes).length>0&&su(l,s),l.name=r.createUniqueName(s.name||"mesh_"+e),ru(l,s),r.assignFinalMaterial(l),c.push(l)}if(1===c.length)return c[0];var m=new t.Group;for(u=0,h=c.length;u<h;u++)m.add(c[u]);return m}))},iu.prototype.loadCamera=function(e){var r,s=this.json.cameras[e],n=s[s.type];if(n)return"perspective"===s.type?r=new t.PerspectiveCamera(t.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):"orthographic"===s.type&&(r=new t.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(r.name=this.createUniqueName(s.name)),ru(r,s),Promise.resolve(r);console.warn("THREE.GLTFLoader: Missing camera parameters.")},iu.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}))},iu.prototype.loadAnimation=function(e){for(var r=this.json.animations[e],s=[],n=[],i=[],o=[],a=[],c=0,u=r.channels.length;c<u;c++){var h=r.channels[c],l=r.samplers[h.sampler],d=h.target,f=void 0!==d.node?d.node:d.id,p=void 0!==r.parameters?r.parameters[l.input]:l.input,m=void 0!==r.parameters?r.parameters[l.output]:l.output;s.push(this.getDependency("node",f)),n.push(this.getDependency("accessor",p)),i.push(this.getDependency("accessor",m)),o.push(l),a.push(d)}return Promise.all([Promise.all(s),Promise.all(n),Promise.all(i),Promise.all(o),Promise.all(a)]).then((function(s){for(var n=s[0],i=s[1],o=s[2],a=s[3],c=s[4],u=[],h=0,l=n.length;h<l;h++){var d=n[h],f=i[h],p=o[h],m=a[h],g=c[h];if(void 0!==d){var y;switch(d.updateMatrix(),d.matrixAutoUpdate=!0,Kc[g.path]){case Kc.weights:y=t.NumberKeyframeTrack;break;case Kc.rotation:y=t.QuaternionKeyframeTrack;break;case Kc.position:case Kc.scale:default:y=t.VectorKeyframeTrack}var w=d.name?d.name:d.uuid,b=void 0!==m.interpolation?Qc[m.interpolation]:t.InterpolateLinear,T=[];Kc[g.path]===Kc.weights?d.traverse((function(e){!0===e.isMesh&&e.morphTargetInfluences&&T.push(e.name?e.name:e.uuid)})):T.push(w);var v=p.array;if(p.normalized){var _;if(v.constructor===Int8Array)_=1/127;else if(v.constructor===Uint8Array)_=1/255;else if(v.constructor==Int16Array)_=1/32767;else{if(v.constructor!==Uint16Array)throw new Error("THREE.GLTFLoader: Unsupported output accessor component type.");_=1/65535}for(var E=new Float32Array(v.length),x=0,S=v.length;x<S;x++)E[x]=v[x]*_;v=E}for(x=0,S=T.length;x<S;x++){var M=new y(T[x]+"."+Kc[g.path],f.array,v,b);"CUBICSPLINE"===m.interpolation&&(M.createInterpolant=function(e){return new Uc(this.times,this.values,this.getValueSize()/3,e)},M.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),u.push(M)}}}var A=r.name?r.name:"animation_"+e;return new t.AnimationClip(A,void 0,u)}))},iu.prototype.loadNode=function(e){var r,s=this.json,n=this.extensions,i=this,o=s.nodes[e]||e,a=o.name?i.createUniqueName(o.name):"";return(r=[],void 0!==o.mesh&&r.push(i.getDependency("mesh",o.mesh).then((function(e){var t=i._getNodeRef(i.meshCache,o.mesh,e);return void 0!==o.weights&&t.traverse((function(e){if(e.isMesh)for(var t=0,r=o.weights.length;t<r;t++)e.morphTargetInfluences[t]=o.weights[t]})),t}))),void 0!==o.camera&&r.push(i.getDependency("camera",o.camera).then((function(e){return i._getNodeRef(i.cameraCache,o.camera,e)}))),i._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){r.push(e)})),Promise.all(r)).then((function(r){var s;if((s=!0===o.isBone?new t.Bone:r.length>1?new t.Group:1===r.length?r[0]:new t.Object3D)!==r[0])for(var c=0,u=r.length;c<u;c++)s.add(r[c]);if(o.name&&(s.userData.name=o.name,s.name=a),ru(s,o),o.extensions&&tu(n,s,o),void 0!==o.matrix){var h=new t.Matrix4;h.fromArray(o.matrix),s.applyMatrix4(h)}else void 0!==o.translation&&s.position.fromArray(o.translation),void 0!==o.rotation&&s.quaternion.fromArray(o.rotation),void 0!==o.scale&&s.scale.fromArray(o.scale);return i.associations.set(s,{type:"nodes",index:e}),s}))},iu.prototype.loadScene=function(){function e(r,s,n,i){var o=n.nodes[r]||r;return i.getDependency("node",r).then((function(e){return void 0===o.skin?e:i.getDependency("skin",o.skin).then((function(e){for(var t=[],s=0,n=(r=e).joints.length;s<n;s++)t.push(i.getDependency("node",r.joints[s]));return Promise.all(t)})).then((function(s){return e.traverse((function(e){if(e.isMesh){for(var n=[],i=[],o=0,a=s.length;o<a;o++){var c=s[o];if(c){n.push(c);var u=new t.Matrix4;void 0!==r.inverseBindMatrices&&u.fromArray(r.inverseBindMatrices.array,16*o),i.push(u)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',r.joints[o])}e.bind(new t.Skeleton(n,i),e.matrixWorld)}})),e}));var r})).then((function(t){s.add(t);var r=[];if(o.children)for(var a=o.children,c=0,u=a.length;c<u;c++){var h=a[c];r.push(e(h,t,n,i))}return Promise.all(r)}))}return function(r){var s=this.json,n=this.extensions,i=this.json.scenes[r],o=new t.Group;i.name&&(o.name=this.createUniqueName(i.name)),ru(o,i),i.extensions&&tu(n,o,i);for(var a=i.nodes||[],c=[],u=0,h=a.length;u<h;u++)c.push(e(a[u],o,s,this));return Promise.all(c).then((function(){return o}))}}();const cu={SPECTRAL:[[0,new t.Color(.3686,.3098,.6353)],[.1,new t.Color(.1961,.5333,.7412)],[.2,new t.Color(.4,.7608,.6471)],[.3,new t.Color(.6706,.8667,.6431)],[.4,new t.Color(.902,.9608,.5961)],[.5,new t.Color(1,1,.749)],[.6,new t.Color(.9961,.8784,.5451)],[.7,new t.Color(.9922,.6824,.3804)],[.8,new t.Color(.9569,.4275,.2627)],[.9,new t.Color(.8353,.2431,.3098)],[1,new t.Color(.6196,.0039,.2588)]],PLASMA:[[0,new t.Color(.241,.015,.61)],[.1,new t.Color(.387,.001,.654)],[.2,new t.Color(.524,.025,.653)],[.3,new t.Color(.651,.125,.596)],[.4,new t.Color(.752,.227,.513)],[.5,new t.Color(.837,.329,.431)],[.6,new t.Color(.907,.435,.353)],[.7,new t.Color(.963,.554,.272)],[.8,new t.Color(.992,.681,.195)],[.9,new t.Color(.987,.822,.144)],[1,new t.Color(.94,.975,.131)]],YELLOW_GREEN:[[0,new t.Color(.1647,.2824,.3451)],[.1,new t.Color(.1338,.3555,.4227)],[.2,new t.Color(.061,.4319,.4864)],[.3,new t.Color(0,.5099,.5319)],[.4,new t.Color(0,.5881,.5569)],[.5,new t.Color(.137,.665,.5614)],[.6,new t.Color(.2906,.7395,.5477)],[.7,new t.Color(.4453,.8099,.5201)],[.8,new t.Color(.6102,.8748,.485)],[.9,new t.Color(.7883,.9323,.4514)],[1,new t.Color(.9804,.9804,.4314)]],VIRIDIS:[[0,new t.Color(.267,.005,.329)],[.1,new t.Color(.283,.141,.458)],[.2,new t.Color(.254,.265,.53)],[.3,new t.Color(.207,.372,.553)],[.4,new t.Color(.164,.471,.558)],[.5,new t.Color(.128,.567,.551)],[.6,new t.Color(.135,.659,.518)],[.7,new t.Color(.267,.749,.441)],[.8,new t.Color(.478,.821,.318)],[.9,new t.Color(.741,.873,.15)],[1,new t.Color(.993,.906,.144)]],INFERNO:[[0,new t.Color(.077,.042,.206)],[.1,new t.Color(.225,.036,.388)],[.2,new t.Color(.373,.074,.432)],[.3,new t.Color(.522,.128,.42)],[.4,new t.Color(.665,.182,.37)],[.5,new t.Color(.797,.255,.287)],[.6,new t.Color(.902,.364,.184)],[.7,new t.Color(.969,.516,.063)],[.8,new t.Color(.988,.683,.072)],[.9,new t.Color(.961,.859,.298)],[1,new t.Color(.988,.998,.645)]],GRAYSCALE:[[0,new t.Color(0,0,0)],[1,new t.Color(1,1,1)]],TURBO:[[0,new t.Color(.18995,.07176,.23217)],[.07,new t.Color(.25107,.25237,.63374)],[.13,new t.Color(.27628,.42118,.89123)],[.2,new t.Color(.25862,.57958,.99876)],[.27,new t.Color(.15844,.73551,.92305)],[.33,new t.Color(.09267,.86554,.7623)],[.4,new t.Color(.19659,.94901,.59466)],[.47,new t.Color(.42778,.99419,.38575)],[.53,new t.Color(.64362,.98999,.23356)],[.6,new t.Color(.80473,.92452,.20459)],[.67,new t.Color(.93301,.81236,.22667)],[.73,new t.Color(.99314,.67408,.20348)],[.8,new t.Color(.9836,.49291,.12849)],[.87,new t.Color(.92105,.31489,.05475)],[.93,new t.Color(.81608,.18462,.01809)],[1,new t.Color(.66449,.08436,.00424)]],RAINBOW:[[0,new t.Color(.278,0,.714)],[1/6,new t.Color(0,0,1)],[2/6,new t.Color(0,1,1)],[.5,new t.Color(0,1,0)],[4/6,new t.Color(1,1,0)],[5/6,new t.Color(1,.64,0)],[1,new t.Color(1,0,0)]],CONTOUR:[[0,new t.Color(0,0,0)],[.03,new t.Color(0,0,0)],[.04,new t.Color(1,1,1)],[1,new t.Color(1,1,1)]]},uu="\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",hu="\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 lu,du;e.PointCloudColoring=void 0,(lu=e.PointCloudColoring||(e.PointCloudColoring={}))[lu.Intensity=1]="Intensity",lu[lu.Classification=2]="Classification",lu[lu.Elevation=3]="Elevation",lu[lu.RGB=4]="RGB",lu[lu.White=5]="White",e.Shading=void 0,(du=e.Shading||(e.Shading={}))[du.FlatTexture=1]="FlatTexture",du[du.ShadedTexture=2]="ShadedTexture",du[du.ShadedNoTexture=3]="ShadedNoTexture";const fu="undefined"!=typeof document?dc(cu.RAINBOW):null,pu="undefined"!=typeof document?dc(cu.GRAYSCALE):null,mu={initialTransform:new t.Matrix4,throttleRequests:!0,maxRequests:64,updateInterval:.1,maxConcurrency:1,maximumScreenSpaceError:16,maximumMemoryUsage:32,viewDistanceScale:1,skipLevelOfDetail:!1,updateTransforms:!1,shading:e.Shading.FlatTexture,pointCloudColoring:e.PointCloudColoring.White,worker:!0,wireframe:!1,debug:!1,basisTranscoderPath:null,dracoDecoderPath:null,material:null,computeNormals:!1,shaderCallback:null,loadersGlGltf:!0};function gu(e){e.traverse((e=>{if(e.isMesh)if(e.geometry.dispose(),e.material.isMaterial)e.material.dispose();else for(const t of e.material)t.dispose()}));for(let t=e.children.length-1;t>=0;t--){const r=e.children[t];e.remove(r)}}e.Loader3DTiles=class{static load(o){return i(this,void 0,void 0,(function*(){const a=Object.assign(Object.assign({},mu),o.options),{url:c}=o,u=a.updateInterval,h={};if(a.cesiumIONToken){h["cesium-ion"]={accessToken:a.cesiumIONToken};const e=yield lc.preload(c,h);h.fetch={headers:e.headers}}const l=yield nt(c,cc,Object.assign({},h)),d={},f={},p=[],m=new t.Group,g=new t.Group;a.debug||(g.visible=!1);let y=new t.Matrix4;const w=l.root.transform?(new t.Matrix4).fromArray(l.root.transform):new t.Matrix4;if(1==l.root.children.length&&l.root.children[0].transform){const e=(new t.Matrix4).fromArray(l.root.children[0].transform);w.multiply(e)}y.copy(w).invert();const b=y.clone();y.premultiply(a.initialTransform);let T=new br(y.toArray());const v={pointSize:{type:"f",value:1},gradient:{type:"t",value:fu},grayscale:{type:"t",value:pu},rootCenter:{type:"vec3",value:new t.Vector3},rootNormal:{type:"vec3",value:new t.Vector3},coloring:{type:"i",value:a.pointCloudColoring},hideGround:{type:"b",value:!0},elevationRange:{type:"vec2",value:new t.Vector2(0,400)},maxIntensity:{type:"f",value:1},intensityContrast:{type:"f",value:1}};let _=null,E=null;const x=a.loadersGlGltf?new mc:new r.GLTFLoader;if(a.basisTranscoderPath){const e=new n.KTX2Loader;e.detectSupport(o.renderer),e.setTranscoderPath(a.basisTranscoderPath+"/"),x.setKTX2Loader(e)}if(!a.loadersGlGltf&&a.dracoDecoderPath){const e=new s.DRACOLoader;e.setDecoderPath(a.dracoDecoderPath+"/"),e.setWorkerLimit(a.maxConcurrency),x.setDRACOLoader(e)}const S=new t.ShaderMaterial({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"}),M={modelMatrix:T,maximumMemoryUsage:a.maximumMemoryUsage,maximumScreenSpaceError:a.maximumScreenSpaceError,viewDistanceScale:a.viewDistanceScale,skipLevelOfDetail:a.skipLevelOfDetail,updateTransforms:a.updateTransforms,throttleRequests:a.throttleRequests,maxRequests:a.maxRequests,contentLoader:r=>i(this,void 0,void 0,(function*(){let s=null;switch(r.type){case Fn:s=function(e,r){const s={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:n}=e.content.attributes;n&&3===n.size&&(s.rgb=n.value);n&&4===n.size&&(s.rgba=n.value);const i=new t.BufferGeometry;i.setAttribute("position",new t.Float32BufferAttribute(s.points,3));const o=new t.ShaderMaterial({uniforms:r,vertexShader:hu,fragmentShader:uu,transparent:!0});s.rgba?(i.setAttribute("color",new t.Float32BufferAttribute(s.rgba,4)),o.vertexColors=!0):s.rgb&&(i.setAttribute("color",new t.Uint8BufferAttribute(s.rgb,3,!0)),o.vertexColors=!0);s.intensities&&i.setAttribute("intensity",new t.Uint8BufferAttribute(s.intensities,1,!0));s.classifications&&i.setAttribute("classification",new t.Uint8BufferAttribute(s.classifications,1,!1));const a=new t.Points(i,o);if(s.rtc_center){const e=s.rtc_center;a.applyMatrix4((new t.Matrix4).makeTranslation(e[0],e[1],e[2]))}return a}(r,v);break;case jn:case Vn:s=yield function(r,s,n,o){return i(this,void 0,void 0,(function*(){return new Promise(((i,a)=>{const c=(new t.Matrix4).makeRotationAxis(new t.Vector3(1,0,0),Math.PI/2);r.parse(o.loadersGlGltf?s.content.gltf:s.content.gltfArrayBuffer,"",(r=>{const s=r.scenes[0].children[0];s.applyMatrix4(c),s.traverse((r=>{if(r instanceof t.Mesh){const t=r.material.map;o.material?r.material=o.material.clone():o.shading==e.Shading.FlatTexture&&(r.material=n.clone()),o.shading!=e.Shading.ShadedNoTexture?r.material.uniforms?r.material.uniforms.map={value:t}:r.material.map=t:r.material.map=null,o.shaderCallback&&(r.onBeforeRender=o.shaderCallback),r.material.wireframe=o.wireframe,o.computeNormals&&r.geometry.computeVertexNormals()}})),i(s)}),(e=>{a(new Error(`error parsing gltf in tile ${s.id}: ${e}`))}))}))}))}(x,r,S,a)}if(s&&(s.visible=!1,d[r.id]=s,m.add(d[r.id]),a.debug)){const e=pc(r);g.add(e),f[r.id]=e}})),onTileLoad:()=>i(this,void 0,void 0,(function*(){A&&(A._frameNumber++,U(A,d,E,_))})),onTileUnload:e=>{p.push(e)},onTileError:(e,t)=>{console.error("Tile error",e.id,t)}},A=new Mi(l,Object.assign(Object.assign({},M),{loadOptions:Object.assign(Object.assign({},h),{maxConcurrency:a.maxConcurrency,worker:a.worker,gltf:{loadImages:!1},"3d-tiles":{loadGLTF:a.loadersGlGltf}})}));let R=!1;const O=(new t.Vector3).setFromMatrixPosition(a.initialTransform);v.rootCenter.value.copy(O),v.rootNormal.value.copy(new t.Vector3(0,0,1).applyMatrix4(a.initialTransform).normalize()),m.applyMatrix4(a.initialTransform),A.stats.get("Loader concurrency").count=a.maxConcurrency,A.stats.get("Maximum SSE").count=a.maximumScreenSpaceError,A.stats.get("Maximum mem usage").count=a.maximumMemoryUsage;let I=0;const C=(new t.Matrix4).makeTranslation(1/0,1/0,1/0);let L=null;const N=new t.Vector3(1/0,1/0,1/0);let P=null;function U(e,r,s,n){if(R)return;if(!P||n.aspect!=L){const e=new _n({fov:n.fov/180*Math.PI,aspectRatio:n.aspect,near:n.near,far:n.far});P=e.sseDenominator,L=n.aspect,a.debug&&console.log("Updated sse denonimator:",P)}const i=fc(n).planes.map((e=>new hn(e.normal.toArray(),e.constant))),c=new pn(i),u=new t.Vector2;s.getSize(u);const h={camera:{position:N.toArray()},height:u.y,frameNumber:e._frameNumber,sseDenominator:P,cullingVolume:c,viewport:{id:0}};e._cache.reset(),e._traverser.traverse(e.root,h,e.options);for(const t of e.tiles)t.selected?r[t.id]?r[t.id].visible=!0:console.error("TILE SELECTED BUT NOT LOADED!!",t.id):r[t.id]&&(r[t.id].visible=!1);for(;p.length>0;){const e=p.pop();r[e.id]&&e.contentState==Cn&&(m.remove(r[e.id]),gu(r[e.id]),delete r[e.id]),f[e.id]&&(gu(f[e.id]),g.remove(f[e.id]),delete f[e.id])}return o.onProgress&&o.onProgress(e.stats.get("Tiles Loaded").count,e.stats.get("Tiles Loaded").count+e.stats.get("Tiles Loading").count),h}return{model:m,runtime:{getTileset:()=>A,getStats:()=>A.stats,showTiles:e=>{g.visible=e},setWireframe:e=>{a.wireframe=e,m.traverse((r=>{r instanceof t.Mesh&&(r.material.wireframe=e)}))},setDebug:e=>{a.debug=e,g.visible=e},setShading:e=>{a.shading=e},getTileBoxes:()=>g,setViewDistanceScale:e=>{A.options.viewDistanceScale=e,A._frameNumber++,U(A,d,E,_)},setHideGround:e=>{v.hideGround.value=e},setPointCloudColoring:e=>{v.coloring.value=e},setElevationRange:e=>{v.elevationRange.value.set(e[0],e[1])},setMaxIntensity:e=>{v.maxIntensity.value=e},setIntensityContrast:e=>{v.intensityContrast.value=e},getLatLongHeightFromPosition:e=>{const r=A.ellipsoid.cartesianToCartographic((new t.Vector3).copy(e).applyMatrix4((new t.Matrix4).copy(y).invert()).toArray());return{lat:r[1],long:r[0],height:r[2]}},getPositionFromLatLongHeight:e=>{const r=A.ellipsoid.cartographicToCartesian([e.long,e.lat,e.height]);return new t.Vector3(...r).applyMatrix4(y)},getCameraFrustum:e=>{const r=fc(e).planes.map((e=>new hn(e.normal.toArray(),e.constant))).map((e=>function(e){const r=new t.Group,s=new t.PlaneGeometry(10,5),n=new t.Vector3(...e.projectPointOntoPlane([0,0,0])),i=new t.Vector3(e.normal.x,e.normal.y,e.normal.z),o=(new t.Vector3).copy(n).add(i);s.lookAt(o),s.translate(n.x,n.y,n.z);const a=new t.MeshBasicMaterial({color:65535,side:t.DoubleSide}),c=new t.Mesh(s,a),u=new t.ArrowHelper(i,n,5,16776960);return r.add(u),r.add(c),r}(e))),s=new t.Group;for(const e of r)s.add(e);return s},getTransform:()=>a.initialTransform,setTransform:e=>{a.initialTransform=e,y=b.clone(),y.premultiply(a.initialTransform),T=new br(y.toArray()),A.modelMatrix=T,m.matrix.copy(a.initialTransform),m.matrix.decompose(m.position,m.quaternion,m.scale)},update:function(e,t,r){const s=!(r.matrixWorld.equals(C)&&r.aspect==L);_=r,E=t,I+=e,A&&I>=u&&s&&(I=0,A._frameNumber++,r.getWorldPosition(N),C.copy(r.matrixWorld),U(A,d,t,r))},dispose:function(){for(R=!0,A._destroy();m.children.length>0;){const e=m.children[0];gu(e),m.remove(e)}for(;g.children.length>0;){const e=g.children[0];g.remove(e),e.geometry.dispose(),e.material.dispose()}}}}}))}},Object.defineProperty(e,"__esModule",{value:!0})}));
  //# sourceMappingURL=three-loader-3dtiles.min.js.map
  