@loaders.gl/i3s 3.1.0-alpha.3 → 4.0.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/i3s-attribute-loader.js +44 -14
  2. package/dist/i3s-attribute-loader.js.map +1 -1
  3. package/dist/i3s-building-scene-layer-loader.js +21 -0
  4. package/dist/i3s-building-scene-layer-loader.js.map +1 -0
  5. package/dist/i3s-content-loader.js +1 -1
  6. package/dist/i3s-content-worker.js +7549 -2
  7. package/dist/i3s-loader.js +5 -2
  8. package/dist/i3s-loader.js.map +1 -1
  9. package/dist/i3s-node-page-loader.js +1 -1
  10. package/dist/index.js +2 -0
  11. package/dist/index.js.map +1 -1
  12. package/dist/lib/helpers/i3s-nodepages-tiles.js +27 -20
  13. package/dist/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
  14. package/dist/lib/parsers/constants.js +8 -0
  15. package/dist/lib/parsers/constants.js.map +1 -1
  16. package/dist/lib/parsers/parse-i3s-attribute.js +9 -1
  17. package/dist/lib/parsers/parse-i3s-attribute.js.map +1 -1
  18. package/dist/lib/parsers/parse-i3s-building-scene-layer.js +43 -0
  19. package/dist/lib/parsers/parse-i3s-building-scene-layer.js.map +1 -0
  20. package/dist/lib/parsers/parse-i3s-tile-content.js +49 -32
  21. package/dist/lib/parsers/parse-i3s-tile-content.js.map +1 -1
  22. package/dist/lib/parsers/parse-i3s.js +4 -4
  23. package/dist/lib/parsers/parse-i3s.js.map +1 -1
  24. package/dist/lib/utils/url-utils.js +3 -3
  25. package/dist/lib/utils/url-utils.js.map +1 -1
  26. package/package.json +13 -11
  27. package/src/i3s-attribute-loader.ts +56 -19
  28. package/src/i3s-building-scene-layer-loader.ts +34 -0
  29. package/src/i3s-loader.ts +4 -1
  30. package/src/index.ts +2 -0
  31. package/src/lib/helpers/i3s-nodepages-tiles.ts +28 -12
  32. package/src/lib/parsers/constants.ts +22 -0
  33. package/src/lib/parsers/parse-i3s-attribute.ts +19 -1
  34. package/src/lib/parsers/parse-i3s-building-scene-layer.ts +57 -0
  35. package/src/lib/parsers/parse-i3s-tile-content.ts +51 -31
  36. package/src/types.ts +102 -6
  37. package/dist/dist.min.js +0 -2
  38. package/dist/dist.min.js.map +0 -1
  39. package/dist/i3s-content-worker.js.map +0 -1
package/dist/dist.min.js DELETED
@@ -1,2 +0,0 @@
1
- !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(window,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=22)}([,function(t,e,r){"use strict";(function(t,n){r.d(e,"a",(function(){return s})),r.d(e,"b",(function(){return o})),r.d(e,"d",(function(){return a})),r.d(e,"c",(function(){return c}));const i={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==t&&t,document:"undefined"!=typeof document&&document},s=i.global||i.self||i.window||{},o="object"!=typeof n||"[object process]"!==String(n)||n.browser,a="function"==typeof importScripts,c="undefined"!=typeof window&&void 0!==window.orientation,u=void 0!==n&&n.version&&/v([0-9]*)/.exec(n.version);u&&parseFloat(u[1])}).call(this,r(12),r(4))},function(t,e,r){"use strict";(function(t,n){r.d(e,"a",(function(){return i}));"undefined"!=typeof self&&self,"undefined"!=typeof window&&window,"undefined"!=typeof document&&document;const i=Boolean("object"!=typeof n||"[object process]"!==String(n)||n.browser),s=void 0!==n&&n.version&&/v([0-9]*)/.exec(n.version);s&&parseFloat(s[1])}).call(this,r(12),r(4))},function(t,e,r){"use strict";(function(t,n){r.d(e,"b",(function(){return s})),r.d(e,"a",(function(){return o}));const i={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==t&&t,document:"undefined"!=typeof document&&document,process:"object"==typeof n&&n},s=i.window||i.self||i.global,o=i.process||{};console}).call(this,r(12),r(4))},function(t,e){var r,n,i=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(r===setTimeout)return setTimeout(t,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:s}catch(t){r=s}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(t){n=o}}();var c,u=[],l=!1,h=-1;function f(){l&&c&&(l=!1,c.length?u=c.concat(u):h=-1,u.length&&d())}function d(){if(!l){var t=a(f);l=!0;for(var e=u.length;e;){for(c=u,u=[];++h<e;)c&&c[h].run();h=-1,e=u.length}c=null,l=!1,function(t){if(n===clearTimeout)return clearTimeout(t);if((n===o||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(t);try{n(t)}catch(e){try{return n.call(null,t)}catch(e){return n.call(this,t)}}}(t)}}function _(t,e){this.fun=t,this.array=e}function m(){}i.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];u.push(new _(t,e)),1!==u.length||l||a(d)},_.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=m,i.addListener=m,i.once=m,i.off=m,i.removeListener=m,i.removeAllListeners=m,i.emit=m,i.prependListener=m,i.prependOnceListener=m,i.listeners=function(t){return[]},i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(t,e){},,,function(t,e){},,,,function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e){},,,,,function(t,e){},function(t,e,r){"use strict";(function(t){r.d(e,"a",(function(){return i}));var n=r(20);function i(){return!("object"==typeof t&&"[object process]"===String(t)&&!t.browser)||Object(n.a)()}}).call(this,r(4))},function(t,e,r){"use strict";(function(t){function n(e){if("undefined"!=typeof window&&"object"==typeof window.process&&"renderer"===window.process.type)return!0;if(void 0!==t&&"object"==typeof t.versions&&Boolean(t.versions.electron))return!0;const r="object"==typeof navigator&&"string"==typeof navigator.userAgent&&navigator.userAgent,n=e||r;return!!(n&&n.indexOf("Electron")>=0)}r.d(e,"a",(function(){return n}))}).call(this,r(4))},,function(t,e,r){const n=r(30);globalThis.loaders=globalThis.loaders||{},t.exports=Object.assign(globalThis.loaders,n)},,,,,,,function(t,e){},function(t,e,r){"use strict";r.r(e),r.d(e,"I3SLoader",(function(){return Qs})),r.d(e,"I3SContentLoader",(function(){return ki})),r.d(e,"I3SAttributeLoader",(function(){return to})),r.d(e,"loadFeatureAttributes",(function(){return eo}));var n={};r.r(n),r.d(n,"filename",(function(){return Dt})),r.d(n,"dirname",(function(){return vt})),r.d(n,"join",(function(){return It}));const i=t=>"boolean"==typeof t,s=t=>"function"==typeof t,o=t=>null!==t&&"object"==typeof t,a=t=>o(t)&&t.constructor==={}.constructor,c=t=>t&&"function"==typeof t[Symbol.iterator],u=t=>t&&"function"==typeof t[Symbol.asyncIterator],l=t=>"undefined"!=typeof Response&&t instanceof Response||t&&t.arrayBuffer&&t.text&&t.json,h=t=>"undefined"!=typeof Blob&&t instanceof Blob,f=t=>(t=>"undefined"!=typeof ReadableStream&&t instanceof ReadableStream||o(t)&&s(t.tee)&&s(t.cancel)&&s(t.getReader))(t)||(t=>o(t)&&s(t.read)&&s(t.pipe)&&i(t.readable))(t);function d(t,e){if(!t)throw new Error(e||"loader assertion failed.")}function _(t){var e;if(!t)return!1;Array.isArray(t)&&(t=t[0]);return Array.isArray(null===(e=t)||void 0===e?void 0:e.extensions)}function m(t){var e,r;let n;return d(t,"null loader"),d(_(t),"invalid loader"),Array.isArray(t)&&(n=t[1],t=t[0],t={...t,options:{...t.options,...n}}),(null!==(e=t)&&void 0!==e&&e.parseTextSync||null!==(r=t)&&void 0!==r&&r.parseText)&&(t.text=!0),t.text||(t.binary=!0),t}let p="";const g={};const S=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,y=/^([-\w.]+\/[-\w.+]+)/;function E(t){const e=y.exec(t);return e?e[1]:t}function b(t){const e=S.exec(t);return e?e[1]:""}const R=/\?.*/;function w(t){if(l(t)){const e=A(t.url||"");return{url:e,type:E(t.headers.get("content-type")||"")||b(e)}}return h(t)?{url:A(t.name||""),type:t.type||""}:"string"==typeof t?{url:A(t),type:b(t)}:{url:"",type:""}}function A(t){return t.replace(R,"")}async function T(t){if(l(t))return t;const e={},r=function(t){return l(t)?t.headers["content-length"]||-1:h(t)?t.size:"string"==typeof t?t.length:t instanceof ArrayBuffer||ArrayBuffer.isView(t)?t.byteLength:-1}(t);r>=0&&(e["content-length"]=String(r));const{url:n,type:i}=w(t);i&&(e["content-type"]=i);const s=await async function(t){if("string"==typeof t)return"data:,"+t.slice(0,5);if(t instanceof Blob){const e=t.slice(0,5);return await new Promise(t=>{const r=new FileReader;r.onload=e=>{var r;return t(null==e||null===(r=e.target)||void 0===r?void 0:r.result)},r.readAsDataURL(e)})}if(t instanceof ArrayBuffer){const e=t.slice(0,5);return"data:base64,"+function(t){let e="";const r=new Uint8Array(t);for(let t=0;t<r.byteLength;t++)e+=String.fromCharCode(r[t]);return btoa(e)}(e)}return null}(t);s&&(e["x-first-bytes"]=s),"string"==typeof t&&(t=(new TextEncoder).encode(t));const o=new Response(t,{headers:e});return Object.defineProperty(o,"url",{value:n}),o}async function C(t){if(!t.ok){const e=await async function(t){let e=`Failed to fetch resource ${t.url} (${t.status}): `;try{const r=t.headers.get("Content-Type");let n=t.statusText;r.includes("application/json")&&(n+=" "+await t.text()),e+=n,e=e.length>60?e.slice(60)+"...":e}catch(t){}return e}(t);throw new Error(e)}}async function M(t,e){if("string"==typeof t){t=function(t){for(const e in g)if(t.startsWith(e)){const r=g[e];t=t.replace(e,r)}return t.startsWith("http://")||t.startsWith("https://")||(t=`${p}${t}`),t}(t);let r=e;return null!=e&&e.fetch&&"function"!=typeof(null==e?void 0:e.fetch)&&(r=e.fetch),await fetch(t,r)}return await T(t)}var P=r(19);const x=Object(P.a)();class O{constructor(t,e,r="sessionStorage"){this.storage=function(t){try{const e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch(t){return null}}(r),this.id=t,this.config={},Object.assign(this.config,e),this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(t){return this.config={},this.updateConfiguration(t)}updateConfiguration(t){if(Object.assign(this.config,t),this.storage){const t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}return this}_loadConfiguration(){let t={};if(this.storage){const e=this.storage.getItem(this.id);t=e?JSON.parse(e):{}}return Object.assign(this.config,t),this}}function D(t,e,r,n=600){const i=t.src.replace(/\(/g,"%28").replace(/\)/g,"%29");t.width>n&&(r=Math.min(r,n/t.width));const s=t.width*r,o=t.height*r,a=["font-size:1px;","padding:".concat(Math.floor(o/2),"px ").concat(Math.floor(s/2),"px;"),"line-height:".concat(o,"px;"),"background:url(".concat(i,");"),"background-size:".concat(s,"px ").concat(o,"px;"),"color:transparent;"].join("");return["".concat(e," %c+"),a]}const v={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 I(t){return"string"==typeof t?v[t.toUpperCase()]||v.WHITE:t}function B(t,e){if(!t)throw new Error(e||"Assertion failed")}var L=r(3);function G(){let t;if(x&&L.b.performance)t=L.b.performance.now();else if(L.a.hrtime){const e=L.a.hrtime();t=1e3*e[0]+e[1]/1e6}else t=Date.now();return t}const U={debug:x&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},N={enabled:!0,level:0};function H(){}const k={},F={once:!0};function X(t){for(const e in t)for(const r in t[e])return r||"untitled";return"empty"}class z{constructor({id:t}={id:""}){this.id=t,this.VERSION="3.1.0-alpha.3",this._startTs=G(),this._deltaTs=G(),this.LOG_THROTTLE_TIMEOUT=0,this._storage=new O("__probe-".concat(this.id,"__"),N),this.userData={},this.timeStamp("".concat(this.id," started")),function(t,e=["constructor"]){const r=Object.getPrototypeOf(t),n=Object.getOwnPropertyNames(r);for(const r of n)"function"==typeof t[r]&&(e.find(t=>r===t)||(t[r]=t[r].bind(t)))}(this),Object.seal(this)}set level(t){this.setLevel(t)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((G()-this._startTs).toPrecision(10))}getDelta(){return Number((G()-this._deltaTs).toPrecision(10))}set priority(t){this.level=t}get priority(){return this.level}getPriority(){return this.level}enable(t=!0){return this._storage.updateConfiguration({enabled:t}),this}setLevel(t){return this._storage.updateConfiguration({level:t}),this}assert(t,e){B(t,e)}warn(t){return this._getLogFunction(0,t,U.warn,arguments,F)}error(t){return this._getLogFunction(0,t,U.error,arguments)}deprecated(t,e){return this.warn("`".concat(t,"` is deprecated and will be removed in a later version. Use `").concat(e,"` instead"))}removed(t,e){return this.error("`".concat(t,"` has been removed. Use `").concat(e,"` instead"))}probe(t,e){return this._getLogFunction(t,e,U.log,arguments,{time:!0,once:!0})}log(t,e){return this._getLogFunction(t,e,U.debug,arguments)}info(t,e){return this._getLogFunction(t,e,console.info,arguments)}once(t,e){return this._getLogFunction(t,e,U.debug||U.info,arguments,F)}table(t,e,r){return e?this._getLogFunction(t,e,console.table||H,r&&[r],{tag:X(e)}):H}image({logLevel:t,priority:e,image:n,message:i="",scale:s=1}){return this._shouldLog(t||e)?x?function({image:t,message:e="",scale:r=1}){if("string"==typeof t){const n=new Image;return n.onload=()=>{const t=D(n,e,r);console.log(...t)},n.src=t,H}const n=t.nodeName||"";if("img"===n.toLowerCase())return console.log(...D(t,e,r)),H;if("canvas"===n.toLowerCase()){const n=new Image;return n.onload=()=>console.log(...D(n,e,r)),n.src=t.toDataURL(),H}return H}({image:n,message:i,scale:s}):function({image:t,message:e="",scale:n=1}){let i=null;try{i=r(29)}catch(t){}if(i)return()=>i(t,{fit:"box",width:"".concat(Math.round(80*n),"%")}).then(t=>console.log(t));return H}({image:n,message:i,scale:s}):H}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}get(t){return this._storage.config[t]}set(t,e){this._storage.updateConfiguration({[t]:e})}time(t,e){return this._getLogFunction(t,e,console.time?console.time:console.info)}timeEnd(t,e){return this._getLogFunction(t,e,console.timeEnd?console.timeEnd:console.info)}timeStamp(t,e){return this._getLogFunction(t,e,console.timeStamp||H)}group(t,e,r={collapsed:!1}){r=K({logLevel:t,message:e,opts:r});const{collapsed:n}=r;return r.method=(n?console.groupCollapsed:console.group)||console.info,this._getLogFunction(r)}groupCollapsed(t,e,r={}){return this.group(t,e,Object.assign({},r,{collapsed:!0}))}groupEnd(t){return this._getLogFunction(t,"",console.groupEnd||H)}withGroup(t,e,r){this.group(t,e)();try{r()}finally{this.groupEnd(t)()}}trace(){console.trace&&console.trace()}_shouldLog(t){return this.isEnabled()&&this.getLevel()>=j(t)}_getLogFunction(t,e,r,n=[],i){if(this._shouldLog(t)){i=K({logLevel:t,message:e,args:n,opts:i}),B(r=r||i.method),i.total=this.getTotal(),i.delta=this.getDelta(),this._deltaTs=G();const s=i.tag||i.message;if(i.once){if(k[s])return H;k[s]=G()}return e=function(t,e,r){if("string"==typeof e){const o=r.time?function(t,e=8){const r=Math.max(e-t.length,0);return"".concat(" ".repeat(r)).concat(t)}(function(t){let e;return e=t<10?"".concat(t.toFixed(2),"ms"):t<100?"".concat(t.toFixed(1),"ms"):t<1e3?"".concat(t.toFixed(0),"ms"):"".concat((t/1e3).toFixed(2),"s"),e}(r.total)):"";e=r.time?"".concat(t,": ").concat(o," ").concat(e):"".concat(t,": ").concat(e),n=e,i=r.color,s=r.background,x||"string"!=typeof n||(i&&(i=I(i),n="[".concat(i,"m").concat(n,"")),s&&(i=I(s),n="[".concat(s+10,"m").concat(n,""))),e=n}var n,i,s;return e}(this.id,i.message,i),r.bind(console,e,...i.args)}return H}}function j(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return B(Number.isFinite(e)&&e>=0),e}function K(t){const{logLevel:e,message:r}=t;t.logLevel=j(e);const n=t.args?Array.from(t.args):[];for(;n.length&&n.shift()!==r;);switch(t.args=n,typeof e){case"string":case"function":void 0!==r&&n.unshift(r),t.message=e;break;case"object":Object.assign(t,e)}"function"==typeof t.message&&(t.message=t.message());const i=typeof t.message;return B("string"===i||"object"===i),Object.assign(t,t.opts)}z.VERSION="3.1.0-alpha.3";const W=new z({id:"loaders.gl"});class q{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}const V={fetch:null,mimeType:void 0,nothrow:!1,log:new class{constructor(){var t,e,r;r=void 0,(e="console")in(t=this)?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,this.console=console}log(...t){return this.console.log.bind(this.console,...t)}info(...t){return this.console.info.bind(this.console,...t)}warn(...t){return this.console.warn.bind(this.console,...t)}error(...t){return this.console.error.bind(this.console,...t)}},CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},$={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 Q(){globalThis.loaders=globalThis.loaders||{};const{loaders:t}=globalThis;return t._state=t._state||{},t._state}const Z=()=>{const t=Q();return t.globalOptions=t.globalOptions||{...V},t.globalOptions};function Y(t,e,r,n){return r=r||[],function(t,e){tt(t,null,V,$,e);for(const r of e){const n=t&&t[r.id]||{},i=r.options&&r.options[r.id]||{},s=r.deprecatedOptions&&r.deprecatedOptions[r.id]||{};tt(n,r.id,i,s,e)}}(t,r=Array.isArray(r)?r:[r]),rt(e,t,n)}function J(t,e){const r=Z(),n=t||r;return"function"==typeof n.fetch?n.fetch:o(n.fetch)?t=>M(t,n):null!=e&&e.fetch?null==e?void 0:e.fetch:M}function tt(t,e,r,n,i){const s=e||"Top level",a=e?e+".":"";for(const c in t){const u=!e&&o(t[c]),l="baseUri"===c&&!e,h="workerUrl"===c&&e;if(!(c in r)&&!l&&!h)if(c in n)W.warn(`${s} loader option '${a}${c}' no longer supported, use '${n[c]}'`)();else if(!u){const t=et(c,i);W.warn(`${s} loader option '${a}${c}' not recognized. ${t}`)()}}}function et(t,e){const r=t.toLowerCase();let n="";for(const i of e)for(const e in i.options){if(t===e)return`Did you mean '${i.id}.${e}'?`;const s=e.toLowerCase();(r.startsWith(s)||s.startsWith(r))&&(n=n||`Did you mean '${i.id}.${e}'?`)}return n}function rt(t,e,r){const n={...t.options||{}};return function(t,e){e&&!("baseUri"in t)&&(t.baseUri=e)}(n,r),null===n.log&&(n.log=new q),nt(n,Z()),nt(n,e),n}function nt(t,e){for(const r in e)if(r in e){const n=e[r];a(n)&&a(t[r])?t[r]={...t[r],...e[r]}:t[r]=e[r]}}function it(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}var st=r(1);const ot=new Map;function at(t){it(t.source&&!t.url||!t.source&&t.url);let e=ot.get(t.source||t.url);return e||(t.url&&(e=function(t){if(!t.startsWith("http"))return t;return ct((e=t,`try {\n importScripts('${e}');\n} catch (error) {\n console.error(error);\n throw error;\n}`));var e}(t.url),ot.set(t.url,e)),t.source&&(e=ct(t.source),ot.set(t.source,e))),it(e),e}function ct(t){const e=new Blob([t],{type:"application/javascript"});return URL.createObjectURL(e)}function ut(t){return!!t&&(t instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&t instanceof MessagePort||("undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas)))}function lt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}const ht=()=>{};class ft{static isSupported(){return"undefined"!=typeof Worker}constructor(t){lt(this,"name",void 0),lt(this,"source",void 0),lt(this,"url",void 0),lt(this,"terminated",!1),lt(this,"worker",void 0),lt(this,"onMessage",void 0),lt(this,"onError",void 0),lt(this,"_loadableURL","");const{name:e,source:r,url:n}=t;it(r||n),this.name=e,this.source=r,this.url=n,this.onMessage=ht,this.onError=t=>console.log(t),this.worker=this._createBrowserWorker()}destroy(){this.onMessage=ht,this.onError=ht,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(t,e){e=e||function t(e,r=!0,n){const i=n||new Set;if(e){if(ut(e))i.add(e);else if(ut(e.buffer))i.add(e.buffer);else if(ArrayBuffer.isView(e));else if(r&&"object"==typeof e)for(const n in e)t(e[n],r,i)}else;return void 0===n?Array.from(i):[]}(t),this.worker.postMessage(t,e)}_getErrorFromErrorEvent(t){let e="Failed to load ";return e+=`worker ${this.name} from ${this.url}. `,t.message&&(e+=t.message+" in "),t.lineno&&(e+=`:${t.lineno}:${t.colno}`),new Error(e)}_createBrowserWorker(){this._loadableURL=at({source:this.source,url:this.url});const t=new Worker(this._loadableURL,{name:this.name});return t.onmessage=t=>{t.data?this.onMessage(t.data):this.onError(new Error("No data received"))},t.onerror=t=>{this.onError(this._getErrorFromErrorEvent(t)),this.terminated=!0},t.onmessageerror=t=>console.error(t),t}}function dt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}class _t{constructor(t,e){dt(this,"name",void 0),dt(this,"workerThread",void 0),dt(this,"isRunning",void 0),dt(this,"result",void 0),dt(this,"_resolve",void 0),dt(this,"_reject",void 0),this.name=t,this.workerThread=e,this.isRunning=!0,this._resolve=()=>{},this._reject=()=>{},this.result=new Promise((t,e)=>{this._resolve=t,this._reject=e})}postMessage(t,e){this.workerThread.postMessage({source:"loaders.gl",type:t,payload:e})}done(t){it(this.isRunning),this.isRunning=!1,this._resolve(t)}error(t){it(this.isRunning),this.isRunning=!1,this._reject(t)}}function mt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}class pt{constructor(t){mt(this,"name","unnamed"),mt(this,"source",void 0),mt(this,"url",void 0),mt(this,"maxConcurrency",1),mt(this,"maxMobileConcurrency",1),mt(this,"onDebug",()=>{}),mt(this,"reuseWorkers",!0),mt(this,"props",{}),mt(this,"jobQueue",[]),mt(this,"idleQueue",[]),mt(this,"count",0),mt(this,"isDestroyed",!1),this.source=t.source,this.url=t.url,this.setProps(t)}destroy(){this.idleQueue.forEach(t=>t.destroy()),this.isDestroyed=!0}setProps(t){this.props={...this.props,...t},void 0!==t.name&&(this.name=t.name),void 0!==t.maxConcurrency&&(this.maxConcurrency=t.maxConcurrency),void 0!==t.maxMobileConcurrency&&(this.maxMobileConcurrency=t.maxMobileConcurrency),void 0!==t.reuseWorkers&&(this.reuseWorkers=t.reuseWorkers),void 0!==t.onDebug&&(this.onDebug=t.onDebug)}async startJob(t,e=((t,e,r)=>t.done(r)),r=((t,e)=>t.error(e))){const n=new Promise(n=>(this.jobQueue.push({name:t,onMessage:e,onError:r,onStart:n}),this));return this._startQueuedJob(),await n}async _startQueuedJob(){if(!this.jobQueue.length)return;const t=this._getAvailableWorker();if(!t)return;const e=this.jobQueue.shift();if(e){this.onDebug({message:"Starting job",name:e.name,workerThread:t,backlog:this.jobQueue.length});const r=new _t(e.name,t);t.onMessage=t=>e.onMessage(r,t.type,t.payload),t.onError=t=>e.onError(r,t),e.onStart(r);try{await r.result}finally{this.returnWorkerToQueue(t)}}}returnWorkerToQueue(t){this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(t.destroy(),this.count--):this.idleQueue.push(t),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count<this._getMaxConcurrency()){this.count++;const t=`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;return new ft({name:t,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return st.c?this.maxMobileConcurrency:this.maxConcurrency}}function gt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}const St={maxConcurrency:3,maxMobileConcurrency:1,onDebug:()=>{},reuseWorkers:!0};class yt{static isSupported(){return ft.isSupported()}static getWorkerFarm(t={}){return yt._workerFarm=yt._workerFarm||new yt({}),yt._workerFarm.setProps(t),yt._workerFarm}constructor(t){gt(this,"props",void 0),gt(this,"workerPools",new Map),this.props={...St},this.setProps(t),this.workerPools=new Map}destroy(){for(const t of this.workerPools.values())t.destroy()}setProps(t){this.props={...this.props,...t};for(const t of this.workerPools.values())t.setProps(this._getWorkerPoolProps())}getWorkerPool(t){const{name:e,source:r,url:n}=t;let i=this.workerPools.get(e);return i||(i=new pt({name:e,source:r,url:n}),i.setProps(this._getWorkerPoolProps()),this.workerPools.set(e,i)),i}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}}gt(yt,"_workerFarm",void 0);async function Et(t,e,r,n,i){const s=t.id,o=function(t,e={}){const r=e[t.id]||{},n=t.id+"-worker.js";let i=r.workerUrl;if("test"===e._workerType&&(i=`modules/${t.module}/dist/${n}`),!i){let e=t.version;"latest"===e&&(e="beta");const r=e?"@"+e:"";i=`https://unpkg.com/@loaders.gl/${t.module}${r}/dist/${n}`}return it(i),i}(t,r),a=yt.getWorkerFarm(r).getWorkerPool({name:s,url:o});r=JSON.parse(JSON.stringify(r));const c=await a.startJob("process-on-worker",bt.bind(null,i));c.postMessage("process",{input:e,options:r});const u=await c.result;return await u.result}async function bt(t,e,r,n){switch(r){case"done":e.done(n);break;case"error":e.error(n.error);break;case"process":const{id:i,input:s,options:o}=n;try{const r=await t(s,o);e.postMessage("done",{id:i,result:r})}catch(t){const r=t instanceof Error?t.message:"unknown error";e.postMessage("error",{id:i,error:r})}break;default:console.warn("parse-with-worker unknown message "+r)}}r(13);function Rt(t){return t&&"object"==typeof t&&t.isBuffer}function wt(t){if(Rt(t))return function(t){if(Rt(t)){return new Uint8Array(t.buffer,t.byteOffset,t.length).slice().buffer}return t}(t);if(t instanceof ArrayBuffer)return t;if(ArrayBuffer.isView(t))return 0===t.byteOffset&&t.byteLength===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);if("string"==typeof t){const e=t;return(new TextEncoder).encode(e).buffer}if(t&&"object"==typeof t&&t._toArrayBuffer)return t._toArrayBuffer();throw new Error("toArrayBuffer")}async function At(t){const e=[];for await(const r of t)e.push(r);return function(...t){const e=t.map(t=>t instanceof ArrayBuffer?new Uint8Array(t):t),r=e.reduce((t,e)=>t+e.byteLength,0),n=new Uint8Array(r);let i=0;for(const t of e)n.set(t,i),i+=t.byteLength;return n.buffer}(...e)}const Tt=262144;var Ct=r(2);function Mt(t,e){return Ct.a?async function*(t,e){const r=t.getReader();let n;try{for(;;){const t=n||r.read();null!=e&&e._streamReadAhead&&(n=r.read());const{done:i,value:s}=await t;if(i)return;yield wt(s)}}catch(t){r.releaseLock()}}(t,e):async function*(t,e){for await(const e of t)yield wt(e)}(t)}function Pt(t,e){if("string"==typeof t)return function*(t,e){const r=(null==e?void 0:e.chunkSize)||262144;let n=0;const i=new TextEncoder;for(;n<t.length;){const e=Math.min(t.length-n,r),s=t.slice(n,n+e);n+=e,yield i.encode(s)}}(t,e);if(t instanceof ArrayBuffer)return function*(t,e={}){const{chunkSize:r=Tt}=e;let n=0;for(;n<t.byteLength;){const e=Math.min(t.byteLength-n,r),i=new ArrayBuffer(e),s=new Uint8Array(t,n,e);new Uint8Array(i).set(s),n+=e,yield i}}(t,e);if(h(t))return async function*(t,e){const r=(null==e?void 0:e.chunkSize)||1048576;let n=0;for(;n<t.size;){const e=n+r,i=await t.slice(n,e).arrayBuffer();n=e,yield i}}(t,e);if(f(t))return Mt(t,e);if(l(t)){return Mt(t.body,e)}throw new Error("makeIterator")}const xt="Cannot convert supplied data type";async function Ot(t,e,r){const n=t instanceof ArrayBuffer||ArrayBuffer.isView(t);if("string"==typeof t||n)return function(t,e,r){if(e.text&&"string"==typeof t)return t;var n;if((n=t)&&"object"==typeof n&&n.isBuffer&&(t=t.buffer),t instanceof ArrayBuffer){const r=t;if(e.text&&!e.binary){return new TextDecoder("utf8").decode(r)}return r}if(ArrayBuffer.isView(t)){if(e.text&&!e.binary){return new TextDecoder("utf8").decode(t)}let r=t.buffer;const n=t.byteLength||t.length;return 0===t.byteOffset&&n===r.byteLength||(r=r.slice(t.byteOffset,t.byteOffset+n)),r}throw new Error(xt)}(t,e);if(h(t)&&(t=await T(t)),l(t)){const r=t;return await C(r),e.binary?await r.arrayBuffer():await r.text()}if(f(t)&&(t=Pt(t,r)),c(t)||u(t))return At(t);throw new Error(xt)}function Dt(t){const e=t&&t.lastIndexOf("/");return e>=0?t.substr(e+1):""}function vt(t){const e=t&&t.lastIndexOf("/");return e>=0?t.substr(0,e):""}function It(...t){return(t=t.map((e,r)=>(r&&(e=e.replace(new RegExp("^/"),"")),r!==t.length-1&&(e=e.replace(new RegExp("/$"),"")),e))).join("/")}r(8),r(18);const Bt=()=>{const t=Q();return t.loaderRegistry=t.loaderRegistry||[],t.loaderRegistry};const Lt=/\.([^.]+)$/;function Gt(t,e=[],r,n){if(!Ut(t))return null;if(e&&!Array.isArray(e))return m(e);let i=[];e&&(i=i.concat(e)),null!=r&&r.ignoreRegisteredLoaders||i.push(...Bt()),function(t){for(const e of t)m(e)}(i);const s=function(t,e,r,n){const{url:i,type:s}=w(t),o=i||(null==n?void 0:n.url);let a=null;null!=r&&r.mimeType&&(a=Ht(e,null==r?void 0:r.mimeType));return a=a||function(t,e){const r=e&&Lt.exec(e),n=r&&r[1];return n?function(t,e){e=e.toLowerCase();for(const r of t)for(const t of r.extensions)if(t.toLowerCase()===e)return r;return null}(t,n):null}(e,o),a=a||Ht(e,s),a=a||function(t,e){if(!e)return null;for(const r of t)if("string"==typeof e){if(kt(e,r))return r}else if(ArrayBuffer.isView(e)){if(Ft(e.buffer,e.byteOffset,r))return r}else if(e instanceof ArrayBuffer){if(Ft(e,0,r))return r}return null}(e,t),a=a||Ht(e,null==r?void 0:r.fallbackMimeType),a}(t,i,r,n);if(!(s||null!=r&&r.nothrow))throw new Error(Nt(t));return s}function Ut(t){return!(t instanceof Response&&204===t.status)}function Nt(t){const{url:e,type:r}=w(t);let i="No valid loader found (";i+=e?n.filename(e)+", ":"no url provided, ",i+=`MIME type: ${r?`"${r}"`:"not provided"}, `;const s=t?function(t,e=5){if("string"==typeof t)return t.slice(0,e);if(ArrayBuffer.isView(t))return Xt(t.buffer,t.byteOffset,e);if(t instanceof ArrayBuffer){return Xt(t,0,e)}return""}(t):"";return i+=s?` first bytes: "${s}"`:"first bytes: not available",i+=")",i}function Ht(t,e){for(const r of t){if(r.mimeTypes&&r.mimeTypes.includes(e))return r;if(e==="application/x."+r.id)return r}return null}function kt(t,e){if(e.testText)return e.testText(t);return(Array.isArray(e.tests)?e.tests:[e.tests]).some(e=>t.startsWith(e))}function Ft(t,e,r){return(Array.isArray(r.tests)?r.tests:[r.tests]).some(n=>function(t,e,r,n){if(n instanceof ArrayBuffer)return function(t,e,r){if(r=r||t.byteLength,t.byteLength<r||e.byteLength<r)return!1;const n=new Uint8Array(t),i=new Uint8Array(e);for(let t=0;t<n.length;++t)if(n[t]!==i[t])return!1;return!0}(n,t,n.byteLength);switch(typeof n){case"function":return n(t,r);case"string":const i=Xt(t,e,n.length);return n===i;default:return!1}}(t,e,r,n))}function Xt(t,e,r){if(t.byteLength<e+r)return"";const n=new DataView(t);let i="";for(let t=0;t<r;t++)i+=String.fromCharCode(n.getUint8(e+t));return i}async function zt(t,e,r,n){it(!n||"object"==typeof n),!e||Array.isArray(e)||_(e)||(n=void 0,r=e,e=void 0),t=await t,r=r||{};const{url:i}=w(t),s=function(t,e){if(!e&&t&&!Array.isArray(t))return t;let r;if(t&&(r=Array.isArray(t)?t:[t]),e&&e.loaders){const t=Array.isArray(e.loaders)?e.loaders:[e.loaders];r=r?[...r,...t]:t}return r&&r.length?r:null}(e,n),o=await async function(t,e=[],r,n){if(!Ut(t))return null;let i=Gt(t,e,{...r,nothrow:!0},n);if(i)return i;if(h(t)&&(i=Gt(t=await t.slice(0,10).arrayBuffer(),e,r,n)),!(i||null!=r&&r.nothrow))throw new Error(Nt(t));return i}(t,s,r);return o?(n=function(t,e,r=null){if(r)return r;const n={fetch:J(e,t),...t};return Array.isArray(n.loaders)||(n.loaders=null),n}({url:i,parse:zt,loaders:s},r=Y(r,o,s,i),n),await async function(t,e,r,n){if(function(t,e="3.1.0-alpha.3"){it(t,"no worker provided");const r=t.version}(t),e=await Ot(e,t,r),t.parseTextSync&&"string"==typeof e)return r.dataType="text",t.parseTextSync(e,r,n,t);if(function(t,e){return!!yt.isSupported()&&(t.worker&&(null==e?void 0:e.worker))}(t,r))return await Et(t,e,r,0,zt);if(t.parseText&&"string"==typeof e)return await t.parseText(e,r,n,t);if(t.parse)return await t.parse(e,r,n,t);throw it(!t.parseSync),new Error(t.id+" loader - no parser found and worker is disabled")}(o,t,r,n)):null}async function jt(t,e,r,n){Array.isArray(e)||_(e)||(void 0,r=e,e=void 0);const i=J(r);let s=t;return"string"==typeof t&&(s=await i(t)),h(t)&&(s=await i(t)),await zt(s,e,r)}function Kt(t,e){if(!t)throw new Error("math.gl assertion ".concat(e))}const Wt=1/Math.PI*180,qt=1/180*Math.PI,Vt={};function $t(t,{precision:e=Vt.precision||4}={}){return t=function(t){return Math.round(t/Vt.EPSILON)*Vt.EPSILON}(t),"".concat(parseFloat(t.toPrecision(e)))}function Qt(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Zt(t,e,r){if(Qt(t)){r=r||((n=t).clone?n.clone():new Array(n.length));for(let n=0;n<r.length&&n<t.length;++n)r[n]=e(t[n],n,r);return r}var n;return e(t)}function Yt(t){return function(t,e){return Zt(t,t=>t*qt,e)}(t)}function Jt(t){return function(t,e){return Zt(t,t=>t*Wt,e)}(t)}function te(t,e,r){const n=Vt.EPSILON;r&&(Vt.EPSILON=r);try{if(t===e)return!0;if(Qt(t)&&Qt(e)){if(t.length!==e.length)return!1;for(let r=0;r<t.length;++r)if(!te(t[r],e[r]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):!(!Number.isFinite(t)||!Number.isFinite(e))&&Math.abs(t-e)<=Vt.EPSILON*Math.max(1,Math.abs(t),Math.abs(e))}finally{Vt.EPSILON=n}}Vt.EPSILON=1e-12,Vt.debug=!1,Vt.precision=4,Vt.printTypes=!1,Vt.printDegrees=!1,Vt.printRowMajor=!0;class ee extends(function(t){function e(){var e=Reflect.construct(t,Array.from(arguments));return Object.setPrototypeOf(e,Object.getPrototypeOf(this)),e}return e.prototype=Object.create(t.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t,e}(Array)){get ELEMENTS(){return Kt(!1),0}clone(){return(new this.constructor).copy(this)}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}fromArray(t,e=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=t[r+e];return this.check()}to(t){return t===this?this:Qt(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toArray(t=[],e=0){for(let r=0;r<this.ELEMENTS;++r)t[e+r]=this[r];return t}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(Vt)}formatString(t){let e="";for(let r=0;r<this.ELEMENTS;++r)e+=(r>0?", ":"")+$t(this[r],t);return"".concat(t.printTypes?this.constructor.name:"","[").concat(e,"]")}equals(t){if(!t||this.length!==t.length)return!1;for(let e=0;e<this.ELEMENTS;++e)if(!te(this[e],t[e]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let e=0;e<this.ELEMENTS;++e)if(this[e]!==t[e])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,e,r){void 0===r&&(r=e,e=t,t=this);for(let n=0;n<this.ELEMENTS;++n){const i=t[n];this[n]=i+r*(e[n]-i)}return this.check()}min(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=Math.min(t[e],this[e]);return this.check()}max(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=Math.max(t[e],this[e]);return this.check()}clamp(t,e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t[r]),e[r]);return this.check()}add(...t){for(const e of t)for(let t=0;t<this.ELEMENTS;++t)this[t]+=e[t];return this.check()}subtract(...t){for(const e of t)for(let t=0;t<this.ELEMENTS;++t)this[t]-=e[t];return this.check()}scale(t){if(Array.isArray(t))return this.multiply(t);for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;return this.check()}sub(t){return this.subtract(t)}setScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=t;return this.check()}addScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;return this.check()}divideScalar(t){return this.scale(1/t)}clampScalar(t,e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t),e);return this.check()}multiplyByScalar(t){return this.scale(t)}get elements(){return this}check(){if(Vt.debug&&!this.validate())throw new Error("math.gl: ".concat(this.constructor.name," some fields set to invalid numbers'"));return this}validate(){let t=this.length===this.ELEMENTS;for(let e=0;e<this.ELEMENTS;++e)t=t&&Number.isFinite(this[e]);return t}}function re(t){if(!Number.isFinite(t))throw new Error("Invalid number ".concat(t));return t}function ne(t,e,r=""){if(Vt.debug&&!function(t,e){if(t.length!==e)return!1;for(let e=0;e<t.length;++e)if(!Number.isFinite(t[e]))return!1;return!0}(t,e))throw new Error("math.gl: ".concat(r," some fields set to invalid numbers'"));return t}const ie={};function se(t,e){ie[t]||(ie[t]=!0,console.warn("".concat(t," has been removed in version ").concat(e,", see upgrade guide for more information")))}class oe extends ee{get ELEMENTS(){return Kt(!1),0}copy(t){return Kt(!1),this}get x(){return this[0]}set x(t){this[0]=re(t)}get y(){return this[1]}set y(t){this[1]=re(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let e=0;e<this.ELEMENTS;++e)t+=this[e]*this[e];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let e=0;for(let r=0;r<this.ELEMENTS;++r){const n=this[r]-t[r];e+=n*n}return re(e)}dot(t){let e=0;for(let r=0;r<this.ELEMENTS;++r)e+=this[r]*t[r];return re(e)}normalize(){const t=this.magnitude();if(0!==t)for(let e=0;e<this.ELEMENTS;++e)this[e]/=t;return this.check()}multiply(...t){for(const e of t)for(let t=0;t<this.ELEMENTS;++t)this[t]*=e[t];return this.check()}divide(...t){for(const e of t)for(let t=0;t<this.ELEMENTS;++t)this[t]/=e[t];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return Kt(t>=0&&t<this.ELEMENTS,"index is out of range"),re(this[t])}setComponent(t,e){return Kt(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=e,this.check()}addVectors(t,e){return this.copy(t).add(e)}subVectors(t,e){return this.copy(t).subtract(e)}multiplyVectors(t,e){return this.copy(t).multiply(e)}addScaledVector(t,e){return this.add(new this.constructor(t).multiplyScalar(e))}}var ae=1e-6,ce="undefined"!=typeof Float32Array?Float32Array:Array;Math.random;Math.PI;function ue(){var t=new ce(3);return ce!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function le(t){var e=t[0],r=t[1],n=t[2];return Math.hypot(e,r,n)}function he(t,e,r){var n=new ce(3);return n[0]=t,n[1]=e,n[2]=r,n}function fe(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function de(t,e,r){var n=e[0],i=e[1],s=e[2],o=r[0],a=r[1],c=r[2];return t[0]=i*c-s*a,t[1]=s*o-n*c,t[2]=n*a-i*o,t}function _e(t,e,r){var n=e[0],i=e[1],s=e[2],o=r[3]*n+r[7]*i+r[11]*s+r[15];return o=o||1,t[0]=(r[0]*n+r[4]*i+r[8]*s+r[12])/o,t[1]=(r[1]*n+r[5]*i+r[9]*s+r[13])/o,t[2]=(r[2]*n+r[6]*i+r[10]*s+r[14])/o,t}function me(t,e,r){var n=e[0],i=e[1],s=e[2];return t[0]=n*r[0]+i*r[3]+s*r[6],t[1]=n*r[1]+i*r[4]+s*r[7],t[2]=n*r[2]+i*r[5]+s*r[8],t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var pe,ge=le;pe=ue();function Se(t,e,r){const n=e[0],i=e[1],s=e[2],o=r[3]*n+r[7]*i+r[11]*s||1;return t[0]=(r[0]*n+r[4]*i+r[8]*s)/o,t[1]=(r[1]*n+r[5]*i+r[9]*s)/o,t[2]=(r[2]*n+r[6]*i+r[10]*s)/o,t}const ye=[0,0,0],Ee={};class be extends oe{static get ZERO(){return Ee.ZERO=Ee.ZERO||Object.freeze(new be(0,0,0,0))}constructor(t=0,e=0,r=0){super(-0,-0,-0),1===arguments.length&&Qt(t)?this.copy(t):(Vt.debug&&(re(t),re(e),re(r)),this[0]=t,this[1]=e,this[2]=r)}set(t,e,r){return this[0]=t,this[1]=e,this[2]=r,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this.check()}fromObject(t){return Vt.debug&&(re(t.x),re(t.y),re(t.z)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t}get ELEMENTS(){return 3}get z(){return this[2]}set z(t){this[2]=re(t)}angle(t){return r=t,n=(e=this)[0],i=e[1],s=e[2],o=r[0],a=r[1],c=r[2],u=Math.sqrt(n*n+i*i+s*s)*Math.sqrt(o*o+a*a+c*c),l=u&&fe(e,r)/u,Math.acos(Math.min(Math.max(l,-1),1));var e,r,n,i,s,o,a,c,u,l}cross(t){return de(this,this,t),this.check()}rotateX({radians:t,origin:e=ye}){var r,n,i,s,o,a;return r=this,i=e,s=t,a=[],(o=[])[0]=(n=this)[0]-i[0],o[1]=n[1]-i[1],o[2]=n[2]-i[2],a[0]=o[0],a[1]=o[1]*Math.cos(s)-o[2]*Math.sin(s),a[2]=o[1]*Math.sin(s)+o[2]*Math.cos(s),r[0]=a[0]+i[0],r[1]=a[1]+i[1],r[2]=a[2]+i[2],this.check()}rotateY({radians:t,origin:e=ye}){var r,n,i,s,o,a;return r=this,i=e,s=t,a=[],(o=[])[0]=(n=this)[0]-i[0],o[1]=n[1]-i[1],o[2]=n[2]-i[2],a[0]=o[2]*Math.sin(s)+o[0]*Math.cos(s),a[1]=o[1],a[2]=o[2]*Math.cos(s)-o[0]*Math.sin(s),r[0]=a[0]+i[0],r[1]=a[1]+i[1],r[2]=a[2]+i[2],this.check()}rotateZ({radians:t,origin:e=ye}){var r,n,i,s,o,a;return r=this,i=e,s=t,a=[],(o=[])[0]=(n=this)[0]-i[0],o[1]=n[1]-i[1],o[2]=n[2]-i[2],a[0]=o[0]*Math.cos(s)-o[1]*Math.sin(s),a[1]=o[0]*Math.sin(s)+o[1]*Math.cos(s),a[2]=o[2],r[0]=a[0]+i[0],r[1]=a[1]+i[1],r[2]=a[2]+i[2],this.check()}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return _e(this,this,t),this.check()}transformAsVector(t){return Se(this,this,t),this.check()}transformByMatrix3(t){return me(this,this,t),this.check()}transformByMatrix2(t){return function(t,e,r){const n=e[0],i=e[1];t[0]=r[0]*n+r[2]*i,t[1]=r[1]*n+r[3]*i,t[2]=e[2]}(this,this,t),this.check()}transformByQuaternion(t){var e,r,n,i,s,o,a,c,u,l,h,f,d,_,m,p,g;return e=this,r=this,i=(n=t)[0],s=n[1],o=n[2],a=n[3],c=r[0],u=r[1],l=r[2],_=s*(d=i*u-s*c)-o*(f=o*c-i*l),m=o*(h=s*l-o*u)-i*d,p=i*f-s*h,h*=g=2*a,f*=g,d*=g,_*=2,m*=2,p*=2,e[0]=c+h+_,e[1]=u+f+m,e[2]=l+d+p,this.check()}}class Re extends ee{get ELEMENTS(){return Kt(!1),0}get RANK(){return Kt(!1),0}toString(){let t="[";if(Vt.printRowMajor){t+="row-major:";for(let e=0;e<this.RANK;++e)for(let r=0;r<this.RANK;++r)t+=" ".concat(this[r*this.RANK+e])}else{t+="column-major:";for(let e=0;e<this.ELEMENTS;++e)t+=" ".concat(this[e])}return t+="]",t}getElementIndex(t,e){return e*this.RANK+t}getElement(t,e){return this[e*this.RANK+t]}setElement(t,e,r){return this[e*this.RANK+t]=re(r),this}getColumn(t,e=new Array(this.RANK).fill(-0)){const r=t*this.RANK;for(let t=0;t<this.RANK;++t)e[t]=this[r+t];return e}setColumn(t,e){const r=t*this.RANK;for(let t=0;t<this.RANK;++t)this[r+t]=e[t];return this}}function we(t,e,r){var n=e[0],i=e[1],s=e[2],o=e[3],a=e[4],c=e[5],u=e[6],l=e[7],h=e[8],f=e[9],d=e[10],_=e[11],m=e[12],p=e[13],g=e[14],S=e[15],y=r[0],E=r[1],b=r[2],R=r[3];return t[0]=y*n+E*a+b*h+R*m,t[1]=y*i+E*c+b*f+R*p,t[2]=y*s+E*u+b*d+R*g,t[3]=y*o+E*l+b*_+R*S,y=r[4],E=r[5],b=r[6],R=r[7],t[4]=y*n+E*a+b*h+R*m,t[5]=y*i+E*c+b*f+R*p,t[6]=y*s+E*u+b*d+R*g,t[7]=y*o+E*l+b*_+R*S,y=r[8],E=r[9],b=r[10],R=r[11],t[8]=y*n+E*a+b*h+R*m,t[9]=y*i+E*c+b*f+R*p,t[10]=y*s+E*u+b*d+R*g,t[11]=y*o+E*l+b*_+R*S,y=r[12],E=r[13],b=r[14],R=r[15],t[12]=y*n+E*a+b*h+R*m,t[13]=y*i+E*c+b*f+R*p,t[14]=y*s+E*u+b*d+R*g,t[15]=y*o+E*l+b*_+R*S,t}function Ae(t,e,r){var n=r[0],i=r[1],s=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*s,t[9]=e[9]*s,t[10]=e[10]*s,t[11]=e[11]*s,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Te(t,e){var r=e[0],n=e[1],i=e[2],s=e[4],o=e[5],a=e[6],c=e[8],u=e[9],l=e[10];return t[0]=Math.hypot(r,n,i),t[1]=Math.hypot(s,o,a),t[2]=Math.hypot(c,u,l),t}!function(){var t,e=(t=new ce(2),ce!=Float32Array&&(t[0]=0,t[1]=0),t)}();function Ce(t){var e=t[0],r=t[1],n=t[2],i=t[3];return Math.hypot(e,r,n,i)}function Me(t){var e=t[0],r=t[1],n=t[2],i=t[3];return e*e+r*r+n*n+i*i}!function(){var t,e=(t=new ce(4),ce!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();const Pe=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),xe=Object.freeze([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Oe=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}),De={};class ve extends Re{static get IDENTITY(){return De.IDENTITY=De.IDENTITY||Object.freeze(new ve(Pe)),De.IDENTITY}static get ZERO(){return De.ZERO=De.ZERO||Object.freeze(new ve(xe)),De.ZERO}get INDICES(){return Oe}get ELEMENTS(){return 16}get RANK(){return 4}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(t)?this.copy(t):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,e,r,n,i,s,o,a,c,u,l,h,f,d,_,m){return this[0]=t,this[1]=e,this[2]=r,this[3]=n,this[4]=i,this[5]=s,this[6]=o,this[7]=a,this[8]=c,this[9]=u,this[10]=l,this[11]=h,this[12]=f,this[13]=d,this[14]=_,this[15]=m,this.check()}setRowMajor(t,e,r,n,i,s,o,a,c,u,l,h,f,d,_,m){return this[0]=t,this[1]=i,this[2]=c,this[3]=f,this[4]=e,this[5]=s,this[6]=u,this[7]=d,this[8]=r,this[9]=o,this[10]=l,this[11]=_,this[12]=n,this[13]=a,this[14]=h,this[15]=m,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(Pe)}fromQuaternion(t){return function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=r+r,a=n+n,c=i+i,u=r*o,l=n*o,h=n*a,f=i*o,d=i*a,_=i*c,m=s*o,p=s*a,g=s*c;t[0]=1-h-_,t[1]=l+g,t[2]=f-p,t[3]=0,t[4]=l-g,t[5]=1-u-_,t[6]=d+m,t[7]=0,t[8]=f+p,t[9]=d-m,t[10]=1-u-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1}(this,t),this.check()}frustum({left:t,right:e,bottom:r,top:n,near:i,far:s}){return s===1/0?ve._computeInfinitePerspectiveOffCenter(this,t,e,r,n,i):function(t,e,r,n,i,s,o){var a=1/(r-e),c=1/(i-n),u=1/(s-o);t[0]=2*s*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*s*c,t[6]=0,t[7]=0,t[8]=(r+e)*a,t[9]=(i+n)*c,t[10]=(o+s)*u,t[11]=-1,t[12]=0,t[13]=0,t[14]=o*s*2*u,t[15]=0}(this,t,e,r,n,i,s),this.check()}static _computeInfinitePerspectiveOffCenter(t,e,r,n,i,s){const o=2*s/(r-e),a=2*s/(i-n),c=(r+e)/(r-e),u=(i+n)/(i-n),l=-2*s;return t[0]=o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=c,t[9]=u,t[10]=-1,t[11]=-1,t[12]=0,t[13]=0,t[14]=l,t[15]=0,t}lookAt(t,e,r){return 1===arguments.length&&({eye:t,center:e,up:r}=t),function(t,e,r,n){var i,s,o,a,c,u,l,h,f,d,_=e[0],m=e[1],p=e[2],g=n[0],S=n[1],y=n[2],E=r[0],b=r[1],R=r[2];Math.abs(_-E)<ae&&Math.abs(m-b)<ae&&Math.abs(p-R)<ae?function(t){t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1}(t):(l=_-E,h=m-b,f=p-R,i=S*(f*=d=1/Math.hypot(l,h,f))-y*(h*=d),s=y*(l*=d)-g*f,o=g*h-S*l,(d=Math.hypot(i,s,o))?(i*=d=1/d,s*=d,o*=d):(i=0,s=0,o=0),a=h*o-f*s,c=f*i-l*o,u=l*s-h*i,(d=Math.hypot(a,c,u))?(a*=d=1/d,c*=d,u*=d):(a=0,c=0,u=0),t[0]=i,t[1]=a,t[2]=l,t[3]=0,t[4]=s,t[5]=c,t[6]=h,t[7]=0,t[8]=o,t[9]=u,t[10]=f,t[11]=0,t[12]=-(i*_+s*m+o*p),t[13]=-(a*_+c*m+u*p),t[14]=-(l*_+h*m+f*p),t[15]=1)}(this,t,e=e||[0,0,0],r=r||[0,1,0]),this.check()}ortho({left:t,right:e,bottom:r,top:n,near:i=.1,far:s=500}){return function(t,e,r,n,i,s,o){var a=1/(e-r),c=1/(n-i),u=1/(s-o);t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*u,t[11]=0,t[12]=(e+r)*a,t[13]=(i+n)*c,t[14]=(o+s)*u,t[15]=1}(this,t,e,r,n,i,s),this.check()}orthographic({fovy:t=45*Math.PI/180,aspect:e=1,focalDistance:r=1,near:n=.1,far:i=500}){if(t>2*Math.PI)throw Error("radians");const s=t/2,o=r*Math.tan(s),a=o*e;return(new ve).ortho({left:-a,right:a,bottom:-o,top:o,near:n,far:i})}perspective({fovy:t,fov:e=45*Math.PI/180,aspect:r=1,near:n=.1,far:i=500}={}){if((t=t||e)>2*Math.PI)throw Error("radians");return function(t,e,r,n,i){var s,o=1/Math.tan(e/2);t[0]=o/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(s=1/(n-i),t[10]=(i+n)*s,t[14]=2*i*n*s):(t[10]=-1,t[14]=-2*n)}(this,t,r,n,i),this.check()}determinant(){return e=(t=this)[0],r=t[1],n=t[2],i=t[3],s=t[4],o=t[5],a=t[6],c=t[7],u=t[8],l=t[9],h=t[10],f=t[11],d=t[12],_=t[13],m=t[14],p=t[15],(e*o-r*s)*(h*p-f*m)-(e*a-n*s)*(l*p-f*_)+(e*c-i*s)*(l*m-h*_)+(r*a-n*o)*(u*p-f*d)-(r*c-i*o)*(u*m-h*d)+(n*c-i*a)*(u*_-l*d);var t,e,r,n,i,s,o,a,c,u,l,h,f,d,_,m,p}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t=[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],e=null){const r=this.getScale(e||[-0,-0,-0]),n=1/r[0],i=1/r[1],s=1/r[2];return t[0]=this[0]*n,t[1]=this[1]*i,t[2]=this[2]*s,t[3]=0,t[4]=this[4]*n,t[5]=this[5]*i,t[6]=this[6]*s,t[7]=0,t[8]=this[8]*n,t[9]=this[9]*i,t[10]=this[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t=[-0,-0,-0,-0,-0,-0,-0,-0,-0],e=null){const r=this.getScale(e||[-0,-0,-0]),n=1/r[0],i=1/r[1],s=1/r[2];return t[0]=this[0]*n,t[1]=this[1]*i,t[2]=this[2]*s,t[3]=this[4]*n,t[4]=this[5]*i,t[5]=this[6]*s,t[6]=this[8]*n,t[7]=this[9]*i,t[8]=this[10]*s,t}transpose(){return function(t,e){if(t===e){var r=e[1],n=e[2],i=e[3],s=e[6],o=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=s,t[11]=e[14],t[12]=i,t[13]=o,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15]}(this,this),this.check()}invert(){var t,e,r,n,i,s,o,a,c,u,l,h,f,d,_,m,p,g,S,y,E,b,R,w,A,T,C,M,P,x,O;return t=this,r=(e=this)[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],c=e[6],u=e[7],l=e[8],h=e[9],f=e[10],d=e[11],_=e[12],m=e[13],p=e[14],g=e[15],(O=(S=r*a-n*o)*(x=f*g-d*p)-(y=r*c-i*o)*(P=h*g-d*m)+(E=r*u-s*o)*(M=h*p-f*m)+(b=n*c-i*a)*(C=l*g-d*_)-(R=n*u-s*a)*(T=l*p-f*_)+(w=i*u-s*c)*(A=l*m-h*_))&&(O=1/O,t[0]=(a*x-c*P+u*M)*O,t[1]=(i*P-n*x-s*M)*O,t[2]=(m*w-p*R+g*b)*O,t[3]=(f*R-h*w-d*b)*O,t[4]=(c*C-o*x-u*T)*O,t[5]=(r*x-i*C+s*T)*O,t[6]=(p*E-_*w-g*y)*O,t[7]=(l*w-f*E+d*y)*O,t[8]=(o*P-a*C+u*A)*O,t[9]=(n*C-r*P-s*A)*O,t[10]=(_*R-m*E+g*S)*O,t[11]=(h*E-l*R-d*S)*O,t[12]=(a*T-o*M-c*A)*O,t[13]=(r*M-n*T+i*A)*O,t[14]=(m*y-_*b-p*S)*O,t[15]=(l*b-h*y+f*S)*O),this.check()}multiplyLeft(t){return we(this,t,this),this.check()}multiplyRight(t){return we(this,this,t),this.check()}rotateX(t){var e,r,n,i,s,o,a,c,u,l,h,f,d;return e=this,r=this,n=t,i=Math.sin(n),s=Math.cos(n),o=r[4],a=r[5],c=r[6],u=r[7],l=r[8],h=r[9],f=r[10],d=r[11],r!==e&&(e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15]),e[4]=o*s+l*i,e[5]=a*s+h*i,e[6]=c*s+f*i,e[7]=u*s+d*i,e[8]=l*s-o*i,e[9]=h*s-a*i,e[10]=f*s-c*i,e[11]=d*s-u*i,this.check()}rotateY(t){var e,r,n,i,s,o,a,c,u,l,h,f,d;return e=this,r=this,n=t,i=Math.sin(n),s=Math.cos(n),o=r[0],a=r[1],c=r[2],u=r[3],l=r[8],h=r[9],f=r[10],d=r[11],r!==e&&(e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15]),e[0]=o*s-l*i,e[1]=a*s-h*i,e[2]=c*s-f*i,e[3]=u*s-d*i,e[8]=o*i+l*s,e[9]=a*i+h*s,e[10]=c*i+f*s,e[11]=u*i+d*s,this.check()}rotateZ(t){var e,r,n,i,s,o,a,c,u,l,h,f,d;return e=this,r=this,n=t,i=Math.sin(n),s=Math.cos(n),o=r[0],a=r[1],c=r[2],u=r[3],l=r[4],h=r[5],f=r[6],d=r[7],r!==e&&(e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15]),e[0]=o*s+l*i,e[1]=a*s+h*i,e[2]=c*s+f*i,e[3]=u*s+d*i,e[4]=l*s-o*i,e[5]=h*s-a*i,e[6]=f*s-c*i,e[7]=d*s-u*i,this.check()}rotateXYZ([t,e,r]){return this.rotateX(t).rotateY(e).rotateZ(r)}rotateAxis(t,e){return function(t,e,r,n){var i,s,o,a,c,u,l,h,f,d,_,m,p,g,S,y,E,b,R,w,A,T,C,M,P=n[0],x=n[1],O=n[2],D=Math.hypot(P,x,O);D<ae||(P*=D=1/D,x*=D,O*=D,i=Math.sin(r),o=1-(s=Math.cos(r)),a=e[0],c=e[1],u=e[2],l=e[3],h=e[4],f=e[5],d=e[6],_=e[7],m=e[8],p=e[9],g=e[10],S=e[11],y=P*P*o+s,E=x*P*o+O*i,b=O*P*o-x*i,R=P*x*o-O*i,w=x*x*o+s,A=O*x*o+P*i,T=P*O*o+x*i,C=x*O*o-P*i,M=O*O*o+s,t[0]=a*y+h*E+m*b,t[1]=c*y+f*E+p*b,t[2]=u*y+d*E+g*b,t[3]=l*y+_*E+S*b,t[4]=a*R+h*w+m*A,t[5]=c*R+f*w+p*A,t[6]=u*R+d*w+g*A,t[7]=l*R+_*w+S*A,t[8]=a*T+h*C+m*M,t[9]=c*T+f*C+p*M,t[10]=u*T+d*C+g*M,t[11]=l*T+_*C+S*M,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]))}(this,this,t,e),this.check()}scale(t){return Array.isArray(t)?Ae(this,this,t):Ae(this,this,[t,t,t]),this.check()}translate(t){var e,r,n,i,s,o,a,c,u,l,h,f,d,_,m,p,g,S;return e=this,r=this,p=(n=t)[0],g=n[1],S=n[2],r===e?(e[12]=r[0]*p+r[4]*g+r[8]*S+r[12],e[13]=r[1]*p+r[5]*g+r[9]*S+r[13],e[14]=r[2]*p+r[6]*g+r[10]*S+r[14],e[15]=r[3]*p+r[7]*g+r[11]*S+r[15]):(i=r[0],s=r[1],o=r[2],a=r[3],c=r[4],u=r[5],l=r[6],h=r[7],f=r[8],d=r[9],_=r[10],m=r[11],e[0]=i,e[1]=s,e[2]=o,e[3]=a,e[4]=c,e[5]=u,e[6]=l,e[7]=h,e[8]=f,e[9]=d,e[10]=_,e[11]=m,e[12]=i*p+c*g+f*S+r[12],e[13]=s*p+u*g+d*S+r[13],e[14]=o*p+l*g+_*S+r[14],e[15]=a*p+h*g+m*S+r[15]),this.check()}transform(t,e){return 4===t.length?(r=e||[-0,-0,-0,-0],i=this,s=(n=t)[0],o=n[1],a=n[2],c=n[3],r[0]=i[0]*s+i[4]*o+i[8]*a+i[12]*c,r[1]=i[1]*s+i[5]*o+i[9]*a+i[13]*c,r[2]=i[2]*s+i[6]*o+i[10]*a+i[14]*c,r[3]=i[3]*s+i[7]*o+i[11]*a+i[15]*c,ne(e=r,4),e):this.transformAsPoint(t,e);var r,n,i,s,o,a,c}transformAsPoint(t,e){const{length:r}=t;switch(r){case 2:n=e||[-0,-0],s=this,o=(i=t)[0],a=i[1],n[0]=s[0]*o+s[4]*a+s[12],n[1]=s[1]*o+s[5]*a+s[13],e=n;break;case 3:e=_e(e||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}var n,i,s,o,a;return ne(e,t.length),e}transformAsVector(t,e){switch(t.length){case 2:e=function(t,e,r){const n=e[0],i=e[1],s=r[3]*n+r[7]*i||1;return t[0]=(r[0]*n+r[4]*i)/s,t[1]=(r[1]*n+r[5]*i)/s,t}(e||[-0,-0],t,this);break;case 3:e=Se(e||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return ne(e,t.length),e}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,e,r){return this.identity().translate([t,e,r])}transformPoint(t,e){return se("Matrix4.transformPoint","3.0"),this.transformAsPoint(t,e)}transformVector(t,e){return se("Matrix4.transformVector","3.0"),this.transformAsPoint(t,e)}transformDirection(t,e){return se("Matrix4.transformDirection","3.0"),this.transformAsVector(t,e)}}var Ie=.1,Be=1e-12,Le=1e-15;Math.PI,Math.PI,Math.PI,Math.PI;Math.max(6378137,6378137,6356752.314245179);const Ge=t=>t,Ue=new be;function Ne(t,e,r=Ge){return Qt(t)?(e[0]=r(t[0]),e[1]=r(t[1]),e[2]=t[2]):"longitude"in t?(e[0]=r(t.longitude),e[1]=r(t.latitude),e[2]=t.height):(e[0]=r(t.x),e[1]=r(t.y),e[2]=t.z),e}function He(t,e,r=Ge){return Qt(e)?(e[0]=r(t[0]),e[1]=r(t[1]),e[2]=t[2]):"longitude"in e?(e.longitude=r(t[0]),e.latitude=r(t[1]),e.height=t[2]):(e.x=r(t[0]),e.y=r(t[1]),e.z=t[2]),e}const ke=new be,Fe=new be,Xe=new be;const ze=new be,je={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"}},Ke={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},We={east:new be,north:new be,up:new be,west:new be,south:new be,down:new be},qe=new be,Ve=new be,$e=new be;function Qe(t,e,r,n,i,s){const o=je[e]&&je[e][r];let a,c,u;Kt(o&&(!n||n===o));const l=ze.copy(i);if(te(l.x,0,1e-14)&&te(l.y,0,1e-14)){const t=Math.sign(l.z);a=qe.fromArray(Ke[e]),"east"!==e&&"west"!==e&&a.scale(t),c=Ve.fromArray(Ke[r]),"east"!==r&&"west"!==r&&c.scale(t),u=$e.fromArray(Ke[n]),"east"!==n&&"west"!==n&&u.scale(t)}else{const{up:i,east:s,north:o}=We;s.set(-l.y,l.x,0).normalize(),t.geodeticSurfaceNormal(l,i),o.copy(i).cross(s);const{down:h,west:f,south:d}=We;h.copy(i).scale(-1),f.copy(s).scale(-1),d.copy(o).scale(-1),a=We[e],c=We[r],u=We[n]}return s[0]=a.x,s[1]=a.y,s[2]=a.z,s[3]=0,s[4]=c.x,s[5]=c.y,s[6]=c.z,s[7]=0,s[8]=u.x,s[9]=u.y,s[10]=u.z,s[11]=0,s[12]=l.x,s[13]=l.y,s[14]=l.z,s[15]=1,s}const Ze=new be,Ye=new be,Je=new be,tr=new be,er=new be,rr=new be;let nr;class ir{static get WGS84(){return nr=nr||new ir(6378137,6378137,6356752.314245179),nr}constructor(t=0,e=0,r=0){Kt(t>=0),Kt(e>=0),Kt(r>=0),this.radii=new be(t,e,r),this.radiiSquared=new be(t*t,e*e,r*r),this.radiiToTheFourth=new be(t*t*t*t,e*e*e*e,r*r*r*r),this.oneOverRadii=new be(0===t?0:1/t,0===e?0:1/e,0===r?0:1/r),this.oneOverRadiiSquared=new be(0===t?0:1/(t*t),0===e?0:1/(e*e),0===r?0:1/(r*r)),this.minimumRadius=Math.min(t,e,r),this.maximumRadius=Math.max(t,e,r),this.centerToleranceSquared=Ie,0!==this.radiiSquared.z&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(t){return this===t||Boolean(t&&this.radii.equals(t.radii))}toString(){return this.radii.toString()}cartographicToCartesian(t,e=[0,0,0]){const r=Ye,n=Je,[,,i]=t;this.geodeticSurfaceNormalCartographic(t,r),n.copy(this.radiiSquared).scale(r);const s=Math.sqrt(r.dot(n));return n.scale(1/s),r.scale(i),n.add(r),n.to(e)}cartesianToCartographic(t,e=[0,0,0]){rr.from(t);const r=this.scaleToGeodeticSurface(rr,tr);if(!r)return;const n=this.geodeticSurfaceNormal(r,Ye),i=er;i.copy(rr).subtract(r);const s=Math.atan2(n.y,n.x),o=Math.asin(n.z),a=Math.sign(fe(i,rr))*le(i);return He([s,o,a],e,Vt._cartographicRadians?Ge:Jt)}eastNorthUpToFixedFrame(t,e=new ve){return Qe(this,"east","north","up",t,e)}localFrameToFixedFrame(t,e,r,n,i=new ve){return Qe(this,t,e,r,n,i)}geocentricSurfaceNormal(t,e=[0,0,0]){return Ze.from(t).normalize().to(e)}geodeticSurfaceNormalCartographic(t,e=[0,0,0]){const r=function(t,e=Ue){return Ne(t,e,Vt._cartographicRadians?Ge:Yt)}(t),n=r[0],i=r[1],s=Math.cos(i);return Ze.set(s*Math.cos(n),s*Math.sin(n),Math.sin(i)).normalize(),Ze.to(e)}geodeticSurfaceNormal(t,e=[0,0,0]){return Ze.from(t).scale(this.oneOverRadiiSquared).normalize().to(e)}scaleToGeodeticSurface(t,e){return function(t,e,r=new be){const{oneOverRadii:n,oneOverRadiiSquared:i,centerToleranceSquared:s}=e;ke.from(t);const o=t.x,a=t.y,c=t.z,u=n.x,l=n.y,h=n.z,f=o*o*u*u,d=a*a*l*l,_=c*c*h*h,m=f+d+_,p=Math.sqrt(1/m);if(!Number.isFinite(p))return;const g=Fe;if(g.copy(t).scale(p),m<s)return g.to(r);const S=i.x,y=i.y,E=i.z,b=Xe;b.set(g.x*S*2,g.y*y*2,g.z*E*2);let R,w,A,T,C=(1-p)*t.len()/(.5*b.len()),M=0;do{C-=M,R=1/(1+C*S),w=1/(1+C*y),A=1/(1+C*E);const t=R*R,e=w*w,r=A*A;T=f*t+d*e+_*r-1;M=T/(-2*(f*(t*R)*S+d*(e*w)*y+_*(r*A)*E))}while(Math.abs(T)>Be);return ke.scale([R,w,A]).to(r)}(t,this,e)}scaleToGeocentricSurface(t,e=[0,0,0]){tr.from(t);const r=tr.x,n=tr.y,i=tr.z,s=this.oneOverRadiiSquared,o=1/Math.sqrt(r*r*s.x+n*n*s.y+i*i*s.z);return tr.multiplyScalar(o).to(e)}transformPositionToScaledSpace(t,e=[0,0,0]){return tr.from(t).scale(this.oneOverRadii).to(e)}transformPositionFromScaledSpace(t,e=[0,0,0]){return tr.from(t).scale(this.radii).to(e)}getSurfaceNormalIntersectionWithZAxis(t,e=0,r=[0,0,0]){Kt(te(this.radii.x,this.radii.y,Le)),Kt(this.radii.z>0),tr.from(t);const n=tr.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(n)>=this.radii.z-e))return tr.set(0,0,n).to(r)}}const{_parseImageNode:sr}=globalThis,or="undefined"!=typeof Image,ar="undefined"!=typeof ImageBitmap,cr=Boolean(sr),ur=!!Ct.a||cr;function lr(t){const e=fr(t);if(!e)throw new Error("Not an image");return e}function hr(t){switch(lr(t)){case"data":return t;case"image":case"imagebitmap":const e=document.createElement("canvas"),r=e.getContext("2d");if(!r)throw new Error("getImageData");return e.width=t.width,e.height=t.height,r.drawImage(t,0,0),r.getImageData(0,0,t.width,t.height);default:throw new Error("getImageData")}}function fr(t){return"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?"imagebitmap":"undefined"!=typeof Image&&t instanceof Image?"image":t&&"object"==typeof t&&t.data&&t.width&&t.height?"data":null}const dr=/^data:image\/svg\+xml/,_r=/\.svg((\?|#).*)?$/;function mr(t){return t&&(dr.test(t)||_r.test(t))}function pr(t,e){if(mr(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(t)])}async function gr(t,e,r){const n=function(t,e){if(mr(e)){let e=(new TextDecoder).decode(t);try{"function"==typeof unescape&&"function"==typeof encodeURIComponent&&(e=unescape(encodeURIComponent(e)))}catch(t){throw new Error(t.message)}return"data:image/svg+xml;base64,"+btoa(e)}return pr(t,e)}(t,r),i=self.URL||self.webkitURL,s="string"!=typeof n&&i.createObjectURL(n);try{return await async function(t,e){const r=new Image;if(r.src=t,e.image&&e.image.decode&&r.decode)return await r.decode(),r;return await new Promise((e,n)=>{try{r.onload=()=>e(r),r.onerror=e=>n(new Error(`Could not load image ${t}: ${e}`))}catch(t){n(t)}})}(s||n,e)}finally{s&&i.revokeObjectURL(s)}}const Sr={};let yr=!0;async function Er(t,e,r){let n;if(mr(r)){n=await gr(t,e,r)}else n=pr(t,r);const i=e&&e.imagebitmap;return await async function(t,e=null){!function(t){for(const e in t||Sr)return!1;return!0}(e)&&yr||(e=null);if(e)try{return await createImageBitmap(t,e)}catch(t){console.warn(t),yr=!1}return await createImageBitmap(t)}(n,i)}function br(t){const e=Rr(t);return function(t){const e=Rr(t);if(!(e.byteLength>=24&&2303741511===e.getUint32(0,!1)))return null;return{mimeType:"image/png",width:e.getUint32(16,!1),height:e.getUint32(20,!1)}}(e)||function(t){const e=Rr(t);if(!(e.byteLength>=3&&65496===e.getUint16(0,!1)&&255===e.getUint8(2)))return null;const{tableMarkers:r,sofMarkers:n}=function(){const t=new Set([65499,65476,65484,65501,65534]);for(let e=65504;e<65520;++e)t.add(e);const e=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:t,sofMarkers:e}}();let i=2;for(;i+9<e.byteLength;){const t=e.getUint16(i,!1);if(n.has(t))return{mimeType:"image/jpeg",height:e.getUint16(i+5,!1),width:e.getUint16(i+7,!1)};if(!r.has(t))return null;i+=2,i+=e.getUint16(i,!1)}return null}(e)||function(t){const e=Rr(t);if(!(e.byteLength>=10&&1195984440===e.getUint32(0,!1)))return null;return{mimeType:"image/gif",width:e.getUint16(6,!0),height:e.getUint16(8,!0)}}(e)||function(t){const e=Rr(t);if(!(e.byteLength>=14&&16973===e.getUint16(0,!1)&&e.getUint32(2,!0)===e.byteLength))return null;return{mimeType:"image/bmp",width:e.getUint32(18,!0),height:e.getUint32(22,!0)}}(e)}function Rr(t){if(t instanceof DataView)return t;if(ArrayBuffer.isView(t))return new DataView(t.buffer);if(t instanceof ArrayBuffer)return new DataView(t);throw new Error("toDataView")}const wr={id:"image",module:"images",name:"Images",version:"3.1.0-alpha.3",mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg"],parse:async function(t,e,r){const n=((e=e||{}).image||{}).type||"auto",{url:i}=r||{};let s;switch(function(t){switch(t){case"auto":case"data":return function(){if(ar)return"imagebitmap";if(or)return"image";if(ur)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}();default:return function(t){switch(t){case"auto":return ar||or||ur;case"imagebitmap":return ar;case"image":return or;case"data":return ur;default:throw new Error(`@loaders.gl/images: image ${t} not supported in this environment`)}}(t),t}}(n)){case"imagebitmap":s=await Er(t,e,i);break;case"image":s=await gr(t,e,i);break;case"data":s=await async function(t,e){const{mimeType:r}=br(t)||{},n=globalThis._parseImageNode;return d(n),await n(t,r)}(t);break;default:d(!1)}return"data"===n&&(s=hr(s)),s},tests:[t=>Boolean(br(new DataView(t)))],options:{image:{type:"auto",decode:!0}}},Ar={name:"Draco",id:"draco",module:"draco",shapes:["mesh"],version:"3.1.0-alpha.3",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}}};function Tr(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}class Cr{constructor(t,e){Tr(this,"fields",void 0),Tr(this,"metadata",void 0),function(t,e){if(!t)throw new Error(e||"loader assertion failed.")}(Array.isArray(t)),function(t){const e={};for(const r of t)e[r.name]&&console.warn("Schema: duplicated field name",r.name,r),e[r.name]=!0}(t),this.fields=t,this.metadata=e||new Map}compareTo(t){if(this.metadata!==t.metadata)return!1;if(this.fields.length!==t.fields.length)return!1;for(let e=0;e<this.fields.length;++e)if(!this.fields[e].compareTo(t.fields[e]))return!1;return!0}select(...t){const e=Object.create(null);for(const r of t)e[r]=!0;const r=this.fields.filter(t=>e[t.name]);return new Cr(r,this.metadata)}selectAt(...t){const e=t.map(t=>this.fields[t]).filter(Boolean);return new Cr(e,this.metadata)}assign(t){let e,r=this.metadata;if(t instanceof Cr){const n=t;e=n.fields,r=Mr(Mr(new Map,this.metadata),n.metadata)}else e=t;const n=Object.create(null);for(const t of this.fields)n[t.name]=t;for(const t of e)n[t.name]=t;const i=Object.values(n);return new Cr(i,r)}}function Mr(t,e){return new Map([...t||new Map,...e||new Map])}function Pr(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}class xr{constructor(t,e,r=!1,n=new Map){Pr(this,"name",void 0),Pr(this,"type",void 0),Pr(this,"nullable",void 0),Pr(this,"metadata",void 0),this.name=t,this.type=e,this.nullable=r,this.metadata=n}get typeId(){return this.type&&this.type.typeId}clone(){return new xr(this.name,this.type,this.nullable,this.metadata)}compareTo(t){return this.name===t.name&&this.type===t.type&&this.nullable===t.nullable&&this.metadata===t.metadata}toString(){return`${this.type}${this.nullable?", nullable":""}${this.metadata?", metadata: "+this.metadata:""}`}}let Or,Dr,vr,Ir,Br,Lr,Gr,Ur,Nr;function Hr(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}!function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.Float=3]="Float",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct=13]="Struct",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Dictionary=-1]="Dictionary",t[t.Int8=-2]="Int8",t[t.Int16=-3]="Int16",t[t.Int32=-4]="Int32",t[t.Int64=-5]="Int64",t[t.Uint8=-6]="Uint8",t[t.Uint16=-7]="Uint16",t[t.Uint32=-8]="Uint32",t[t.Uint64=-9]="Uint64",t[t.Float16=-10]="Float16",t[t.Float32=-11]="Float32",t[t.Float64=-12]="Float64",t[t.DateDay=-13]="DateDay",t[t.DateMillisecond=-14]="DateMillisecond",t[t.TimestampSecond=-15]="TimestampSecond",t[t.TimestampMillisecond=-16]="TimestampMillisecond",t[t.TimestampMicrosecond=-17]="TimestampMicrosecond",t[t.TimestampNanosecond=-18]="TimestampNanosecond",t[t.TimeSecond=-19]="TimeSecond",t[t.TimeMillisecond=-20]="TimeMillisecond",t[t.TimeMicrosecond=-21]="TimeMicrosecond",t[t.TimeNanosecond=-22]="TimeNanosecond",t[t.DenseUnion=-23]="DenseUnion",t[t.SparseUnion=-24]="SparseUnion",t[t.IntervalDayTime=-25]="IntervalDayTime",t[t.IntervalYearMonth=-26]="IntervalYearMonth"}(Or||(Or={}));class kr{static isNull(t){return t&&t.typeId===Or.Null}static isInt(t){return t&&t.typeId===Or.Int}static isFloat(t){return t&&t.typeId===Or.Float}static isBinary(t){return t&&t.typeId===Or.Binary}static isUtf8(t){return t&&t.typeId===Or.Utf8}static isBool(t){return t&&t.typeId===Or.Bool}static isDecimal(t){return t&&t.typeId===Or.Decimal}static isDate(t){return t&&t.typeId===Or.Date}static isTime(t){return t&&t.typeId===Or.Time}static isTimestamp(t){return t&&t.typeId===Or.Timestamp}static isInterval(t){return t&&t.typeId===Or.Interval}static isList(t){return t&&t.typeId===Or.List}static isStruct(t){return t&&t.typeId===Or.Struct}static isUnion(t){return t&&t.typeId===Or.Union}static isFixedSizeBinary(t){return t&&t.typeId===Or.FixedSizeBinary}static isFixedSizeList(t){return t&&t.typeId===Or.FixedSizeList}static isMap(t){return t&&t.typeId===Or.Map}static isDictionary(t){return t&&t.typeId===Or.Dictionary}get typeId(){return Or.NONE}compareTo(t){return this===t}}Symbol.toStringTag;Symbol.toStringTag;Dr=Symbol.toStringTag;class Fr extends kr{constructor(t,e){super(),Hr(this,"isSigned",void 0),Hr(this,"bitWidth",void 0),this.isSigned=t,this.bitWidth=e}get typeId(){return Or.Int}get[Dr](){return"Int"}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}class Xr extends Fr{constructor(){super(!0,8)}}class zr extends Fr{constructor(){super(!0,16)}}class jr extends Fr{constructor(){super(!0,32)}}class Kr extends Fr{constructor(){super(!1,8)}}class Wr extends Fr{constructor(){super(!1,16)}}class qr extends Fr{constructor(){super(!1,32)}}const Vr=32,$r=64;vr=Symbol.toStringTag;class Qr extends kr{constructor(t){super(),Hr(this,"precision",void 0),this.precision=t}get typeId(){return Or.Float}get[vr](){return"Float"}toString(){return"Float"+this.precision}}class Zr extends Qr{constructor(){super(Vr)}}class Yr extends Qr{constructor(){super($r)}}Symbol.toStringTag;Symbol.toStringTag;Ir=Symbol.toStringTag;Br=Symbol.toStringTag;Lr=Symbol.toStringTag;Gr=Symbol.toStringTag;Ur=Symbol.toStringTag;class Jr extends kr{constructor(t,e){super(),Hr(this,"listSize",void 0),Hr(this,"children",void 0),this.listSize=t,this.children=[e]}get typeId(){return Or.FixedSizeList}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get[Ur](){return"FixedSizeList"}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}Nr=Symbol.toStringTag;function tn(t,e,r){const n=function(t){switch(t.constructor){case Int8Array:return new Xr;case Uint8Array:return new Kr;case Int16Array:return new zr;case Uint16Array:return new Wr;case Int32Array:return new jr;case Uint32Array:return new qr;case Float32Array:return new Zr;case Float64Array:return new Yr;default:throw new Error("array type not supported")}}(e.value),i=r||function(t){const e=new Map;"byteOffset"in t&&e.set("byteOffset",t.byteOffset.toString(10));"byteStride"in t&&e.set("byteStride",t.byteStride.toString(10));"normalized"in t&&e.set("normalized",t.normalized.toString());return e}(e);return new xr(t,new Jr(e.size,new xr("value",n)),!1,i)}function en(t,e,r){return tn(t,e,r?rn(r.metadata):void 0)}function rn(t){const e=new Map;for(const r in t)e.set(r+".string",JSON.stringify(t[r]));return e}function nn(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}const sn={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},on={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array};class an{constructor(t){nn(this,"draco",void 0),nn(this,"decoder",void 0),nn(this,"metadataQuerier",void 0),this.draco=t,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(t,e={}){const r=new this.draco.DecoderBuffer;r.Init(new Int8Array(t),t.byteLength),this._disableAttributeTransforms(e);const n=this.decoder.GetEncodedGeometryType(r),i=n===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let t;switch(n){case this.draco.TRIANGULAR_MESH:t=this.decoder.DecodeBufferToMesh(r,i);break;case this.draco.POINT_CLOUD:t=this.decoder.DecodeBufferToPointCloud(r,i);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!t.ok()||!i.ptr){const e="DRACO decompression failed: "+t.error_msg();throw new Error(e)}const s=this._getDracoLoaderData(i,n,e),o=this._getMeshData(i,s,e),a=function(t){let e=1/0,r=1/0,n=1/0,i=-1/0,s=-1/0,o=-1/0;const a=t.POSITION?t.POSITION.value:[],c=a&&a.length;for(let t=0;t<c;t+=3){const c=a[t],u=a[t+1],l=a[t+2];e=c<e?c:e,r=u<r?u:r,n=l<n?l:n,i=c>i?c:i,s=u>s?u:s,o=l>o?l:o}return[[e,r,n],[i,s,o]]}(o.attributes),c=function(t,e,r){const n=rn(e.metadata),i=[],s=function(t){const e={};for(const r in t){const n=t[r];e[n.name||"undefined"]=n}return e}(e.attributes);for(const e in t){const r=en(e,t[e],s[e]);i.push(r)}if(r){const t=en("indices",r);i.push(t)}return new Cr(i,n)}(o.attributes,s,o.indices);return{loader:"draco",loaderData:s,header:{vertexCount:i.num_points(),boundingBox:a},...o,schema:c}}finally{this.draco.destroy(r),i&&this.draco.destroy(i)}}_getDracoLoaderData(t,e,r){const n=this._getTopLevelMetadata(t),i=this._getDracoAttributes(t,r);return{geometry_type:e,num_attributes:t.num_attributes(),num_points:t.num_points(),num_faces:t instanceof this.draco.Mesh?t.num_faces():0,metadata:n,attributes:i}}_getDracoAttributes(t,e){const r={};for(let n=0;n<t.num_attributes();n++){const i=this.decoder.GetAttribute(t,n),s=this._getAttributeMetadata(t,n);r[i.unique_id()]={unique_id:i.unique_id(),attribute_type:i.attribute_type(),data_type:i.data_type(),num_components:i.num_components(),byte_offset:i.byte_offset(),byte_stride:i.byte_stride(),normalized:i.normalized(),attribute_index:n,metadata:s};const o=this._getQuantizationTransform(i,e);o&&(r[i.unique_id()].quantization_transform=o);const a=this._getOctahedronTransform(i,e);a&&(r[i.unique_id()].octahedron_transform=a)}return r}_getMeshData(t,e,r){const n=this._getMeshAttributes(e,t,r);if(!n.POSITION)throw new Error("DRACO: No position attribute found.");if(t instanceof this.draco.Mesh)switch(r.topology){case"triangle-strip":return{topology:"triangle-strip",mode:4,attributes:n,indices:{value:this._getTriangleStripIndices(t),size:1}};case"triangle-list":default:return{topology:"triangle-list",mode:5,attributes:n,indices:{value:this._getTriangleListIndices(t),size:1}}}return{topology:"point-list",mode:0,attributes:n}}_getMeshAttributes(t,e,r){const n={};for(const i of Object.values(t.attributes)){const t=this._deduceAttributeName(i,r);i.name=t;const{value:s,size:o}=this._getAttributeValues(e,i);n[t]={value:s,size:o,byteOffset:i.byte_offset,byteStride:i.byte_stride,normalized:i.normalized}}return n}_getTriangleListIndices(t){const e=3*t.num_faces(),r=4*e,n=this.draco._malloc(r);try{return this.decoder.GetTrianglesUInt32Array(t,r,n),new Uint32Array(this.draco.HEAPF32.buffer,n,e).slice()}finally{this.draco._free(n)}}_getTriangleStripIndices(t){const e=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(t,e),function(t){const e=t.size(),r=new Int32Array(e);for(let n=0;n<e;n++)r[n]=t.GetValue(n);return r}(e)}finally{this.draco.destroy(e)}}_getAttributeValues(t,e){const r=on[e.data_type],n=e.num_components,i=t.num_points()*n,s=i*r.BYTES_PER_ELEMENT,o=function(t,e){switch(e){case Float32Array:return t.DT_FLOAT32;case Int8Array:return t.DT_INT8;case Int16Array:return t.DT_INT16;case Int32Array:return t.DT_INT32;case Uint8Array:return t.DT_UINT8;case Uint16Array:return t.DT_UINT16;case Uint32Array:return t.DT_UINT32;default:return t.DT_INVALID}}(this.draco,r);let a;const c=this.draco._malloc(s);try{const n=this.decoder.GetAttribute(t,e.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(t,n,o,s,c),a=new r(this.draco.HEAPF32.buffer,c,i).slice()}finally{this.draco._free(c)}return{value:a,size:n}}_deduceAttributeName(t,e){const r=t.unique_id;for(const[t,n]of Object.entries(e.extraAttributes||{}))if(n===r)return t;const n=t.attribute_type;for(const t in sn){if(this.draco[t]===n)return sn[t]}const i=e.attributeNameEntry||"name";return t.metadata[i]?t.metadata[i].string:"CUSTOM_ATTRIBUTE_"+r}_getTopLevelMetadata(t){const e=this.decoder.GetMetadata(t);return this._getDracoMetadata(e)}_getAttributeMetadata(t,e){const r=this.decoder.GetAttributeMetadata(t,e);return this._getDracoMetadata(r)}_getDracoMetadata(t){if(!t||!t.ptr)return{};const e={},r=this.metadataQuerier.NumEntries(t);for(let n=0;n<r;n++){const r=this.metadataQuerier.GetEntryName(t,n);e[r]=this._getDracoMetadataField(t,r)}return e}_getDracoMetadataField(t,e){const r=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(t,e,r);const n=function(t){const e=t.size(),r=new Int32Array(e);for(let n=0;n<e;n++)r[n]=t.GetValue(n);return r}(r);return{int:this.metadataQuerier.GetIntEntry(t,e),string:this.metadataQuerier.GetStringEntry(t,e),double:this.metadataQuerier.GetDoubleEntry(t,e),intArray:n}}finally{this.draco.destroy(r)}}_disableAttributeTransforms(t){const{quantizedAttributes:e=[],octahedronAttributes:r=[]}=t,n=[...e,...r];for(const t of n)this.decoder.SkipAttributeTransform(this.draco[t])}_getQuantizationTransform(t,e){const{quantizedAttributes:r=[]}=e,n=t.attribute_type();if(r.map(t=>this.decoder[t]).includes(n)){const e=new this.draco.AttributeQuantizationTransform;try{if(e.InitFromAttribute(t))return{quantization_bits:e.quantization_bits(),range:e.range(),min_values:new Float32Array([1,2,3]).map(t=>e.min_value(t))}}finally{this.draco.destroy(e)}}return null}_getOctahedronTransform(t,e){const{octahedronAttributes:r=[]}=e,n=t.attribute_type();if(r.map(t=>this.decoder[t]).includes(n)){const e=new this.draco.AttributeQuantizationTransform;try{if(e.InitFromAttribute(t))return{quantization_bits:e.quantization_bits()}}finally{this.draco.destroy(e)}}return null}}var cn=r(5);const un={};async function ln(t,e=null,r={}){return e&&(t=function(t,e,r){if(t.startsWith("http"))return t;const n=r.modules||{};if(n[t])return n[t];if(!st.b)return`modules/${e}/dist/libs/${t}`;if(r.CDN)return it(r.CDN.startsWith("http")),`${r.CDN}/${e}@3.1.0-alpha.3/dist/libs/${t}`;if(st.d)return"../src/libs/"+t;return`modules/${e}/src/libs/${t}`}(t,e,r)),un[t]=un[t]||async function(t){if(t.endsWith("wasm")){const e=await fetch(t);return await e.arrayBuffer()}if(!st.b)return cn.requireFromFile&&await cn.requireFromFile(t);if(st.d)return importScripts(t);const e=await fetch(t);return function(t,e){if(!st.b)return cn.requireFromString&&cn.requireFromString(t,e);if(st.d)return eval.call(st.a,t),null;const r=document.createElement("script");r.id=e;try{r.appendChild(document.createTextNode(t))}catch(e){r.text=t}return document.body.appendChild(r),null}(await e.text(),t)}(t),await un[t]}let hn;async function fn(t){const e=t.modules||{};return hn=e.draco3d?hn||e.draco3d.createDecoderModule({}).then(t=>({draco:t})):hn||async function(t){let e,r;switch(t.draco&&t.draco.decoderType){case"js":e=await ln("https://www.gstatic.com/draco/versioned/decoders/1.4.1/draco_decoder.js","draco",t);break;case"wasm":default:[e,r]=await Promise.all([await ln("https://www.gstatic.com/draco/versioned/decoders/1.4.1/draco_wasm_wrapper.js","draco",t),await ln("https://www.gstatic.com/draco/versioned/decoders/1.4.1/draco_decoder.wasm","draco",t)])}return e=e||globalThis.DracoDecoderModule,await function(t,e){const r={};e&&(r.wasmBinary=e);return new Promise(e=>{t({...r,onModuleLoaded:t=>e({draco:t})})})}(e,r)}(t),await hn}const dn={...Ar,parse:async function(t,e){const{draco:r}=await fn(e),n=new an(r);try{return n.parseSync(t,null==e?void 0:e.draco)}finally{n.destroy()}}};new Uint8Array([0]);const _n=[171,75,84,88,32,50,48,187,13,10,26,10];var mn,pn,gn,Sn,yn,En,bn,Rn,wn;(wn=mn||(mn={}))[wn.NONE=0]="NONE",wn[wn.BASISLZ=1]="BASISLZ",wn[wn.ZSTD=2]="ZSTD",wn[wn.ZLIB=3]="ZLIB",function(t){t[t.BASICFORMAT=0]="BASICFORMAT"}(pn||(pn={})),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.ETC1S=163]="ETC1S",t[t.UASTC=166]="UASTC"}(gn||(gn={})),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.SRGB=1]="SRGB"}(Sn||(Sn={})),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.LINEAR=1]="LINEAR",t[t.SRGB=2]="SRGB",t[t.ITU=3]="ITU",t[t.NTSC=4]="NTSC",t[t.SLOG=5]="SLOG",t[t.SLOG2=6]="SLOG2"}(yn||(yn={})),function(t){t[t.ALPHA_STRAIGHT=0]="ALPHA_STRAIGHT",t[t.ALPHA_PREMULTIPLIED=1]="ALPHA_PREMULTIPLIED"}(En||(En={})),function(t){t[t.RGB=0]="RGB",t[t.RRR=3]="RRR",t[t.GGG=4]="GGG",t[t.AAA=15]="AAA"}(bn||(bn={})),function(t){t[t.RGB=0]="RGB",t[t.RGBA=3]="RGBA",t[t.RRR=4]="RRR",t[t.RRRG=5]="RRRG"}(Rn||(Rn={}));class An{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=mn.NONE,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:pn.BASICFORMAT,versionNumber:2,descriptorBlockSize:40,colorModel:gn.UNSPECIFIED,colorPrimaries:Sn.SRGB,transferFunction:Sn.SRGB,flags:En.ALPHA_STRAIGHT,texelBlockDimension:{x:4,y:4,z:1,w:1},bytesPlane:[],samples:[]}],this.keyValue={},this.globalData=null}}class Tn{constructor(t,e,r,n){this._dataView=new DataView(t.buffer,t.byteOffset+e,r),this._littleEndian=n,this._offset=0}_nextUint8(){const t=this._dataView.getUint8(this._offset);return this._offset+=1,t}_nextUint16(){const t=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,t}_nextUint32(){const t=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,t}_nextUint64(){const t=this._dataView.getUint32(this._offset,this._littleEndian)+2**32*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,t}_skip(t){return this._offset+=t,this}_scan(t,e=0){const r=this._offset;let n=0;for(;this._dataView.getUint8(this._offset)!==e&&n<t;)n++,this._offset++;return n<t&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+r,n)}}function Cn(t){return"undefined"!=typeof TextDecoder?(new TextDecoder).decode(t):Buffer.from(t).toString("utf8")}function Mn(t,e){const r=new Array(e.mipMapLevels);let n=e.width,i=e.height,s=0;for(let o=0;o<e.mipMapLevels;++o){const a=xn(e,n,i,t,o),c=Pn(t,o,s,a);r[o]={compressed:!0,format:e.internalFormat,data:c,width:n,height:i,levelSize:a},n=Math.max(1,n>>1),i=Math.max(1,i>>1),s+=a}return r}function Pn(t,e,r,n){return Array.isArray(t)?t[e].levelData:new Uint8Array(t.buffer,t.byteOffset+r,n)}function xn(t,e,r,n,i){return Array.isArray(n)?t.sizeFunction(n[i]):t.sizeFunction(e,r)}const On={COMPRESSED_RGB_S3TC_DXT1_EXT:33776,COMPRESSED_RGBA_S3TC_DXT1_EXT:33777,COMPRESSED_RGBA_S3TC_DXT3_EXT:33778,COMPRESSED_RGBA_S3TC_DXT5_EXT:33779,COMPRESSED_R11_EAC:37488,COMPRESSED_SIGNED_R11_EAC:37489,COMPRESSED_RG11_EAC:37490,COMPRESSED_SIGNED_RG11_EAC:37491,COMPRESSED_RGB8_ETC2:37492,COMPRESSED_RGBA8_ETC2_EAC:37493,COMPRESSED_SRGB8_ETC2:37494,COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:37495,COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:37496,COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:37497,COMPRESSED_RGB_PVRTC_4BPPV1_IMG:35840,COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:35842,COMPRESSED_RGB_PVRTC_2BPPV1_IMG:35841,COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:35843,COMPRESSED_RGB_ETC1_WEBGL:36196,COMPRESSED_RGB_ATC_WEBGL:35986,COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL:35987,COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL:34798,COMPRESSED_RGBA_ASTC_4X4_KHR:37808,COMPRESSED_RGBA_ASTC_5X4_KHR:37809,COMPRESSED_RGBA_ASTC_5X5_KHR:37810,COMPRESSED_RGBA_ASTC_6X5_KHR:37811,COMPRESSED_RGBA_ASTC_6X6_KHR:37812,COMPRESSED_RGBA_ASTC_8X5_KHR:37813,COMPRESSED_RGBA_ASTC_8X6_KHR:37814,COMPRESSED_RGBA_ASTC_8X8_KHR:37815,COMPRESSED_RGBA_ASTC_10X5_KHR:37816,COMPRESSED_RGBA_ASTC_10X6_KHR:37817,COMPRESSED_RGBA_ASTC_10X8_KHR:37818,COMPRESSED_RGBA_ASTC_10X10_KHR:37819,COMPRESSED_RGBA_ASTC_12X10_KHR:37820,COMPRESSED_RGBA_ASTC_12X12_KHR:37821,COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR:37840,COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR:37841,COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR:37842,COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR:37843,COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR:37844,COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR:37845,COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR:37846,COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR:37847,COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR:37848,COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR:37849,COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR:37850,COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR:37851,COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR:37852,COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR:37853,COMPRESSED_RED_RGTC1_EXT:36283,COMPRESSED_SIGNED_RED_RGTC1_EXT:36284,COMPRESSED_RED_GREEN_RGTC2_EXT:36285,COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT:36286,COMPRESSED_SRGB_S3TC_DXT1_EXT:35916,COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:35917,COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:35918,COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:35919},Dn={131:On.COMPRESSED_RGB_S3TC_DXT1_EXT,132:On.COMPRESSED_SRGB_S3TC_DXT1_EXT,133:On.COMPRESSED_RGBA_S3TC_DXT1_EXT,134:On.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,135:On.COMPRESSED_RGBA_S3TC_DXT3_EXT,136:On.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,137:On.COMPRESSED_RGBA_S3TC_DXT5_EXT,138:On.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,139:On.COMPRESSED_RED_RGTC1_EXT,140:On.COMPRESSED_SIGNED_RED_RGTC1_EXT,141:On.COMPRESSED_RED_GREEN_RGTC2_EXT,142:On.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,147:On.COMPRESSED_RGB8_ETC2,148:On.COMPRESSED_SRGB8_ETC2,149:On.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,150:On.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,151:On.COMPRESSED_RGBA8_ETC2_EAC,152:On.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,153:On.COMPRESSED_R11_EAC,154:On.COMPRESSED_SIGNED_R11_EAC,155:On.COMPRESSED_RG11_EAC,156:On.COMPRESSED_SIGNED_RG11_EAC,157:On.COMPRESSED_RGBA_ASTC_4x4_KHR,158:On.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,159:On.COMPRESSED_RGBA_ASTC_5x4_KHR,160:On.COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR,161:On.COMPRESSED_RGBA_ASTC_5x5_KHR,162:On.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,163:On.COMPRESSED_RGBA_ASTC_6x5_KHR,164:On.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,165:On.COMPRESSED_RGBA_ASTC_6x6_KHR,166:On.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,167:On.COMPRESSED_RGBA_ASTC_8x5_KHR,168:On.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,169:On.COMPRESSED_RGBA_ASTC_8x6_KHR,170:On.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,171:On.COMPRESSED_RGBA_ASTC_8x8_KHR,172:On.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,173:On.COMPRESSED_RGBA_ASTC_10x5_KHR,174:On.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,175:On.COMPRESSED_RGBA_ASTC_10x6_KHR,176:On.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,177:On.COMPRESSED_RGBA_ASTC_10x8_KHR,178:On.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,179:On.COMPRESSED_RGBA_ASTC_10x10_KHR,180:On.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,181:On.COMPRESSED_RGBA_ASTC_12x10_KHR,182:On.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,183:On.COMPRESSED_RGBA_ASTC_12x12_KHR,184:On.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,1000054e3:On.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,1000054001:On.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,1000066e3:On.COMPRESSED_RGBA_ASTC_4x4_KHR,1000066001:On.COMPRESSED_RGBA_ASTC_5x4_KHR,1000066002:On.COMPRESSED_RGBA_ASTC_5x5_KHR,1000066003:On.COMPRESSED_RGBA_ASTC_6x5_KHR,1000066004:On.COMPRESSED_RGBA_ASTC_6x6_KHR,1000066005:On.COMPRESSED_RGBA_ASTC_8x5_KHR,1000066006:On.COMPRESSED_RGBA_ASTC_8x6_KHR,1000066007:On.COMPRESSED_RGBA_ASTC_8x8_KHR,1000066008:On.COMPRESSED_RGBA_ASTC_10x5_KHR,1000066009:On.COMPRESSED_RGBA_ASTC_10x6_KHR,1000066010:On.COMPRESSED_RGBA_ASTC_10x8_KHR,1000066011:On.COMPRESSED_RGBA_ASTC_10x10_KHR,1000066012:On.COMPRESSED_RGBA_ASTC_12x10_KHR,1000066013:On.COMPRESSED_RGBA_ASTC_12x12_KHR};const vn=[171,75,84,88,32,50,48,187,13,10,26,10];function In(t){const e=function(t){const e=new Uint8Array(t.buffer,t.byteOffset,_n.length);if(e[0]!==_n[0]||e[1]!==_n[1]||e[2]!==_n[2]||e[3]!==_n[3]||e[4]!==_n[4]||e[5]!==_n[5]||e[6]!==_n[6]||e[7]!==_n[7]||e[8]!==_n[8]||e[9]!==_n[9]||e[10]!==_n[10]||e[11]!==_n[11])throw new Error("Missing KTX 2.0 identifier.");const r=new An,n=17*Uint32Array.BYTES_PER_ELEMENT,i=new Tn(t,_n.length,n,!0);r.vkFormat=i._nextUint32(),r.typeSize=i._nextUint32(),r.pixelWidth=i._nextUint32(),r.pixelHeight=i._nextUint32(),r.pixelDepth=i._nextUint32(),r.layerCount=i._nextUint32(),r.faceCount=i._nextUint32();const s=i._nextUint32();r.supercompressionScheme=i._nextUint32();const o=i._nextUint32(),a=i._nextUint32(),c=i._nextUint32(),u=i._nextUint32(),l=i._nextUint64(),h=i._nextUint64(),f=new Tn(t,_n.length+n,3*s*8,!0);for(let e=0;e<s;e++)r.levels.push({levelData:new Uint8Array(t.buffer,t.byteOffset+f._nextUint64(),f._nextUint64()),uncompressedByteLength:f._nextUint64()});const d=new Tn(t,o,a,!0),_={vendorId:d._skip(4)._nextUint16(),descriptorType:d._nextUint16(),versionNumber:d._nextUint16(),descriptorBlockSize:d._nextUint16(),colorModel:d._nextUint8(),colorPrimaries:d._nextUint8(),transferFunction:d._nextUint8(),flags:d._nextUint8(),texelBlockDimension:{x:d._nextUint8()+1,y:d._nextUint8()+1,z:d._nextUint8()+1,w:d._nextUint8()+1},bytesPlane:[d._nextUint8(),d._nextUint8(),d._nextUint8(),d._nextUint8(),d._nextUint8(),d._nextUint8(),d._nextUint8(),d._nextUint8()],samples:[]},m=(_.descriptorBlockSize/4-6)/4;for(let t=0;t<m;t++)_.samples[t]={bitOffset:d._nextUint16(),bitLength:d._nextUint8(),channelID:d._nextUint8(),samplePosition:[d._nextUint8(),d._nextUint8(),d._nextUint8(),d._nextUint8()],sampleLower:d._nextUint32(),sampleUpper:d._nextUint32()};r.dataFormatDescriptor.length=0,r.dataFormatDescriptor.push(_);const p=new Tn(t,c,u,!0);for(;p._offset<u;){const t=p._nextUint32(),e=p._scan(t),n=Cn(e),i=p._scan(t-e.byteLength);r.keyValue[n]=n.match(/^ktx/i)?Cn(i):i,t%4&&p._skip(4-t%4)}if(h<=0)return r;const g=new Tn(t,l,h,!0),S=g._nextUint16(),y=g._nextUint16(),E=g._nextUint32(),b=g._nextUint32(),R=g._nextUint32(),w=g._nextUint32(),A=[];for(let t=0;t<s;t++)A.push({imageFlags:g._nextUint32(),rgbSliceByteOffset:g._nextUint32(),rgbSliceByteLength:g._nextUint32(),alphaSliceByteOffset:g._nextUint32(),alphaSliceByteLength:g._nextUint32()});const T=l+g._offset,C=T+E,M=C+b,P=M+R,x=new Uint8Array(t.buffer,t.byteOffset+T,E),O=new Uint8Array(t.buffer,t.byteOffset+C,b),D=new Uint8Array(t.buffer,t.byteOffset+M,R),v=new Uint8Array(t.buffer,t.byteOffset+P,w);return r.globalData={endpointCount:S,selectorCount:y,imageDescs:A,endpointsData:x,selectorsData:O,tablesData:D,extendedData:v},r}(new Uint8Array(t)),r=Math.max(1,e.levels.length),n=e.pixelWidth,i=e.pixelHeight,s=(o=e.vkFormat,Dn[o]);var o;return Mn(e.levels,{mipMapLevels:r,width:n,height:i,sizeFunction:t=>t.uncompressedByteLength,internalFormat:s})}const Bn={MAGIC_NUMBER:542327876,HEADER_LENGTH:31,MAGIC_NUMBER_INDEX:0,HEADER_SIZE_INDEX:1,HEADER_FLAGS_INDEX:2,HEADER_HEIGHT_INDEX:3,HEADER_WIDTH_INDEX:4,MIPMAPCOUNT_INDEX:7,HEADER_PF_FLAGS_INDEX:20,HEADER_PF_FOURCC_INDEX:21,DDSD_MIPMAPCOUNT:131072,DDPF_FOURCC:4,PIXEL_FORMATS:{DXT1:On.COMPRESSED_RGB_S3TC_DXT1_EXT,DXT3:On.COMPRESSED_RGBA_S3TC_DXT3_EXT,DXT5:On.COMPRESSED_RGBA_S3TC_DXT5_EXT,"ATC ":On.COMPRESSED_RGB_ATC_WEBGL,ATCA:On.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL,ATCI:On.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL},SIZE_FUNCTIONS:{DXT1:Gn,DXT3:Un,DXT5:Un,"ATC ":Gn,ATCA:Un,ATCI:Un}};function Ln(t){const e=new Int32Array(t,0,Bn.HEADER_LENGTH),r=e[Bn.HEADER_PF_FOURCC_INDEX];d(Boolean(e[Bn.HEADER_PF_FLAGS_INDEX]&Bn.DDPF_FOURCC),"DDS: Unsupported format, must contain a FourCC code");const n=(i=r,String.fromCharCode(255&i,i>>8&255,i>>16&255,i>>24&255));var i;const s=Bn.PIXEL_FORMATS[n],o=Bn.SIZE_FUNCTIONS[n];d(s&&o,"DDS: Unknown pixel format "+r);let a=1;e[Bn.HEADER_FLAGS_INDEX]&Bn.DDSD_MIPMAPCOUNT&&(a=Math.max(1,e[Bn.MIPMAPCOUNT_INDEX]));const c=e[Bn.HEADER_WIDTH_INDEX],u=e[Bn.HEADER_HEIGHT_INDEX],l=e[Bn.HEADER_SIZE_INDEX]+4;return Mn(new Uint8Array(t,l),{mipMapLevels:a,width:c,height:u,sizeFunction:o,internalFormat:s})}function Gn(t,e){return(t+3>>2)*(e+3>>2)*8}function Un(t,e){return(t+3>>2)*(e+3>>2)*16}const Nn=55727696,Hn=1347834371,kn=13,Fn=52,Xn=0,zn=2,jn=4,Kn=6,Wn=7,qn=11,Vn=12,$n={0:[On.COMPRESSED_RGB_PVRTC_2BPPV1_IMG],1:[On.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG],2:[On.COMPRESSED_RGB_PVRTC_4BPPV1_IMG],3:[On.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG],6:[On.COMPRESSED_RGB_ETC1_WEBGL],7:[On.COMPRESSED_RGB_S3TC_DXT1_EXT],9:[On.COMPRESSED_RGBA_S3TC_DXT3_EXT],11:[On.COMPRESSED_RGBA_S3TC_DXT5_EXT],22:[On.COMPRESSED_RGB8_ETC2],23:[On.COMPRESSED_RGBA8_ETC2_EAC],24:[On.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2],25:[On.COMPRESSED_R11_EAC],26:[On.COMPRESSED_RG11_EAC],27:[On.COMPRESSED_RGBA_ASTC_4X4_KHR,On.COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR],28:[On.COMPRESSED_RGBA_ASTC_5X4_KHR,On.COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR],29:[On.COMPRESSED_RGBA_ASTC_5X5_KHR,On.COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR],30:[On.COMPRESSED_RGBA_ASTC_6X5_KHR,On.COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR],31:[On.COMPRESSED_RGBA_ASTC_6X6_KHR,On.COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR],32:[On.COMPRESSED_RGBA_ASTC_8X5_KHR,On.COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR],33:[On.COMPRESSED_RGBA_ASTC_8X6_KHR,On.COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR],34:[On.COMPRESSED_RGBA_ASTC_8X8_KHR,On.COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR],35:[On.COMPRESSED_RGBA_ASTC_10X5_KHR,On.COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR],36:[On.COMPRESSED_RGBA_ASTC_10X6_KHR,On.COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR],37:[On.COMPRESSED_RGBA_ASTC_10X8_KHR,On.COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR],38:[On.COMPRESSED_RGBA_ASTC_10X10_KHR,On.COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR],39:[On.COMPRESSED_RGBA_ASTC_12X10_KHR,On.COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR],40:[On.COMPRESSED_RGBA_ASTC_12X12_KHR,On.COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR]},Qn={0:Zn,1:Zn,2:Yn,3:Yn,6:Jn,7:Jn,9:ti,11:ti,22:Jn,23:ti,24:Jn,25:Jn,26:ti,27:ti,28:function(t,e){return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16},29:function(t,e){return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16},30:function(t,e){return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16},31:function(t,e){return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16},32:function(t,e){return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16},33:function(t,e){return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16},34:function(t,e){return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16},35:function(t,e){return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16},36:function(t,e){return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16},37:function(t,e){return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16},38:function(t,e){return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16},39:function(t,e){return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16},40:function(t,e){return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16}};function Zn(t,e){return(t=Math.max(t,16))*(e=Math.max(e,8))/4}function Yn(t,e){return(t=Math.max(t,8))*(e=Math.max(e,8))/2}function Jn(t,e){return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8}function ti(t,e){return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16}function ei(t){if(function(t){const e=new Uint8Array(t.buffer||t,t.byteOffset||0,vn.length);return!(e[0]!==vn[0]||e[1]!==vn[1]||e[2]!==vn[2]||e[3]!==vn[3]||e[4]!==vn[4]||e[5]!==vn[5]||e[6]!==vn[6]||e[7]!==vn[7]||e[8]!==vn[8]||e[9]!==vn[9]||e[10]!==vn[10]||e[11]!==vn[11])}(t))return In(t);if(function(t){return new Uint32Array(t,0,Bn.HEADER_LENGTH)[Bn.MAGIC_NUMBER_INDEX]===Bn.MAGIC_NUMBER}(t))return Ln(t);if(function(t){const e=new Uint32Array(t,0,kn)[Xn];return e===Nn||e===Hn}(t))return function(t){const e=new Uint32Array(t,0,kn),r=e[zn],n=e[jn],i=$n[r]||[],s=i.length>1&&n?i[1]:i[0],o=Qn[r],a=e[qn],c=e[Wn],u=e[Kn],l=Fn+e[Vn];return Mn(new Uint8Array(t,l),{mipMapLevels:a,width:c,height:u,sizeFunction:o,internalFormat:s})}(t);throw new Error("Texture container format not recognized")}let ri,ni;async function ii(t){const e=t.modules||{};return e.basis?e.basis:(ri=ri||async function(t){let e=null,r=null;return[e,r]=await Promise.all([await ln("basis_transcoder.js","textures",t),await ln("basis_transcoder.wasm","textures",t)]),e=e||globalThis.BASIS,await function(t,e){const r={};e&&(r.wasmBinary=e);return new Promise(e=>{t(r).then(t=>{const{BasisFile:r,initializeBasis:n}=t;n(),e({BasisFile:r})})})}(e,r)}(t),await ri)}async function si(t){const e=t.modules||{};return e.basisEncoder?e.basisEncoder:(ni=ni||async function(t){let e=null,r=null;return[e,r]=await Promise.all([await ln("basis_encoder.js","textures",t),await ln("basis_encoder.wasm","textures",t)]),e=e||globalThis.BASIS,await function(t,e){const r={};e&&(r.wasmBinary=e);return new Promise(e=>{t(r).then(t=>{const{BasisFile:r,KTX2File:n,initializeBasis:i}=t;i(),e({BasisFile:r,KTX2File:n})})})}(e,r)}(t),await ni)}const oi=["","WEBKIT_","MOZ_"],ai={WEBGL_compressed_texture_s3tc:"dxt",WEBGL_compressed_texture_s3tc_srgb:"dxt-srgb",WEBGL_compressed_texture_etc1:"etc1",WEBGL_compressed_texture_etc:"etc2",WEBGL_compressed_texture_pvrtc:"pvrtc",WEBGL_compressed_texture_atc:"atc",WEBGL_compressed_texture_astc:"astc",EXT_texture_compression_rgtc:"rgtc"};let ci=null;function ui(t){if(!ci){t=t||function(){try{return document.createElement("canvas").getContext("webgl")}catch(t){return null}}()||void 0,ci=new Set;for(const e of oi)for(const r in ai)if(t&&t.getExtension(`${e}${r}`)){const t=ai[r];ci.add(t)}}return ci}const li={etc1:{basisFormat:0,compressed:!0,format:On.COMPRESSED_RGB_ETC1_WEBGL},etc2:{basisFormat:1,compressed:!0},bc1:{basisFormat:2,compressed:!0,format:On.COMPRESSED_RGB_S3TC_DXT1_EXT},bc3:{basisFormat:3,compressed:!0,format:On.COMPRESSED_RGBA_S3TC_DXT5_EXT},bc4:{basisFormat:4,compressed:!0},bc5:{basisFormat:5,compressed:!0},"bc7-m6-opaque-only":{basisFormat:6,compressed:!0},"bc7-m5":{basisFormat:7,compressed:!0},"pvrtc1-4-rgb":{basisFormat:8,compressed:!0,format:On.COMPRESSED_RGB_PVRTC_4BPPV1_IMG},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:On.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG},"astc-4x4":{basisFormat:10,compressed:!0,format:On.COMPRESSED_RGBA_ASTC_4X4_KHR},"atc-rgb":{basisFormat:11,compressed:!0},"atc-rgba-interpolated-alpha":{basisFormat:12,compressed:!0},rgba32:{basisFormat:13,compressed:!1},rgb565:{basisFormat:14,compressed:!1},bgr565:{basisFormat:15,compressed:!1},rgba4444:{basisFormat:16,compressed:!1}};async function hi(t,e){switch(e.basis.module){case"encoder":const r=await si(e);switch(e.basis.decoderFormat){case"ktx2":return function(t,e,r){const n=new t(new Uint8Array(e));try{if(!n.startTranscoding())return null;const t=n.getLevels(),e=[];for(let i=0;i<t;i++){e.push(_i(n,i,r));break}return e}finally{n.close(),n.delete()}}(r.KTX2File,t,e);case"basis":default:return fi(r.BasisFile,t,e)}case"transcoder":default:const{BasisFile:n}=await ii(e);return fi(n,t,e)}}function fi(t,e,r){const n=new t(new Uint8Array(e));try{if(!n.startTranscoding())return null;const t=n.getNumImages(),e=[];for(let i=0;i<t;i++){const t=n.getNumLevels(i),s=[];for(let e=0;e<t;e++)s.push(di(n,i,e,r));e.push(s)}return e}finally{n.close(),n.delete()}}function di(t,e,r,n){const i=t.getImageWidth(e,r),s=t.getImageHeight(e,r),o=t.getHasAlpha(),{compressed:a,format:c,basisFormat:u}=mi(n,o),l=t.getImageTranscodedSizeInBytes(e,r,u),h=new Uint8Array(l);return t.transcodeImage(h,e,r,u,0,0)?{width:i,height:s,data:h,compressed:a,hasAlpha:o,format:c}:null}function _i(t,e,r){const{alphaFlag:n,height:i,width:s}=t.getImageLevelInfo(e,0,0),{compressed:o,format:a,basisFormat:c}=mi(r,n),u=t.getImageTranscodedSizeInBytes(e,0,0,c),l=new Uint8Array(u);return t.transcodeImage(l,e,0,0,c,0,-1,-1)?{width:s,height:i,data:l,compressed:o,alphaFlag:n,format:a}:null}function mi(t,e){let r=t&&t.basis&&t.basis.format;return"auto"===r&&(r=function(){const t=ui();if(t.has("astc"))return"astc-4x4";if(t.has("dxt"))return{alpha:"bc3",noAlpha:"bc1"};if(t.has("pvrtc"))return{alpha:"pvrtc1-4-rgba",noAlpha:"pvrtc1-4-rgb"};if(t.has("etc1"))return"etc1";if(t.has("etc2"))return"etc2";return"rgb565"}()),"object"==typeof r&&(r=e?r.alpha:r.noAlpha),r=r.toLowerCase(),li[r]}const pi={name:"Texture Containers",id:"compressed-texture",module:"textures",version:"3.1.0-alpha.3",worker:!0,extensions:["ktx","ktx2","dds","pvr"],mimeTypes:["image/ktx2","image/ktx","image/vnd-ms.dds","image/x-dds","application/octet-stream"],binary:!0,options:{"compressed-texture":{libraryPath:"libs/",useBasis:!1}}},gi={...pi,parse:async(t,e)=>e["compressed-texture"].useBasis?(e.basis={format:{alpha:"BC3",noAlpha:"BC1"},...e.basis,decoderFormat:"ktx2",module:"encoder"},await hi(t,e)):ei(t)},Si={name:"Basis",id:"basis",module:"textures",version:"3.1.0-alpha.3",worker:!0,extensions:["basis"],mimeTypes:["application/octet-stream"],tests:["sB"],binary:!0,options:{basis:{format:"auto",libraryPath:"libs/",decoderFormat:"basis",module:"transcoder"}}},yi={...Si,parse:hi};function Ei(t,e=null){return e?`${t}?token=${e}`:t}var bi=5121,Ri=5125,wi=5126,Ai=5130;const Ti={UInt8:Uint8Array,UInt16:Uint16Array,UInt32:Uint32Array,Float32:Float32Array,UInt64:Float64Array},Ci={UInt8:bi,UInt16:Ri,Float32:wi,UInt32:Ri,UInt64:Ai},Mi={position:"position",normal:"normal",uv0:"uv0",color:"color",region:"region"},Pi={vertexAttributes:"vertexAttributes",featureAttributeOrder:"featureAttributeOrder",featureAttributes:"featureAttributes"},xi="header",Oi="vertexCount",Di="featureCount",vi={UInt8:1,UInt16:2,UInt32:4,Float32:4,UInt64:8},Ii=new be([0,0,0]),Bi={jpeg:wr,png:wr,"ktx-etc2":gi,dds:gi,ktx2:yi};async function Li(t,e,r,n,i){if(e.content=e.content||{},e.content.featureIds=e.content.featureIds||null,e.content.featureData=function(t,e){const r=e.store.defaultGeometrySchema,n=r;for(const t in Pi)for(const e in Mi){const i=r[t][e];if(i){const{byteOffset:r=0,count:s=0,valueType:o,valuesPerElement:a}=i;n[t][e]={valueType:o,valuesPerElement:a,byteOffset:r,count:s}}}return n.attributesOrder=r.ordering,n}(0,r),e.content.attributes={},e.textureUrl){var s;const t=Ei(e.textureUrl,null==n||null===(s=n.i3s)||void 0===s?void 0:s.token),r=Bi[e.textureFormat]||wr,o=await fetch(t),a=await o.arrayBuffer();if(r===wr){const t={...e.textureLoaderOptions,image:{type:"data"}};e.content.texture=await i.parse(a,t)}else if(r===gi||r===yi){const t=await jt(a,r,e.textureLoaderOptions);e.content.texture={compressed:!0,mipmaps:!1,width:t[0].width,height:t[0].height,data:t}}}return e.content.material=function(t,e){let r;t?r={...t,pbrMetallicRoughness:t.pbrMetallicRoughness?{...t.pbrMetallicRoughness}:{baseColorFactor:[255,255,255,255]}}:(r={pbrMetallicRoughness:{}},e?r.pbrMetallicRoughness.baseColorTexture={texCoord:0}:r.pbrMetallicRoughness.baseColorFactor=[255,255,255,255]);r.alphaCutoff=r.alphaCutoff||.25,r.alphaMode&&(r.alphaMode=r.alphaMode.toUpperCase());r.emissiveFactor&&(r.emissiveFactor=Hi(r.emissiveFactor));r.pbrMetallicRoughness&&r.pbrMetallicRoughness.baseColorFactor&&(r.pbrMetallicRoughness.baseColorFactor=Hi(r.pbrMetallicRoughness.baseColorFactor));return function(t,e){const r={source:{image:e}};t.pbrMetallicRoughness&&t.pbrMetallicRoughness.baseColorTexture?t.pbrMetallicRoughness.baseColorTexture={...t.pbrMetallicRoughness.baseColorTexture,texture:r}:t.emissiveTexture?t.emissiveTexture={...t.emissiveTexture,texture:r}:t.pbrMetallicRoughness&&t.pbrMetallicRoughness.metallicRoughnessTexture?t.pbrMetallicRoughness.metallicRoughnessTexture={...t.pbrMetallicRoughness.metallicRoughnessTexture,texture:r}:t.normalTexture?t.normalTexture={...t.normalTexture,texture:r}:t.occlusionTexture&&(t.occlusionTexture={...t.occlusionTexture,texture:r})}(r,e),r}(e.materialDefinition,e.content.texture),e.content.material&&(e.content.texture=null),await async function(t,e={},r){if(!e.content)return e;const n=e.content;let i,s,o=0,a=0;if(e.isDracoGeometry){const e=await zt(t,dn,{draco:{attributeNameEntry:"i3s-attribute-type"}});s=e.header.vertexCount;const r=e.indices.value,{POSITION:n,NORMAL:o,COLOR_0:a,TEXCOORD_0:c,"feature-index":u,"uv-region":l}=e.attributes;i={position:n,normal:o,color:a,uv0:c,uvRegion:l,id:u,indices:r},function(t,e){for(const r in e.loaderData.attributes){const n=e.loaderData.attributes[r];switch(n.name){case"POSITION":t.position.metadata=n.metadata;break;case"feature-index":t.id.metadata=n.metadata}}}(i,e);const h=function(t){return t&&t.metadata&&t.metadata["i3s-feature-ids"]&&t.metadata["i3s-feature-ids"].intArray}(u);h&&function(t,e){const r=t.id.value,n=new Float32Array(r.length);for(let t=0;t<r.length;t++)n[t]=e[r[t]];t.id.value=n}(i,h)}else{const{vertexAttributes:e,attributesOrder:r,featureAttributes:c,featureAttributeOrder:u}=n.featureData,l=function(t,e){let r=0,n=0,i=0;const s=t.featureData[xi];for(const t in s){const{property:o,type:a}=s[t],c=Ti[a];o===Oi&&(n=new c(e,0,4)[0],r+=vi[a]),o===Di&&(i=new c(e,4,4)[0],r+=vi[a])}return{vertexCount:n,featureCount:i,byteOffset:r}}(n,t);o=l.byteOffset,s=l.vertexCount,a=l.featureCount;const{attributes:h,byteOffset:f}=Ui(t,o,e,s,r),{attributes:d}=Ui(t,f,c,a,u);!function(t){const{id:e,faceRange:r}=t;if(!e||!r)return;const n=e.value,i=r.value,s=i[i.length-1]+1,o=new Uint32Array(3*s);let a=0,c=0;for(let t=1;t<i.length;t+=2){const e=Number(n[a]),r=i[t],s=i[t-1],u=c+3*(r-s+1);o.fill(e,c,u),a++,c=u}t.id.value=o}(d),i=function(t,e){return{...t,...e}}(h,d)}const{enuMatrix:c,cartographicOrigin:u,cartesianOrigin:l}=function(t,e){const r=e.mbs,n=t.value,i=t.metadata,s=new ve,o=new be(r[0],r[1],r[2]),a=new be;return ir.WGS84.cartographicToCartesian(o,a),ir.WGS84.eastNorthUpToFixedFrame(a,s),t.value=function(t,e={},r){const n=new Float64Array(t.length),i=e["i3s-scale_x"]&&e["i3s-scale_x"].double||1,s=e["i3s-scale_y"]&&e["i3s-scale_y"].double||1;for(let e=0;e<n.length;e+=3)n[e]=t[e]*i+r.x,n[e+1]=t[e+1]*s+r.y,n[e+2]=t[e+2]+r.z;for(let t=0;t<n.length;t+=3)ir.WGS84.cartographicToCartesian(n.subarray(t,t+3),Ii),n[t]=Ii.x,n[t+1]=Ii.y,n[t+2]=Ii.z;return n}(n,i,o),{enuMatrix:s,fixedFrameToENUMatrix:s.invert(),cartographicOrigin:o,cartesianOrigin:a}}(i.position,e),h=(new ve).multiplyRight(c);n.attributes={positions:i.position,normals:i.normal,colors:Gi(i.color),texCoords:i.uv0,uvRegions:Gi(i.uvRegion)},n.indices=i.indices||null,i.id&&i.id.value&&(e.content.featureIds=i.id.value);for(const t in n.attributes)n.attributes[t]||delete n.attributes[t];return n.vertexCount=s,n.cartographicCenter=u,n.cartesianOrigin=l,n.modelMatrix=h.invert(),n.byteLength=t.byteLength,e}(t,e)}function Gi(t){return t?(t.normalized=!0,t):t}function Ui(t,e,r,n,i){const s={};for(const o of i)if(r[o]){const{valueType:i,valuesPerElement:a}=r[o],c=n;if(e+c*a>t.byteLength)break;const u=t.slice(e);let l=[];if("UInt64"===i)l=Ni(u,c*a,vi[i]);else{l=new(0,Ti[i])(u,0,c*a)}switch(s[o]={value:l,type:Ci[i],size:a},o){case"color":s.color.normalized=!0}e+=c*a*vi[i]}return{attributes:s,byteOffset:e}}function Ni(t,e,r){const n=[],i=new DataView(t);let s=0;for(let t=0;t<e;t++){const t=i.getUint32(s,!0)+2**32*i.getUint32(s+4,!0);n.push(t),s+=r}return n}function Hi(t){const e=[...t];for(let r=0;r<t.length;r++)e[r]=t[r]/255;return e}const ki={name:"I3S Content (Indexed Scene Layers)",id:"i3s-content",module:"i3s",worker:!0,version:"3.1.0-alpha.3",mimeTypes:["application/octet-stream"],parse:async function(t,e,r){const{tile:n,tileset:i}=(null==e?void 0:e.i3s)||{};return await Li(t,n,i,e,r),n.content},extensions:["bin"],options:{"i3s-content":{}}};const Fi=Object.freeze({OUTSIDE:-1,INTERSECTING:0,INSIDE:1});new be,new be;const Xi=new be,zi=new be;class ji{constructor(t=[0,0,0],e=0){this.radius=-0,this.center=new be,this.fromCenterRadius(t,e)}fromCenterRadius(t,e){return this.center.from(t),this.radius=e,this}fromCornerPoints(t,e){return e=Xi.from(e),this.center=(new be).from(t).add(e).scale(.5),this.radius=this.center.distance(e),this}equals(t){return this===t||Boolean(t)&&this.center.equals(t.center)&&this.radius===t.radius}clone(){return new ji(this.center,this.radius)}union(t){const e=this.center,r=this.radius,n=t.center,i=t.radius,s=Xi.copy(n).subtract(e),o=s.magnitude();if(r>=o+i)return this.clone();if(i>=o+r)return t.clone();const a=.5*(r+o+i);return zi.copy(s).scale((-r+a)/o).add(e),this.center.copy(zi),this.radius=a,this}expand(t){const e=(t=Xi.from(t)).subtract(this.center).magnitude();return e>this.radius&&(this.radius=e),this}transform(t){this.center.transform(t);const e=Te(Xi,t);return this.radius=Math.max(e[0],Math.max(e[1],e[2]))*this.radius,this}distanceSquaredTo(t){return(t=Xi.from(t)).subtract(this.center).lengthSquared()-this.radius*this.radius}distanceTo(t){return Math.sqrt(this.distanceSquaredTo(t))}intersectPlane(t){const e=this.center,r=this.radius,n=t.normal.dot(e)+t.distance;return n<-r?Fi.OUTSIDE:n<r?Fi.INTERSECTING:Fi.INSIDE}}function Ki(t,e,r){var n=e[0],i=e[1],s=e[2],o=e[3],a=e[4],c=e[5],u=e[6],l=e[7],h=e[8],f=r[0],d=r[1],_=r[2],m=r[3],p=r[4],g=r[5],S=r[6],y=r[7],E=r[8];return t[0]=f*n+d*o+_*u,t[1]=f*i+d*a+_*l,t[2]=f*s+d*c+_*h,t[3]=m*n+p*o+g*u,t[4]=m*i+p*a+g*l,t[5]=m*s+p*c+g*h,t[6]=S*n+y*o+E*u,t[7]=S*i+y*a+E*l,t[8]=S*s+y*c+E*h,t}function Wi(t,e,r){var n=r[0],i=r[1];return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=i*e[3],t[4]=i*e[4],t[5]=i*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}const qi=Object.freeze([1,0,0,0,1,0,0,0,1]),Vi=Object.freeze([0,0,0,0,0,0,0,0,0]),$i=Object.freeze({COL0ROW0:0,COL0ROW1:1,COL0ROW2:2,COL1ROW0:3,COL1ROW1:4,COL1ROW2:5,COL2ROW0:6,COL2ROW1:7,COL2ROW2:8}),Qi={};class Zi extends Re{static get IDENTITY(){return Qi.IDENTITY=Qi.IDENTITY||Object.freeze(new Zi(qi)),Qi.IDENTITY}static get ZERO(){return Qi.ZERO=Qi.ZERO||Object.freeze(new Zi(Vi)),Qi.ZERO}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return $i}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(t)?this.copy(t):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this.check()}set(t,e,r,n,i,s,o,a,c){return this[0]=t,this[1]=e,this[2]=r,this[3]=n,this[4]=i,this[5]=s,this[6]=o,this[7]=a,this[8]=c,this.check()}setRowMajor(t,e,r,n,i,s,o,a,c){return this[0]=t,this[1]=n,this[2]=o,this[3]=e,this[4]=i,this[5]=a,this[6]=r,this[7]=s,this[8]=c,this.check()}determinant(){return e=(t=this)[0],r=t[1],n=t[2],i=t[3],s=t[4],o=t[5],a=t[6],c=t[7],u=t[8],e*(u*s-o*c)+r*(-u*i+o*a)+n*(c*i-s*a);var t,e,r,n,i,s,o,a,c,u}identity(){return this.copy(qi)}fromQuaternion(t){return function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=r+r,a=n+n,c=i+i,u=r*o,l=n*o,h=n*a,f=i*o,d=i*a,_=i*c,m=s*o,p=s*a,g=s*c;t[0]=1-h-_,t[3]=l-g,t[6]=f+p,t[1]=l+g,t[4]=1-u-_,t[7]=d-m,t[2]=f-p,t[5]=d+m,t[8]=1-u-h}(this,t),this.check()}transpose(){return function(t,e){if(t===e){var r=e[1],n=e[2],i=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=n,t[7]=i}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8]}(this,this),this.check()}invert(){var t,e,r,n,i,s,o,a,c,u,l,h,f,d,_;return t=this,r=(e=this)[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],c=e[6],u=e[7],l=e[8],(_=r*(h=l*o-a*u)+n*(f=-l*s+a*c)+i*(d=u*s-o*c))&&(_=1/_,t[0]=h*_,t[1]=(-l*n+i*u)*_,t[2]=(a*n-i*o)*_,t[3]=f*_,t[4]=(l*r-i*c)*_,t[5]=(-a*r+i*s)*_,t[6]=d*_,t[7]=(-u*r+n*c)*_,t[8]=(o*r-n*s)*_),this.check()}multiplyLeft(t){return Ki(this,t,this),this.check()}multiplyRight(t){return Ki(this,this,t),this.check()}rotate(t){var e,r,n,i,s,o,a,c,u,l,h,f,d,_;return e=this,n=t,i=(r=this)[0],s=r[1],o=r[2],a=r[3],c=r[4],u=r[5],l=r[6],h=r[7],f=r[8],d=Math.sin(n),_=Math.cos(n),e[0]=_*i+d*a,e[1]=_*s+d*c,e[2]=_*o+d*u,e[3]=_*a-d*i,e[4]=_*c-d*s,e[5]=_*u-d*o,e[6]=l,e[7]=h,e[8]=f,this.check()}scale(t){return Array.isArray(t)?Wi(this,this,t):Wi(this,this,[t,t,t]),this.check()}translate(t){var e,r,n,i,s,o,a,c,u,l,h,f,d,_;return e=this,n=t,i=(r=this)[0],s=r[1],o=r[2],a=r[3],c=r[4],u=r[5],l=r[6],h=r[7],f=r[8],d=n[0],_=n[1],e[0]=i,e[1]=s,e[2]=o,e[3]=a,e[4]=c,e[5]=u,e[6]=d*i+_*a+l,e[7]=d*s+_*c+h,e[8]=d*o+_*u+f,this.check()}transform(t,e){switch(t.length){case 2:r=e||[-0,-0],i=this,s=(n=t)[0],o=n[1],r[0]=i[0]*s+i[3]*o+i[6],r[1]=i[1]*s+i[4]*o+i[7],e=r;break;case 3:e=me(e||[-0,-0,-0],t,this);break;case 4:e=function(t,e,r){const n=e[0],i=e[1],s=e[2];return t[0]=r[0]*n+r[3]*i+r[6]*s,t[1]=r[1]*n+r[4]*i+r[7]*s,t[2]=r[2]*n+r[5]*i+r[8]*s,t[3]=e[3],t}(e||[-0,-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}var r,n,i,s,o;return ne(e,t.length),e}transformVector(t,e){return se("Matrix3.transformVector"),this.transform(t,e)}transformVector2(t,e){return se("Matrix3.transformVector"),this.transform(t,e)}transformVector3(t,e){return se("Matrix3.transformVector"),this.transform(t,e)}}function Yi(){var t=new ce(4);return ce!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Ji(t,e,r){r*=.5;var n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t}function ts(t,e,r){var n=e[0],i=e[1],s=e[2],o=e[3],a=r[0],c=r[1],u=r[2],l=r[3];return t[0]=n*l+o*a+i*u-s*c,t[1]=i*l+o*c+s*a-n*u,t[2]=s*l+o*u+n*c-i*a,t[3]=o*l-n*a-i*c-s*u,t}function es(t,e,r,n){var i,s,o,a,c,u=e[0],l=e[1],h=e[2],f=e[3],d=r[0],_=r[1],m=r[2],p=r[3];return(s=u*d+l*_+h*m+f*p)<0&&(s=-s,d=-d,_=-_,m=-m,p=-p),1-s>ae?(i=Math.acos(s),o=Math.sin(i),a=Math.sin((1-n)*i)/o,c=Math.sin(n*i)/o):(a=1-n,c=n),t[0]=a*u+c*d,t[1]=a*l+c*_,t[2]=a*h+c*m,t[3]=a*f+c*p,t}function rs(t,e){var r,n=e[0]+e[4]+e[8];if(n>0)r=Math.sqrt(n+1),t[3]=.5*r,r=.5/r,t[0]=(e[5]-e[7])*r,t[1]=(e[6]-e[2])*r,t[2]=(e[1]-e[3])*r;else{var i=0;e[4]>e[0]&&(i=1),e[8]>e[3*i+i]&&(i=2);var s=(i+1)%3,o=(i+2)%3;r=Math.sqrt(e[3*i+i]-e[3*s+s]-e[3*o+o]+1),t[i]=.5*r,r=.5/r,t[3]=(e[3*s+o]-e[3*o+s])*r,t[s]=(e[3*s+i]+e[3*i+s])*r,t[o]=(e[3*o+i]+e[3*i+o])*r}return t}var ns,is,ss,os,as,cs,us,ls=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t},hs=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t},fs=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},ds=function(t,e,r,n){var i=e[0],s=e[1],o=e[2],a=e[3];return t[0]=i+n*(r[0]-i),t[1]=s+n*(r[1]-s),t[2]=o+n*(r[2]-o),t[3]=a+n*(r[3]-a),t},_s=Ce,ms=Me,ps=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=r*r+n*n+i*i+s*s;return o>0&&(o=1/Math.sqrt(o)),t[0]=r*o,t[1]=n*o,t[2]=i*o,t[3]=s*o,t},gs=(ns=ue(),is=he(1,0,0),ss=he(0,1,0),function(t,e,r){var n=fe(e,r);return n<-.999999?(de(ns,is,e),ge(ns)<1e-6&&de(ns,ss,e),function(t,e){var r=e[0],n=e[1],i=e[2],s=r*r+n*n+i*i;s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s}(ns,ns),Ji(t,ns,Math.PI),t):n>.999999?(t[0]=0,t[1]=0,t[2]=0,t[3]=1,t):(de(ns,e,r),t[0]=ns[0],t[1]=ns[1],t[2]=ns[2],t[3]=1+n,ps(t,t))});os=Yi(),as=Yi(),cs=new ce(9),ce!=Float32Array&&(cs[1]=0,cs[2]=0,cs[3]=0,cs[5]=0,cs[6]=0,cs[7]=0),cs[0]=1,cs[4]=1,cs[8]=1,us=cs;const Ss=[0,0,0,1];class ys extends ee{constructor(t=0,e=0,r=0,n=1){super(-0,-0,-0,-0),Array.isArray(t)&&1===arguments.length?this.copy(t):this.set(t,e,r,n)}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}set(t,e,r,n){return this[0]=t,this[1]=e,this[2]=r,this[3]=n,this.check()}fromMatrix3(t){return rs(this,t),this.check()}identity(){return function(t){t[0]=0,t[1]=0,t[2]=0,t[3]=1}(this),this.check()}fromAxisRotation(t,e){return Ji(this,t,e),this.check()}setAxisAngle(t,e){return this.fromAxisRotation(t,e)}get ELEMENTS(){return 4}get x(){return this[0]}set x(t){this[0]=re(t)}get y(){return this[1]}set y(t){this[1]=re(t)}get z(){return this[2]}set z(t){this[2]=re(t)}get w(){return this[3]}set w(t){this[3]=re(t)}len(){return _s(this)}lengthSquared(){return ms(this)}dot(t,e){if(void 0!==e)throw new Error("Quaternion.dot only takes one argument");return fs(this,t)}rotationTo(t,e){return gs(this,t,e),this.check()}add(t,e){if(void 0!==e)throw new Error("Quaternion.add only takes one argument");return ls(this,this,t),this.check()}calculateW(){return function(t,e){var r=e[0],n=e[1],i=e[2];t[0]=r,t[1]=n,t[2]=i,t[3]=Math.sqrt(Math.abs(1-r*r-n*n-i*i))}(this,this),this.check()}conjugate(){return function(t,e){t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3]}(this,this),this.check()}invert(){return function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=r*r+n*n+i*i+s*s,a=o?1/o:0;t[0]=-r*a,t[1]=-n*a,t[2]=-i*a,t[3]=s*a}(this,this),this.check()}lerp(t,e,r){return ds(this,t,e,r),this.check()}multiplyRight(t,e){return Kt(!e),ts(this,this,t),this.check()}multiplyLeft(t,e){return Kt(!e),ts(this,t,this),this.check()}normalize(){const t=this.len(),e=t>0?1/t:0;return this[0]=this[0]*e,this[1]=this[1]*e,this[2]=this[2]*e,this[3]=this[3]*e,0===t&&(this[3]=1),this.check()}rotateX(t){return function(t,e,r){r*=.5;var n=e[0],i=e[1],s=e[2],o=e[3],a=Math.sin(r),c=Math.cos(r);t[0]=n*c+o*a,t[1]=i*c+s*a,t[2]=s*c-i*a,t[3]=o*c-n*a}(this,this,t),this.check()}rotateY(t){return function(t,e,r){r*=.5;var n=e[0],i=e[1],s=e[2],o=e[3],a=Math.sin(r),c=Math.cos(r);t[0]=n*c-s*a,t[1]=i*c+o*a,t[2]=s*c+n*a,t[3]=o*c-i*a}(this,this,t),this.check()}rotateZ(t){return function(t,e,r){r*=.5;var n=e[0],i=e[1],s=e[2],o=e[3],a=Math.sin(r),c=Math.cos(r);t[0]=n*c+i*a,t[1]=i*c-n*a,t[2]=s*c+o*a,t[3]=o*c-s*a}(this,this,t),this.check()}scale(t){return hs(this,this,t),this.check()}slerp(t,e,r){switch(arguments.length){case 1:({start:t=Ss,target:e,ratio:r}=arguments[0]);break;case 2:[e,r]=arguments,t=this}return es(this,t,e,r),this.check()}transformVector4(t,e=t){return function(t,e,r){var n=e[0],i=e[1],s=e[2],o=r[0],a=r[1],c=r[2],u=r[3],l=u*n+a*s-c*i,h=u*i+c*n-o*s,f=u*s+o*i-a*n,d=-o*n-a*i-c*s;t[0]=l*u+d*-o+h*-c-f*-a,t[1]=h*u+d*-a+f*-o-l*-c,t[2]=f*u+d*-c+l*-a-h*-o,t[3]=e[3]}(e,t,this),ne(e,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(t,e){return this.setAxisAngle(t,e)}premultiply(t,e){return this.multiplyLeft(t,e)}multiply(t,e){return this.multiplyRight(t,e)}}const Es=new be,bs=new be,Rs=new be,ws=new be,As=new be,Ts=new be,Cs=new be,Ms=0,Ps=1,xs=2,Os=3,Ds=4,vs=5,Is=6,Bs=7,Ls=8;class Gs{constructor(t=[0,0,0],e=[0,0,0,0,0,0,0,0,0]){this.center=(new be).from(t),this.halfAxes=new Zi(e)}get halfSize(){const t=this.halfAxes.getColumn(0),e=this.halfAxes.getColumn(1),r=this.halfAxes.getColumn(2);return[new be(t).len(),new be(e).len(),new be(r).len()]}get quaternion(){const t=this.halfAxes.getColumn(0),e=this.halfAxes.getColumn(1),r=this.halfAxes.getColumn(2),n=new be(t).normalize(),i=new be(e).normalize(),s=new be(r).normalize();return(new ys).fromMatrix3(new Zi([...n,...i,...s]))}fromCenterHalfSizeQuaternion(t,e,r){const n=new ys(r),i=(new Zi).fromQuaternion(n);return i[0]=i[0]*e[0],i[1]=i[1]*e[0],i[2]=i[2]*e[0],i[3]=i[3]*e[1],i[4]=i[4]*e[1],i[5]=i[5]*e[1],i[6]=i[6]*e[2],i[7]=i[7]*e[2],i[8]=i[8]*e[2],this.center=(new be).from(t),this.halfAxes=i,this}clone(){return new Gs(this.center,this.halfAxes)}equals(t){return this===t||Boolean(t)&&this.center.equals(t.center)&&this.halfAxes.equals(t.halfAxes)}getBoundingSphere(t=new ji){const e=this.halfAxes,r=e.getColumn(0,Rs),n=e.getColumn(1,ws),i=e.getColumn(2,As),s=Es.copy(r).add(n).add(i);return t.center.copy(this.center),t.radius=s.magnitude(),t}intersectPlane(t){const e=this.center,r=t.normal,n=this.halfAxes,i=r.x,s=r.y,o=r.z,a=Math.abs(i*n[Ms]+s*n[Ps]+o*n[xs])+Math.abs(i*n[Os]+s*n[Ds]+o*n[vs])+Math.abs(i*n[Is]+s*n[Bs]+o*n[Ls]),c=r.dot(e)+t.distance;return c<=-a?Fi.OUTSIDE:c>=a?Fi.INSIDE:Fi.INTERSECTING}distanceTo(t){return Math.sqrt(this.distanceSquaredTo(t))}distanceSquaredTo(t){const e=bs.from(t).subtract(this.center),r=this.halfAxes,n=r.getColumn(0,Rs),i=r.getColumn(1,ws),s=r.getColumn(2,As),o=n.magnitude(),a=i.magnitude(),c=s.magnitude();n.normalize(),i.normalize(),s.normalize();let u,l=0;return u=Math.abs(e.dot(n))-o,u>0&&(l+=u*u),u=Math.abs(e.dot(i))-a,u>0&&(l+=u*u),u=Math.abs(e.dot(s))-c,u>0&&(l+=u*u),l}computePlaneDistances(t,e,r=[-0,-0]){let n=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;const s=this.center,o=this.halfAxes,a=o.getColumn(0,Rs),c=o.getColumn(1,ws),u=o.getColumn(2,As),l=Ts.copy(a).add(c).add(u).add(s),h=Cs.copy(l).subtract(t);let f=e.dot(h);return n=Math.min(f,n),i=Math.max(f,i),l.copy(s).add(a).add(c).subtract(u),h.copy(l).subtract(t),f=e.dot(h),n=Math.min(f,n),i=Math.max(f,i),l.copy(s).add(a).subtract(c).add(u),h.copy(l).subtract(t),f=e.dot(h),n=Math.min(f,n),i=Math.max(f,i),l.copy(s).add(a).subtract(c).subtract(u),h.copy(l).subtract(t),f=e.dot(h),n=Math.min(f,n),i=Math.max(f,i),s.copy(l).subtract(a).add(c).add(u),h.copy(l).subtract(t),f=e.dot(h),n=Math.min(f,n),i=Math.max(f,i),s.copy(l).subtract(a).add(c).subtract(u),h.copy(l).subtract(t),f=e.dot(h),n=Math.min(f,n),i=Math.max(f,i),s.copy(l).subtract(a).subtract(c).add(u),h.copy(l).subtract(t),f=e.dot(h),n=Math.min(f,n),i=Math.max(f,i),s.copy(l).subtract(a).subtract(c).subtract(u),h.copy(l).subtract(t),f=e.dot(h),n=Math.min(f,n),i=Math.max(f,i),r[0]=n,r[1]=i,r}transform(t){this.center.transformAsPoint(t);const e=this.halfAxes.getColumn(0,Rs);e.transformAsPoint(t);const r=this.halfAxes.getColumn(1,ws);r.transformAsPoint(t);const n=this.halfAxes.getColumn(2,As);return n.transformAsPoint(t),this.halfAxes=new Zi([...e,...r,...n]),this}getTransform(){throw new Error("not implemented")}}const Us=new be,Ns=new be;class Hs{constructor(t=[0,0,1],e=0){this.normal=new be,this.distance=-0,this.fromNormalDistance(t,e)}fromNormalDistance(t,e){return Kt(Number.isFinite(e)),this.normal.from(t).normalize(),this.distance=e,this}fromPointNormal(t,e){t=Us.from(t),this.normal.from(e).normalize();const r=-this.normal.dot(t);return this.distance=r,this}fromCoefficients(t,e,r,n){return this.normal.set(t,e,r),Kt(te(this.normal.len(),1)),this.distance=n,this}clone(t){return new Hs(this.normal,this.distance)}equals(t){return te(this.distance,t.distance)&&te(this.normal,t.normal)}getPointDistance(t){return this.normal.dot(t)+this.distance}transform(t){const e=Ns.copy(this.normal).transformAsVector(t).normalize(),r=this.normal.scale(-this.distance).transform(t);return this.fromPointNormal(r,e)}projectPointOntoPlane(t,e=[0,0,0]){t=Us.from(t);const r=this.getPointDistance(t),n=Ns.copy(this.normal).scale(r);return t.subtract(n).to(e)}}new be([1,0,0]),new be([0,1,0]),new be([0,0,1]),new be,new be,new Hs(new be(1,0,0),0);new be,new be,new be,new be,new be;new be,new be,new be,new be,new be,new be,new be,new be,new be,new be,new be,new be,Math.PI;new Zi,new Zi,new Zi,new Zi,new Zi;new be,new be,new be,new be,new be,new Zi,new Zi,new Zi;const ks=2,Fs="mesh",Xs="I3S";async function zs(t){return JSON.parse((new TextDecoder).decode(t))}const js={name:"I3S Node Page",id:"i3s-node-page",module:"i3s",version:"3.1.0-alpha.3",mimeTypes:["application/json"],parse:async function(t){return t=zs(t)},extensions:["json"],options:{}};function Ks(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}class Ws{constructor(t,e){Ks(this,"tileset",void 0),Ks(this,"nodePages",[]),Ks(this,"pendingNodePages",[]),Ks(this,"nodesPerPage",void 0),Ks(this,"options",void 0),Ks(this,"lodSelectionMetricType",void 0),Ks(this,"textureDefinitionsSelectedFormats",[]),this.tileset={...t},this.nodesPerPage=t.nodePages.nodesPerPage,this.lodSelectionMetricType=t.nodePages.lodSelectionMetricType,this.options=e,this._initSelectedFormatsForTextureDefinitions(t)}async getNodeById(t){const e=Math.floor(t/this.nodesPerPage);if(!this.nodePages[e]&&!this.pendingNodePages[e]){var r;const t=Ei(`${this.tileset.url}/nodepages/${e}`,null===(r=this.options.i3s)||void 0===r?void 0:r.token);this.pendingNodePages[e]={status:"Pending",promise:jt(t,js,this.options)},this.nodePages[e]=await this.pendingNodePages[e].promise,this.pendingNodePages[e].status="Done"}"Pending"===this.pendingNodePages[e].status&&(this.nodePages[e]=await this.pendingNodePages[e].promise);const n=t%this.nodesPerPage;return this.nodePages[e].nodes[n]}async formTileFromNodePages(t){const e=await this.getNodeById(t),r=[];for(const t of e.children||[]){const e=await this.getNodeById(t);r.push({id:t,obb:e.obb})}let n=null,i=null,s=null,o="jpeg",a=[],c=!1;if(e&&e.mesh){const{url:t,isDracoGeometry:r}=e.mesh.geometry&&this._getContentUrl(e.mesh.geometry)||{url:null,isDracoGeometry:null};n=t,c=r;const[u,l]=this._getInformationFromMaterial(e.mesh.material);s=l,o=u.format||o,u.name&&(i=`${this.tileset.url}/nodes/${e.mesh.material.resource}/textures/${u.name}`),this.tileset.attributeStorageInfo&&(a=function(t,e){const r=[],{attributeStorageInfo:n,url:i}=t;for(let t=0;t<n.length;t++){const s=n[t].key;r.push(`${i}/nodes/${e}/attributes/${s}/0`)}return r}(this.tileset,e.mesh.attribute.resource))}return qs({id:t,lodSelection:this._getLodSelection(e),obb:e.obb,contentUrl:n,textureUrl:i,attributeUrls:a,materialDefinition:s,textureFormat:o,children:r,isDracoGeometry:c})}_getContentUrl(t){let e={};const r=this.tileset.geometryDefinitions[t.definition];let n=-1;if(this.options.i3s&&this.options.i3s.useDracoGeometry&&(n=r.geometryBuffers.findIndex(t=>t.compressedAttributes&&"draco"===t.compressedAttributes.encoding)),-1===n&&(n=r.geometryBuffers.findIndex(t=>!t.compressedAttributes)),-1!==n){const i=Boolean(r.geometryBuffers[n].compressedAttributes);e={url:`${this.tileset.url}/nodes/${t.resource}/geometries/${n}`,isDracoGeometry:i}}return e}_getLodSelection(t){const e=[];return"maxScreenThresholdSQ"===this.lodSelectionMetricType&&e.push({metricType:"maxScreenThreshold",maxError:Math.sqrt(t.lodThreshold/(.25*Math.PI))}),e.push({metricType:this.lodSelectionMetricType,maxError:t.lodThreshold}),e}_getInformationFromMaterial(t){const e={name:null,format:null};if(t){const r=this.tileset.materialDefinitions[t.definition],n=r&&r.pbrMetallicRoughness&&r.pbrMetallicRoughness.baseColorTexture&&r.pbrMetallicRoughness.baseColorTexture.textureSetDefinitionId;if(n||0===n){return[this.textureDefinitionsSelectedFormats[n]||e,r]}return[e,r]}return[e,null]}_initSelectedFormatsForTextureDefinitions(t){this.textureDefinitionsSelectedFormats=[];const e=this._getSupportedTextureFormats(),r=t.textureSetDefinitions||[];for(const t of r){const r=t&&t.formats||[];let n=null;for(const t of e){const e=r.find(e=>e.format===t);if(e){n=e;break}}this.textureDefinitionsSelectedFormats.push(n)}}_getSupportedTextureFormats(){const t=[];if(!this.options.i3s||this.options.i3s.useCompressedTextures){const e=ui();e.has("etc2")&&t.push("ktx-etc2"),e.has("dxt")&&t.push("dds")}return t.push("jpg"),t.push("png"),t}}function qs(t){const e=t.obb?[...ir.WGS84.cartographicToCartesian(t.obb.center),...t.obb.halfSize,...t.obb.quaternion]:void 0;let r;if(t.mbs)r=[...ir.WGS84.cartographicToCartesian(t.mbs.slice(0,3)),t.mbs[3]];else if(e){const n=(new Gs).fromCenterHalfSizeQuaternion(e.slice(0,3),t.obb.halfSize,t.obb.quaternion).getBoundingSphere();r=[...n.center,n.radius],t.mbs=[...t.obb.center,n.radius]}return t.boundingVolume={sphere:r,box:e},t.lodMetricType=t.lodSelection[0].metricType,t.lodMetricValue=t.lodSelection[0].maxError,t.transformMatrix=t.transform,t.type=Fs,t.refine=ks,t}const Vs=/layers\/[0-9]+$/,$s=/nodes\/([0-9-]+|root)$/,Qs={name:"I3S (Indexed Scene Layers)",id:"i3s",module:"i3s",version:"3.1.0-alpha.3",mimeTypes:["application/octet-stream"],parse:async function(t,e,r){const n=r.url;e.i3s=e.i3s||{};if("504b0304"===function(t){if(t instanceof ArrayBuffer)return[...new Uint8Array(t,0,4)].map(t=>t.toString(16).padStart(2,"0")).join("");return null}(t))throw new Error("Files with .slpk extention currently are not supported by I3SLoader");let i,s;i="auto"===e.i3s.isTileset?Vs.test(n):e.i3s.isTileset;s="auto"===e.isTileHeader?$s.test(n):e.i3s.isTileHeader;i?t=await async function(t,e,r){const n=JSON.parse((new TextDecoder).decode(t));return n.loader=Qs,await async function(t,e,r){if(t.url=r.url,t.nodePages)t.nodePagesTile=new Ws(t,e),t.root=await t.nodePagesTile.formTileFromNodePages(0);else{var n;const r=Ei(t.url+"/nodes/root",null===(n=e.i3s)||void 0===n?void 0:n.token);t.root=await jt(r,t.loader,{i3s:{loadContent:!1,isTileHeader:!0,isTileset:!1}})}t.basePath=t.url,t.type=Xs,t.lodMetricType=t.root.lodMetricType,t.lodMetricValue=t.root.lodMetricValue}(n,e,r),n}(t,e,r):s?(t=await async function(t,e,r){return function(t,e,r){return t.url=r.url,t.featureData&&(t.featureUrl=`${t.url}/${t.featureData[0].href}`),t.geometryData&&(t.contentUrl=`${t.url}/${t.geometryData[0].href}`),t.textureData&&(t.textureUrl=`${t.url}/${t.textureData[0].href}`),t.attributeData&&(t.attributeUrls=function(t){const{url:e,attributeData:r}=t,n=[];for(let t=0;t<r.length;t++){const i=r[t].href.replace("./","");n.push(`${e}/${i}`)}return n}(t)),qs(t)}(t=JSON.parse((new TextDecoder).decode(t)),0,r)}(t,0,r),e.i3s.loadContent&&(e.i3s.tile=t,await jt(t.contentUrl,Qs,e))):t=await async function(t,e){return await zt(t,ki,e)}(t,e);return t},extensions:["bin"],options:{i3s:{loadContent:!0,token:null,isTileset:"auto",isTileHeader:"auto",tile:null,tileset:null,useDracoGeometry:!0,useCompressedTextures:!0}}};async function Zs(t,e){const{attributeName:r,attributeType:n}=e;return r?{[r]:n?Ys(n,t):null}:{}}function Ys(t,e){switch(t){case"String":return function(t){const e=[];try{const r=new DataView(t,0,4).getUint32(0,!0),n=new Uint32Array(t,8,r);let i=8+4*r;for(const r of n){const n=new TextDecoder("utf-8"),s=new Uint8Array(t,i,r);e.push(n.decode(s)),i+=r}}catch(t){console.error("Parse string attribute error: ",t.message)}return e}(e);case"Oid32":return Js(e);case"Float64":return function(t){return new Float64Array(t,8)}(e);default:return Js(e)}}function Js(t){return new Uint32Array(t,4)}const to={name:"I3S Attribute",id:"i3s-attribute",module:"i3s",version:"3.1.0-alpha.3",mimeTypes:["application/binary"],parse:async function(t,e){return t=Zs(t,e)},extensions:["bin"],options:{},binary:!0};async function eo(t,e,r={}){const{attributeStorageInfo:n,attributeUrls:i}=function(t){const e=t&&t.tileset&&t.tileset.tileset&&t.tileset.tileset.attributeStorageInfo,r=t&&t.header&&t.header.attributeUrls;return{attributeStorageInfo:e,attributeUrls:r}}(t);if(!n||!i||!e)return null;let s=[];const o=[];for(let t=0;t<n.length;t++){var a;const e=Ei(i[t],null===(a=r.i3s)||void 0===a?void 0:a.token),s=n[t].name,c=ro(n[t]),u={...r,attributeName:s,attributeType:c},l=jt(e,to,u);o.push(l)}try{s=await Promise.allSettled(o)}catch(t){}return s.length?function(t,e,r){const n=t.find(t=>t.value.OBJECTID);if(!n)return null;const i=n.value.OBJECTID.indexOf(r);if(i<0)return null;return function(t,e,r){const n={};for(let i=0;i<r.length;i++){const s=r[i].name,o=no(t,i,s);n[s]=io(o,e)}return n}(t,i,e)}(s,n,e):null}function ro(t){return t.hasOwnProperty("objectIds")?"Oid32":t.hasOwnProperty("attributeValues")?t.attributeValues.valueType:""}function no(t,e,r){const n=t[e];return"rejected"===n.status?null:n.value[r]}function io(t,e){return t&&t[e]?t[e].toString().replace(/\u0000/g,"").trim():""}}])}));
2
- //# sourceMappingURL=dist.min.js.map