@splnlss/3d-story-viewer 0.8.4 → 0.8.5
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.
- package/README.md +45 -1
- package/build/{main-DZ2oJmQ9.js → main-DCLbtFn7.js} +1234 -471
- package/build/main-DXC7nIw_.cjs +1 -0
- package/build/spark.module-BPiIta4L.cjs +1 -0
- package/build/{spark.module-OeW1hboi.js → spark.module-SbwV3up9.js} +235 -13
- package/build/types/src/main.d.ts +11 -1
- package/build/types/src/viewer/ContentLayer/ContentLayerRegistry.d.ts +31 -0
- package/build/types/src/viewer/ContentLayer/GeojsonLayer.d.ts +1 -0
- package/build/types/src/viewer/ContentLayer/MeshLayer.d.ts +4 -1
- package/build/types/src/viewer/ContentLayer/TilesLayer.d.ts +1 -0
- package/build/types/src/viewer/ContentLayer/gaussianSplatUtils.d.ts +6 -0
- package/build/types/src/viewer/DesktopLookControls.d.ts +22 -0
- package/build/types/src/viewer/GlobeManager.d.ts +3 -0
- package/build/types/src/viewer/SplatDestinationPrefetch.d.ts +18 -0
- package/build/types/src/viewer/WebXRSession.d.ts +2 -2
- package/build/types/src/viewer/XRDiagnosticsPanel.d.ts +14 -0
- package/build/types/src/viewer/XRRenderBridge.d.ts +3 -4
- package/build/types/src/viewer/index.d.ts +135 -7
- package/build/types/src/viewer/loadingDiagnostics.d.ts +10 -0
- package/build/types/src/workers/WorkerPool.d.ts +9 -3
- package/build/viewer.cjs +1 -1
- package/build/viewer.js +1 -1
- package/package.json +1 -1
- package/build/main-CNVle6K1.cjs +0 -1
- package/build/spark.module-HtQy_Ka9.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e,t,i=Object.defineProperty,r=e=>{throw TypeError(e)},a=(e,t,r)=>((e,t,r)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),s=(e,t,i)=>t.has(e)||r("Cannot "+i),n=(e,t,i)=>(s(e,t,"read from private field"),i?i.call(e):t.get(e)),o=(e,t,i,r)=>(s(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);const l=require("./index-XZNzHig1.cjs");l.ShaderChunk.bayer_dither_hash_pars_fragment="#ifdef USE_HASH\nuniform float hashOpacity;varying float vCameraDistance;float bayerDitherPattern(vec2 p){float bayerMatrix[16];bayerMatrix[0]=0.0;bayerMatrix[1]=8.0;bayerMatrix[2]=2.0;bayerMatrix[3]=10.0;bayerMatrix[4]=12.0;bayerMatrix[5]=4.0;bayerMatrix[6]=14.0;bayerMatrix[7]=6.0;bayerMatrix[8]=3.0;bayerMatrix[9]=11.0;bayerMatrix[10]=1.0;bayerMatrix[11]=9.0;bayerMatrix[12]=15.0;bayerMatrix[13]=7.0;bayerMatrix[14]=13.0;bayerMatrix[15]=5.0;int x=int(mod(p.x,4.0));int y=int(mod(p.y,4.0));int index=x+y*4;return bayerMatrix[index]/16.0;}\n#endif\n",l.ShaderChunk.bayer_dither_hash_fragment="#ifdef USE_HASH\nfloat hashAmount=smoothstep(5e4,1e2,vCameraDistance)*0.75+0.1;float ditherValue=bayerDitherPattern(gl_FragCoord.xy);if(hashAmount<ditherValue){discard;}\n#endif\n",l.ShaderChunk.bayer_dither_hash_pars_vertex="#ifdef USE_HASH\nvarying float vCameraDistance;\n#endif\n",l.ShaderChunk.bayer_dither_hash_vertex="#ifdef USE_HASH\nvCameraDistance=-mvPosition.z;\n#endif\n";class c extends l.Object3D{constructor(e=document.createElement("div")){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.center=new l.Vector2(.5,.5),this.rotation2D=0,this.addEventListener("removed",(function(){this.traverse((function(e){e.element&&e.element instanceof e.element.ownerDocument.defaultView.Element&&null!==e.element.parentNode&&e.element.remove()}))}))}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this.rotation2D=e.rotation2D,this}}const h=new l.Vector3,d=new l.Matrix4,u=new l.Matrix4,p=new l.Vector3,m=new l.Vector3;class f{constructor(e={}){const t=this;let i,r,a,s;const n={objects:new WeakMap},o=void 0!==e.element?e.element:document.createElement("div");function l(e){e.isCSS2DObject&&(e.element.style.display="none");for(let t=0,i=e.children.length;t<i;t++)l(e.children[t])}function c(e,i,r){if(!1!==e.visible){if(e.isCSS2DObject){h.setFromMatrixPosition(e.matrixWorld),h.applyMatrix4(u);const l=h.z>=-1&&h.z<=1&&!0===e.layers.test(r.layers),c=e.element;if(c.style.display=!0===l?"":"none",!0===l){e.onBeforeRender(t,i,r);const n=100*e.center.x,l=100*e.center.y;c.style.transformOrigin=`${n}% ${l}%`;const d=-e.rotation2D,u=h.x*a+a,p=-h.y*s+s;c.style.transform=`translate(${-n}%, ${-l}%) translate(${u}px, ${p}px) rotate(${d}rad)`,c.parentNode!==o&&o.appendChild(c),e.onAfterRender(t,i,r)}const d={distanceToCameraSquared:f(r,e)};n.objects.set(e,d)}for(let t=0,a=e.children.length;t<a;t++)c(e.children[t],i,r)}else l(e)}function f(e,t){return p.setFromMatrixPosition(e.matrixWorld),m.setFromMatrixPosition(t.matrixWorld),p.distanceToSquared(m)}o.style.overflow="hidden",this.domElement=o,this.sortObjects=!0,this.getSize=function(){return{width:i,height:r}},this.render=function(e,t){!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),d.copy(t.matrixWorldInverse),u.multiplyMatrices(t.projectionMatrix,d),c(e,e,t),this.sortObjects&&function(e){const t=function(e){const t=[];return e.traverseVisible((function(e){e.isCSS2DObject&&t.push(e)})),t}(e).sort((function(e,t){if(e.renderOrder!==t.renderOrder)return t.renderOrder-e.renderOrder;return n.objects.get(e).distanceToCameraSquared-n.objects.get(t).distanceToCameraSquared})),i=t.length;for(let r=0,a=t.length;r<a;r++)t[r].element.style.zIndex=i-r}(e)},this.setSize=function(e,t){i=e,r=t,a=i/2,s=r/2,o.style.width=e+"px",o.style.height=t+"px"}}}let g=null;function b(){return g??(g=Promise.resolve().then((()=>require("./spark.module-BPiIta4L.cjs"))).catch((e=>{throw g=null,e}))),g}class y{constructor(){this.listeners={}}addEventListener(e,t){const i=this.listeners;void 0===i[e]&&(i[e]=[]),-1===i[e].indexOf(t)&&i[e].push(t)}hasEventListener(e,t){const i=this.listeners;return void 0!==i[e]&&-1!==i[e].indexOf(t)}removeEventListener(e,t){const i=this.listeners[e];if(void 0!==i){const e=i.indexOf(t);-1!==e&&i.splice(e,1)}}dispatchEvent(e){const t=this.listeners[e.type];if(void 0!==t){e.target=this;const i=t.slice(0);for(let t=0,r=i.length;t<r;t+=1)i[t].call(this,e)}}}function v(e){return!(!e||"object"!=typeof e)&&0===Object.keys(e).length}function x(e,t){if(e===t)return!0;if(null===e||"object"!=typeof e||null===t||"object"!=typeof t)return!1;const i=Object.keys(e),r=Object.keys(t);if(i.length!==r.length)return!1;for(let a of i)if(!r.includes(a)||!x(e[a],t[a]))return!1;return!0}const w="defined",T="updated",_="deleted";class A extends y{constructor(e){super(),this.initialValues={},this.values={},this.define(e)}define(e={},t=!0){const i={};for(const r in e)if(Object.hasOwnProperty.call(e,r)){const a=e[r];Object.hasOwnProperty.call(this.initialValues,r)?t&&(this.initialValues[r]=a,this.values[r]=a,i[r]=a):(this.initialValues[r]=a,this.values[r]=a,i[r]=a)}return v(i)||this.dispatchEvent({type:w,values:i}),i}update(e={},t={}){let i={};const r={},a=t.force||!1,s=t.dryrun||!1;for(const n in e)if(Object.hasOwnProperty.call(e,n)){let t=e[n];Object.hasOwnProperty.call(this.initialValues,n)&&(void 0===t&&(t=this.initialValues[n]),x(this.values[n],t)&&!a||(r[n]=this.values[n],s||(this.values[n]=t),i[n]=t))}return s||v(i)||this.dispatchEvent({type:T,values:this.values,changes:i,before:r}),i}get(e){let t={};if(e){Array.isArray(e)||(e=[e]);for(let i=0;i<e.length;i++){const r=e[i];Object.hasOwnProperty.call(this.values,r)&&(t[r]=this.values[r])}}else t={...this.values};return 1==e.length?t[e[0]]:t}reset(e){const t={},i={};if(e){Array.isArray(e)||(e=[e]);for(let r=0;r<e.length;r++){const a=e[r];Object.hasOwnProperty.call(this.initialValues,a)&&(i[a]=this.values[a],this.values[a]=this.initialValues[a],t[a]=this.initialValues[a])}}else for(const r in this.initialValues)Object.hasOwnProperty.call(this.initialValues,r)&&(this.values[r]=this.initialValues[r],t[r]=this.initialValues[r]);return v(t)||this.dispatchEvent({type:T,values:this.values,changes:t,before:i}),t}delete(e=[]){const t={};Array.isArray(e)||(e=[e]);for(let i=0;i<e.length;i++){const r=e[i];Object.hasOwnProperty.call(this.values,r)&&(t[r]=this.values[r],delete this.values[r],delete this.initialValues[r])}return v(t)||this.dispatchEvent({type:_,deleted:t}),t}clone(){const e=new A(this.initialValues);return e.update(this.values),e}}new A;class S extends l.Mesh{constructor(){super(new l.PlaneGeometry(0,0),new M),this.renderOrder=1/0}onBeforeRender(e){const t=this.material.uniforms;e.getSize(t.resolution.value)}updateMatrixWorld(){this.matrixWorld.makeTranslation(this.position)}dispose(){this.geometry.dispose(),this.material.dispose()}}class M extends l.ShaderMaterial{constructor(){super({depthWrite:!1,depthTest:!1,transparent:!0,uniforms:{resolution:{value:new l.Vector2},size:{value:15},thickness:{value:2},opacity:{value:1}},vertexShader:"\n\n\t\t\t\tuniform float size;\n\t\t\t\tuniform float thickness;\n\t\t\t\tuniform vec2 resolution;\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvUv = uv;\n\n\t\t\t\t\tfloat aspect = resolution.x / resolution.y;\n\t\t\t\t\tvec2 offset = uv * 2.0 - vec2( 1.0 );\n\t\t\t\t\toffset.y *= aspect;\n\n\t\t\t\t\tvec4 screenPoint = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t\tscreenPoint.xy += offset * ( size + thickness ) * screenPoint.w / resolution.x;\n\n\t\t\t\t\tgl_Position = screenPoint;\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform float size;\n\t\t\t\tuniform float thickness;\n\t\t\t\tuniform float opacity;\n\n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tfloat ht = 0.5 * thickness;\n\t\t\t\t\tfloat planeDim = size + thickness;\n\t\t\t\t\tfloat offset = ( planeDim - ht - 2.0 ) / planeDim;\n\t\t\t\t\tfloat texelThickness = ht / planeDim;\n\n\t\t\t\t\tvec2 vec = vUv * 2.0 - vec2( 1.0 );\n\t\t\t\t\tfloat dist = abs( length( vec ) - offset );\n\t\t\t\t\tfloat fw = fwidth( dist ) * 0.5;\n\t\t\t\t\tfloat a = smoothstep( texelThickness - fw, texelThickness + fw, dist );\n\n\t\t\t\t\tgl_FragColor = vec4( 1, 1, 1, opacity * ( 1.0 - a ) );\n\n\t\t\t\t}\n\t\t\t"})}}const C=new l.Vector2,E=new l.Vector2;class R{constructor(){this.domElement=null,this.buttons=0,this.pointerType=null,this.pointerOrder=[],this.previousPositions={},this.pointerPositions={},this.startPositions={},this.pointerSetThisFrame={},this.hoverPosition=new l.Vector2,this.hoverSet=!1}reset(){this.buttons=0,this.pointerType=null,this.pointerOrder=[],this.previousPositions={},this.pointerPositions={},this.startPositions={},this.pointerSetThisFrame={},this.hoverPosition=new l.Vector2,this.hoverSet=!1}updateFrame(){const{previousPositions:e,pointerPositions:t}=this;for(const i in t)e[i].copy(t[i])}setHoverEvent(e){"mouse"!==e.pointerType&&"wheel"!==e.type||(this.getAdjustedPointer(e,this.hoverPosition),this.hoverSet=!0)}getLatestPoint(e){return null!==this.pointerType?(this.getCenterPoint(e),e):this.hoverSet?(e.copy(this.hoverPosition),e):null}getAdjustedPointer(e,t){const i=(this.domElement?this.domElement:e.target).getBoundingClientRect(),r=e.clientX-i.left,a=e.clientY-i.top;t.set(r,a)}addPointer(e){const t=e.pointerId,i=new l.Vector2;this.getAdjustedPointer(e,i),this.pointerOrder.push(t),this.pointerPositions[t]=i,this.previousPositions[t]=i.clone(),this.startPositions[t]=i.clone(),1===this.getPointerCount()&&(this.pointerType=e.pointerType,this.buttons=e.buttons)}updatePointer(e){const t=e.pointerId;return t in this.pointerPositions&&(this.getAdjustedPointer(e,this.pointerPositions[t]),!0)}deletePointer(e){const t=e.pointerId,i=this.pointerOrder;i.splice(i.indexOf(t),1),delete this.pointerPositions[t],delete this.previousPositions[t],delete this.startPositions[t],0===this.getPointerCount()&&(this.buttons=0,this.pointerType=null)}getPointerCount(){return this.pointerOrder.length}getCenterPoint(e,t=this.pointerPositions){const i=this.pointerOrder;if(1===this.getPointerCount()||"mouse"===this.getPointerType()){const r=i[0];return e.copy(t[r]),e}if(2===this.getPointerCount()){const i=this.pointerOrder[0],r=this.pointerOrder[1],a=t[i],s=t[r];return e.addVectors(a,s).multiplyScalar(.5),e}return null}getPreviousCenterPoint(e){return this.getCenterPoint(e,this.previousPositions)}getStartCenterPoint(e){return this.getCenterPoint(e,this.startPositions)}getMoveDistance(){return this.getCenterPoint(C),this.getPreviousCenterPoint(E),C.sub(E).length()}getTouchPointerDistance(e=this.pointerPositions){if(this.getPointerCount()<=1||"mouse"===this.getPointerType())return 0;const{pointerOrder:t}=this,i=t[0],r=t[1],a=e[i],s=e[r];return a.distanceTo(s)}getPreviousTouchPointerDistance(){return this.getTouchPointerDistance(this.previousPositions)}getStartTouchPointerDistance(){return this.getTouchPointerDistance(this.startPositions)}getPointerType(){return this.pointerType}isPointerTouch(){return"touch"===this.getPointerType()}getPointerButtons(){return this.buttons}isLeftClicked(){return Boolean(1&this.buttons)}isRightClicked(){return Boolean(2&this.buttons)}}const k=new l.Matrix4;function P(e,t,i){return i.makeTranslation(-e.x,-e.y,-e.z),k.makeRotationFromQuaternion(t),i.premultiply(k),k.makeTranslation(e.x,e.y,e.z),i.premultiply(k),i}function F(e,t,i){i.x=e.x/t.clientWidth*2-1,i.y=-e.y/t.clientHeight*2+1,i.isVector3&&(i.z=0)}function L(e,t,i){const r=e instanceof l.Ray?e:e.ray,{origin:a,direction:s}=r;a.set(t.x,t.y,-1).unproject(i),s.set(t.x,t.y,1).unproject(i).sub(a),e.isRay||(e.near=0,e.far=s.length(),e.camera=i),s.normalize()}const D=.05,U=.025,I=new l.Matrix4,O=new l.Matrix4,B=new l.Vector3,V=new l.Vector3,N=new l.Vector3,j=new l.Vector3,z=new l.Vector3,G=new l.Vector3,H=new l.Vector3,q=new l.Vector3,W=new l.Quaternion,K=new l.Plane,J=new l.Vector3,X=new l.Vector3,Q=new l.Vector3,Y=new l.Quaternion,Z=new l.Ray,$=new l.Vector2,ee=new l.Vector2,te=new l.Vector2,ie=new l.Vector2,re=new l.Vector2,ae=new l.Vector2,se={type:"change"},ne={type:"start"},oe={type:"end"};class le extends l.EventDispatcher{get enabled(){return this._enabled}set enabled(e){e!==this.enabled&&(this._enabled=e,this.resetState(),this.pointerTracker.reset(),this.enabled||(this.dragInertia.set(0,0,0),this.rotationInertia.set(0,0)))}constructor(e=null,t=null,i=null,r=null){super(),this.isEnvironmentControls=!0,this.domElement=null,this.camera=null,this.scene=null,this.tilesRenderer=null,this._enabled=!0,this.cameraRadius=5,this.rotationSpeed=1,this.minAltitude=0,this.maxAltitude=.45*Math.PI,this.minDistance=10,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.zoomSpeed=1,this.adjustHeight=!0,this.enableDamping=!1,this.dampingFactor=.15,this.fallbackPlane=new l.Plane(new l.Vector3(0,1,0),0),this.useFallbackPlane=!0,this.scaleZoomOrientationAtEdges=!1,this.autoAdjustCameraRotation=!0,this.state=0,this.pointerTracker=new R,this.needsUpdate=!1,this.actionHeightOffset=0,this.pivotPoint=new l.Vector3,this.zoomDirectionSet=!1,this.zoomPointSet=!1,this.zoomDirection=new l.Vector3,this.zoomPoint=new l.Vector3,this.zoomDelta=0,this.rotationInertiaPivot=new l.Vector3,this.rotationInertia=new l.Vector2,this.dragInertia=new l.Vector3,this.inertiaTargetDistance=1/0,this.inertiaStableFrames=0,this.pivotMesh=new S,this.pivotMesh.raycast=()=>{},this.pivotMesh.scale.setScalar(.25),this.raycaster=new l.Raycaster,this.raycaster.firstHitOnly=!0,this.up=new l.Vector3(0,1,0),this.clock=new l.Clock,this._detachCallback=null,this._upInitialized=!1,this._lastUsedState=0,this._zoomPointWasSet=!1,this._tilesOnChangeCallback=()=>this.zoomPointSet=!1,i&&this.attach(i),t&&this.setCamera(t),e&&this.setScene(e),r&&this.setTilesRenderer(r)}setScene(e){this.scene=e}setCamera(e){this.camera=e,this._upInitialized=!1,this.zoomDirectionSet=!1,this.zoomPointSet=!1,this.needsUpdate=!0,this.raycaster.camera=e,this.resetState()}setTilesRenderer(e){this.tilesRenderer=e,null!==this.tilesRenderer&&this.setScene(this.tilesRenderer.group)}attach(e){if(this.domElement)throw new Error("EnvironmentControls: Controls already attached to element");this.domElement=e,this.pointerTracker.domElement=e,e.style.touchAction="none";const t=e=>{this.enabled&&e.preventDefault()},i=e=>{if(!this.enabled)return;e.preventDefault();const{camera:t,raycaster:i,domElement:r,up:a,pivotMesh:s,pointerTracker:n,scene:o,pivotPoint:l,enabled:c}=this;if(n.addPointer(e),this.needsUpdate=!0,n.isPointerTouch())if(s.visible=!1,0===n.getPointerCount())r.setPointerCapture(e.pointerId);else if(n.getPointerCount()>2)return void this.resetState();n.getCenterPoint(ee),F(ee,r,ee),L(i,ee,t);const h=Math.abs(i.ray.direction.dot(a));if(h<D||h<U)return;const d=this._raycast(i);d&&(2===n.getPointerCount()||n.isRightClicked()||n.isLeftClicked()&&e.shiftKey?(this.setState(n.isPointerTouch()?4:2),l.copy(d.point),s.position.copy(d.point),s.visible=!n.isPointerTouch()&&c,s.updateMatrixWorld(),o.add(s)):n.isLeftClicked()&&(this.setState(1),l.copy(d.point),s.position.copy(d.point),s.updateMatrixWorld(),o.add(s)))};let r=!1;const a=e=>{const{pointerTracker:t}=this;if(!this.enabled)return;e.preventDefault();const{pivotMesh:i,enabled:a}=this;this.zoomDirectionSet=!1,this.zoomPointSet=!1,0!==this.state&&(this.needsUpdate=!0),t.setHoverEvent(e),t.updatePointer(e)&&(t.isPointerTouch()&&2===t.getPointerCount()&&(r||(r=!0,queueMicrotask((()=>{r=!1,t.getCenterPoint(re);const e=t.getStartTouchPointerDistance(),s=t.getTouchPointerDistance(),n=s-e;if(0===this.state||4===this.state){t.getCenterPoint(re),t.getStartCenterPoint(ae);const e=2*window.devicePixelRatio,i=re.distanceTo(ae);(Math.abs(n)>e||i>e)&&(Math.abs(n)>i?(this.setState(3),this.zoomDirectionSet=!1):this.setState(2))}if(3===this.state){const e=t.getPreviousTouchPointerDistance();this.zoomDelta+=s-e,i.visible=!1}else 2===this.state&&(i.visible=a)})))),this.dispatchEvent(se))},s=t=>{const{pointerTracker:i}=this;this.enabled&&0!==i.getPointerCount()&&(i.deletePointer(t),"touch"===i.getPointerType()&&0===i.getPointerCount()&&e.releasePointerCapture(t.pointerId),this.resetState(),this.needsUpdate=!0)},n=e=>{if(!this.enabled)return;e.preventDefault();const{pointerTracker:t}=this;let i;switch(t.setHoverEvent(e),t.updatePointer(e),this.dispatchEvent(ne),e.deltaMode){case 2:i=800*e.deltaY;break;case 1:i=40*e.deltaY;break;case 0:i=e.deltaY}const r=Math.sign(i),a=Math.abs(i);this.zoomDelta-=.25*r*a,this.needsUpdate=!0,this._lastUsedState=3,this.dispatchEvent(oe)},o=e=>{this.enabled&&this.resetState()};e.addEventListener("contextmenu",t),e.addEventListener("pointerdown",i),e.addEventListener("wheel",n,{passive:!1});const l=e.getRootNode();l.addEventListener("pointermove",a),l.addEventListener("pointerup",s),l.addEventListener("pointerleave",o),this._detachCallback=()=>{e.removeEventListener("contextmenu",t),e.removeEventListener("pointerdown",i),e.removeEventListener("wheel",n),l.removeEventListener("pointermove",a),l.removeEventListener("pointerup",s),l.removeEventListener("pointerleave",o)}}detach(){this.domElement=null,this._detachCallback&&(this._detachCallback(),this._detachCallback=null,this.pointerTracker.reset())}getUpDirection(e,t){t.copy(this.up)}getCameraUpDirection(e){this.getUpDirection(this.camera.position,e)}getPivotPoint(e){let t=null;3===this._lastUsedState?this._zoomPointWasSet&&(t=e.copy(this.zoomPoint)):2!==this._lastUsedState&&1!==this._lastUsedState||(t=e.copy(this.pivotPoint));const{camera:i,raycaster:r}=this;null!==t&&(V.copy(t).project(i),(V.x<-1||V.x>1||V.y<-1||V.y>1)&&(t=null)),L(r,{x:0,y:0},i);const a=this._raycast(r);return a&&(null===t||a.distance<t.distanceTo(r.ray.origin))&&(t=e.copy(a.point)),t}resetState(){0!==this.state&&this.dispatchEvent(oe),this.state=0,this.pivotMesh.removeFromParent(),this.pivotMesh.visible=this.enabled,this.actionHeightOffset=0,this.pointerTracker.reset()}setState(e=this.state,t=!0){this.state!==e&&(0===this.state&&t&&this.dispatchEvent(ne),this.pivotMesh.visible=this.enabled,this.dragInertia.set(0,0,0),this.rotationInertia.set(0,0),this.inertiaStableFrames=0,this.state=e,0!==e&&4!==e&&(this._lastUsedState=e))}update(e=Math.min(this.clock.getDelta(),.064)){if(!this.enabled||!this.camera||0===e)return;const{camera:t,cameraRadius:i,pivotPoint:r,up:a,state:s,adjustHeight:n,autoAdjustCameraRotation:o}=this;t.updateMatrixWorld(),this.getCameraUpDirection(J),this._upInitialized||(this._upInitialized=!0,this.up.copy(J)),this.zoomPointSet=!1;const l=this._inertiaNeedsUpdate(),c=this.needsUpdate||l;if(this.needsUpdate||l){const i=this.zoomDelta;this._updateZoom(),this._updatePosition(e),this._updateRotation(e),1===s||2===s?(z.set(0,0,-1).transformDirection(t.matrixWorld),this.inertiaTargetDistance=V.copy(r).sub(t.position).dot(z)):0===s&&this._updateInertia(e),(0!==s||0!==i||l)&&this.dispatchEvent(se),this.needsUpdate=!1}const h=t.isOrthographicCamera?null:n&&this._getPointBelowCamera()||null;if(this.getCameraUpDirection(J),this._setFrame(J),(1===this.state||2===this.state)&&0!==this.actionHeightOffset){const{actionHeightOffset:e}=this;t.position.addScaledVector(a,-e),r.addScaledVector(a,-e),h&&(h.distance-=e)}if(this.actionHeightOffset=0,h){const e=h.distance;if(e<i){const s=i-e;t.position.addScaledVector(a,s),r.addScaledVector(a,s),this.actionHeightOffset=s}}this.pointerTracker.updateFrame(),c&&o&&(this.getCameraUpDirection(J),this._alignCameraUp(J,1),this.getCameraUpDirection(J),this._clampRotation(J))}adjustCamera(e){const{adjustHeight:t,cameraRadius:i}=this;if(e.isPerspectiveCamera){this.getUpDirection(e.position,J);const r=t&&this._getPointBelowCamera(e.position,J)||null;if(r){const t=r.distance;t<i&&e.position.addScaledVector(J,i-t)}}}dispose(){this.detach()}_updateInertia(e){const{rotationInertia:t,pivotPoint:i,dragInertia:r,enableDamping:a,dampingFactor:s,camera:n,cameraRadius:o,minDistance:l,inertiaTargetDistance:c}=this;if(!this.enableDamping||this.inertiaStableFrames>1)return r.set(0,0,0),void t.set(0,0,0);const h=Math.pow(2,-e/s),d=Math.max(n.near,o,l,c),u=25e-5;if(t.lengthSq()>0){L(Z,V.set(0,0,-1),n),Z.applyMatrix4(n.matrixWorldInverse),Z.direction.normalize(),Z.recast(-Z.direction.dot(Z.origin)).at(d/Z.direction.z,V),V.applyMatrix4(n.matrixWorld),L(Z,B.set(u,u,-1),n),Z.applyMatrix4(n.matrixWorldInverse),Z.direction.normalize(),Z.recast(-Z.direction.dot(Z.origin)).at(d/Z.direction.z,B),B.applyMatrix4(n.matrixWorld),V.sub(i).normalize(),B.sub(i).normalize();const r=V.angleTo(B)/e;t.multiplyScalar(h),(t.lengthSq()<r**2||!a)&&t.set(0,0)}if(r.lengthSq()>0){L(Z,V.set(0,0,-1),n),Z.applyMatrix4(n.matrixWorldInverse),Z.direction.normalize(),Z.recast(-Z.direction.dot(Z.origin)).at(d/Z.direction.z,V),V.applyMatrix4(n.matrixWorld),L(Z,B.set(u,u,-1),n),Z.applyMatrix4(n.matrixWorldInverse),Z.direction.normalize(),Z.recast(-Z.direction.dot(Z.origin)).at(d/Z.direction.z,B),B.applyMatrix4(n.matrixWorld);const t=V.distanceTo(B)/e;r.multiplyScalar(h),(r.lengthSq()<t**2||!a)&&r.set(0,0,0)}t.lengthSq()>0&&this._applyRotation(t.x*e,t.y*e,i),r.lengthSq()>0&&(n.position.addScaledVector(r,e),n.updateMatrixWorld())}_inertiaNeedsUpdate(){const{rotationInertia:e,dragInertia:t}=this;return 0!==e.lengthSq()||0!==t.lengthSq()}_updateZoom(){const{zoomPoint:e,zoomDirection:t,camera:i,minDistance:r,maxDistance:a,pointerTracker:s,domElement:n,minZoom:o,maxZoom:l,zoomSpeed:c,state:h}=this;let d=this.zoomDelta;if(this.zoomDelta=0,s.getLatestPoint(ee)&&(0!==d||3===h))if(this.rotationInertia.set(0,0),this.dragInertia.set(0,0,0),i.isOrthographicCamera){this._updateZoomDirection();const e=this.zoomPointSet||this._updateZoomPoint();X.unproject(i);const t=Math.pow(.95,Math.abs(.05*d));let r=d>0?1/Math.abs(t):t;r*=c,r>1?l<i.zoom*r&&(r=1):o>i.zoom*r&&(r=1),i.zoom*=r,i.updateProjectionMatrix(),e&&(F(ee,n,Q),Q.unproject(i),i.position.sub(Q).add(X),i.updateMatrixWorld())}else{this._updateZoomDirection();const s=V.copy(t);if(this.zoomPointSet||this._updateZoomPoint()){const s=e.distanceTo(i.position);if(d<0){const e=Math.min(0,s-a);d=d*s*c*.0025,d=Math.max(d,e)}else{const e=Math.max(0,s-r);d=d*Math.max(s-r,0)*c*.0025,d=Math.min(d,e)}i.position.addScaledVector(t,d),i.updateMatrixWorld()}else{const e=this._getPointBelowCamera();if(e){const t=e.distance;s.set(0,0,-1).transformDirection(i.matrixWorld),i.position.addScaledVector(s,d*t*.01),i.updateMatrixWorld()}}}}_updateZoomDirection(){if(this.zoomDirectionSet)return;const{domElement:e,raycaster:t,camera:i,zoomDirection:r,pointerTracker:a}=this;a.getLatestPoint(ee),F(ee,e,X),L(t,X,i),r.copy(t.ray.direction).normalize(),this.zoomDirectionSet=!0}_updateZoomPoint(){const{camera:e,zoomDirectionSet:t,zoomDirection:i,raycaster:r,zoomPoint:a,pointerTracker:s,domElement:n}=this;if(this._zoomPointWasSet=!1,!t)return!1;e.isOrthographicCamera&&s.getLatestPoint($)?(F($,n,$),L(r,$,e)):(r.ray.origin.copy(e.position),r.ray.direction.copy(i),r.near=0,r.far=1/0);const o=this._raycast(r);return!!o&&(a.copy(o.point),this.zoomPointSet=!0,this._zoomPointWasSet=!0,!0)}_getPointBelowCamera(e=this.camera.position,t=this.up){const{raycaster:i}=this;i.ray.direction.copy(t).multiplyScalar(-1),i.ray.origin.copy(e).addScaledVector(t,1e5),i.near=0,i.far=1/0;const r=this._raycast(i);return r&&(r.distance-=1e5),r}_updatePosition(e){const{raycaster:t,camera:i,pivotPoint:r,up:a,pointerTracker:s,domElement:n,state:o,dragInertia:l}=this;if(1===o){if(s.getCenterPoint(ee),F(ee,n,ee),K.setFromNormalAndCoplanarPoint(a,r),L(t,ee,i),Math.abs(t.ray.direction.dot(a))<D){const e=Math.acos(D);q.crossVectors(t.ray.direction,a).normalize(),t.ray.direction.copy(a).applyAxisAngle(q,e).multiplyScalar(-1)}if(this.getUpDirection(r,J),Math.abs(t.ray.direction.dot(J))<U){const e=Math.acos(U);q.crossVectors(t.ray.direction,J).normalize(),t.ray.direction.copy(J).applyAxisAngle(q,e).multiplyScalar(-1)}t.ray.intersectPlane(K,V)&&(B.subVectors(r,V),i.position.add(B),i.updateMatrixWorld(),B.multiplyScalar(1/e),s.getMoveDistance()/e<2*window.devicePixelRatio?this.inertiaStableFrames++:(l.copy(B),this.inertiaStableFrames=0))}}_updateRotation(e){const{pivotPoint:t,pointerTracker:i,domElement:r,state:a,rotationInertia:s}=this;2===a&&(i.getCenterPoint(ee),i.getPreviousCenterPoint(te),ie.subVectors(ee,te).multiplyScalar(2*Math.PI/r.clientHeight),this._applyRotation(ie.x,ie.y,t),ie.multiplyScalar(1/e),i.getMoveDistance()/e<2*window.devicePixelRatio?this.inertiaStableFrames++:(s.copy(ie),this.inertiaStableFrames=0))}_applyRotation(e,t,i){if(0===e&&0===t)return;const{camera:r,minAltitude:a,maxAltitude:s,rotationSpeed:n}=this,o=-e*n;let l,c=t*n;if(z.set(0,0,1).transformDirection(r.matrixWorld),G.set(1,0,0).transformDirection(r.matrixWorld),this.getUpDirection(i,J),J.dot(z)>1-1e-10)l=0;else{V.crossVectors(J,z).normalize();l=Math.sign(V.dot(G))*J.angleTo(z)}c>0?(c=Math.min(l-a,c),c=Math.max(0,c)):(c=Math.max(l-s,c),c=Math.min(0,c)),W.setFromAxisAngle(J,o),P(i,W,I),r.matrixWorld.premultiply(I),G.set(1,0,0).transformDirection(r.matrixWorld),W.setFromAxisAngle(G,-c),P(i,W,I),r.matrixWorld.premultiply(I),r.matrixWorld.decompose(r.position,r.quaternion,V)}_setFrame(e){const{up:t,camera:i,zoomPoint:r,zoomDirectionSet:a,zoomPointSet:s,scaleZoomOrientationAtEdges:n}=this;if(a&&(s||this._updateZoomPoint())){if(W.setFromUnitVectors(t,e),n){this.getUpDirection(r,V);let e=Math.max(V.dot(t)-.6,0)/.4;e=l.MathUtils.mapLinear(e,0,.5,0,1),e=Math.min(e,1),i.isOrthographicCamera&&(e*=.1),W.slerp(Y,1-e)}P(r,W,I),i.updateMatrixWorld(),i.matrixWorld.premultiply(I),i.matrixWorld.decompose(i.position,i.quaternion,V),this.zoomDirectionSet=!1,this._updateZoomDirection()}t.copy(e),i.updateMatrixWorld()}_raycast(e){const{scene:t,useFallbackPlane:i,fallbackPlane:r}=this,a=e.intersectObject(t)[0]||null;if(a)return a;if(i){const t=r;if(e.ray.intersectPlane(t,V)){return{point:V.clone(),distance:e.ray.origin.distanceTo(V)}}}return null}_alignCameraUp(e,t=1){const{camera:i,state:r,pivotPoint:a,zoomPoint:s,zoomPointSet:n}=this;i.updateMatrixWorld(),z.set(0,0,-1).transformDirection(i.matrixWorld),G.set(-1,0,0).transformDirection(i.matrixWorld);let o=l.MathUtils.mapLinear(1-Math.abs(z.dot(e)),0,.2,0,1);o=l.MathUtils.clamp(o,0,1),t*=o,H.crossVectors(e,z),H.lerp(G,1-t).normalize(),W.setFromUnitVectors(G,H),i.quaternion.premultiply(W);let c=null;1===r||2===r?c=N.copy(a):n&&(c=N.copy(s)),c&&(O.copy(i.matrixWorld).invert(),V.copy(c).applyMatrix4(O),i.updateMatrixWorld(),V.applyMatrix4(i.matrixWorld),j.subVectors(c,V),i.position.add(j)),i.updateMatrixWorld()}_clampRotation(e){const{camera:t,minAltitude:i,maxAltitude:r,state:a,pivotPoint:s,zoomPoint:n,zoomPointSet:o}=this;let l,c;if(t.updateMatrixWorld(),z.set(0,0,1).transformDirection(t.matrixWorld),G.set(1,0,0).transformDirection(t.matrixWorld),e.dot(z)>1-1e-10)l=0;else{V.crossVectors(e,z);l=Math.sign(V.dot(G))*e.angleTo(z)}if(l>r)c=r;else{if(!(l<i))return;c=i}z.copy(e),W.setFromAxisAngle(G,c),z.applyQuaternion(W).normalize(),V.crossVectors(z,G).normalize(),I.makeBasis(G,V,z),t.quaternion.setFromRotationMatrix(I);let h=null;1===a||2===a?h=N.copy(s):o&&(h=N.copy(n)),h&&(O.copy(t.matrixWorld).invert(),V.copy(h).applyMatrix4(O),t.updateMatrixWorld(),V.applyMatrix4(t.matrixWorld),j.subVectors(h,V),t.position.add(j)),t.updateMatrixWorld()}}function ce(e){if(!e)return null;let t=e.length,i=e.indexOf("?"),r=e.indexOf("#");-1!==i&&(t=Math.min(t,i)),-1!==r&&(t=Math.min(t,r));let a=e.lastIndexOf(".",t),s=e.lastIndexOf("/",t),n=e.indexOf("://");return-1!==n&&n+2===s||-1===a||a<s?null:e.substring(a+1,t)||null}var he=(a(e=class{static setXRSession(e){e!==this.session&&(this.flushPending(),this.session=e)}static requestAnimationFrame(e){let t,{session:i,pending:r}=this,a=()=>{r.delete(t),e()};return t=i?i.requestAnimationFrame(a):requestAnimationFrame(a),r.set(t,e),t}static cancelAnimationFrame(e){let{pending:t,session:i}=this;t.delete(e),i?i.cancelAnimationFrame(e):cancelAnimationFrame(e)}static flushPending(){this.pending.forEach(((e,t)=>{e(),this.cancelAnimationFrame(t)}))}},"pending",new Map),a(e,"session",null),e),de=2**30,ue=class{get unloadPriorityCallback(){return this._unloadPriorityCallback}set unloadPriorityCallback(e){1===e.length?this._unloadPriorityCallback=(t,i)=>{let r=e(t),a=e(i);return r<a?-1:+(r>a)}:this._unloadPriorityCallback=e}constructor(){this.minSize=6e3,this.maxSize=8e3,this.minBytesSize=.3*de,this.maxBytesSize=.4*de,this.unloadPercent=.05,this.autoMarkUnused=!0,this.cachedBytes=0,this.itemSet=new Map,this.itemList=[],this.usedSet=new Set,this.callbacks=new Map,this.unloadingHandle=-1,this.bytesMap=new Map,this.loadedSet=new Set,this._unloadPriorityCallback=null;let e=this.itemSet;this.defaultPriorityCallback=t=>e.get(t)}isFull(){return this.itemSet.size>=this.maxSize||this.cachedBytes>=this.maxBytesSize}getMemoryUsage(e){return this.bytesMap.get(e)||0}setMemoryUsage(e,t){let{bytesMap:i,itemSet:r}=this;r.has(e)&&(this.cachedBytes-=i.get(e)||0,i.set(e,t),this.cachedBytes+=t)}add(e,t){let i=this.itemSet;if(i.has(e)||this.isFull())return!1;let r=this.usedSet,a=this.itemList,s=this.callbacks;return a.push(e),r.add(e),i.set(e,Date.now()),s.set(e,t),!0}has(e){return this.itemSet.has(e)}remove(e){let t=this.usedSet,i=this.itemSet,r=this.itemList,a=this.bytesMap,s=this.callbacks,n=this.loadedSet;if(i.has(e)){this.cachedBytes-=a.get(e)||0,a.delete(e),s.get(e)(e);let o=r.indexOf(e);return r.splice(o,1),t.delete(e),i.delete(e),s.delete(e),n.delete(e),!0}return!1}setLoaded(e,t){let{itemSet:i,loadedSet:r}=this;i.has(e)&&(!0===t?r.add(e):r.delete(e))}markUsed(e){let t=this.itemSet,i=this.usedSet;t.has(e)&&!i.has(e)&&(t.set(e,Date.now()),i.add(e))}markUnused(e){this.usedSet.delete(e)}markAllUnused(){this.usedSet.clear()}isUsed(e){return this.usedSet.has(e)}unloadUnusedContent(){let{unloadPercent:e,minSize:t,maxSize:i,itemList:r,itemSet:a,usedSet:s,loadedSet:n,callbacks:o,bytesMap:l,minBytesSize:c,maxBytesSize:h}=this,d=r.length-s.size,u=r.length-n.size,p=Math.max(Math.min(r.length-t,d),0),m=this.cachedBytes-c,f=this.unloadPriorityCallback||this.defaultPriorityCallback,g=!1,b=p>0&&d>0||u&&r.length>i;if(d&&this.cachedBytes>c||u&&this.cachedBytes>h||b){r.sort(((e,t)=>{let i=s.has(e);if(i===s.has(t)){let i=n.has(e);return i===n.has(t)?-f(e,t):i?1:-1}return i?1:-1}));let u=Math.max(t*e,p*e),b=Math.ceil(Math.min(u,d,p)),y=Math.max(e*m,e*c),v=Math.min(y,m),x=0,w=0;for(;this.cachedBytes-w>h||r.length-x>i;){let e=r[x],t=l.get(e)||0;if(s.has(e)&&n.has(e)||this.cachedBytes-w-t<h&&r.length-x<=i)break;w+=t,x++}for(;w<v||x<b;){let e=r[x],t=l.get(e)||0;if(s.has(e)||this.cachedBytes-w-t<c&&x>=b)break;w+=t,x++}r.splice(0,x).forEach((e=>{this.cachedBytes-=l.get(e)||0,o.get(e)(e),l.delete(e),a.delete(e),o.delete(e),n.delete(e),s.delete(e)})),g=x<p||w<m&&x<d,g&&(g=x>0)}g&&(this.unloadingHandle=he.requestAnimationFrame((()=>this.scheduleUnload())))}scheduleUnload(){he.cancelAnimationFrame(this.unloadingHandle),this.scheduled||(this.scheduled=!0,queueMicrotask((()=>{this.scheduled=!1,this.unloadUnusedContent()})))}},pe=class extends DOMException{constructor(){super("PriorityQueue: Item removed","AbortError")}},me=class{get running(){return 0!==this.items.length||0!==this.currJobs}constructor(){this.maxJobs=6,this.items=[],this.callbacks=new Map,this.currJobs=0,this.scheduled=!1,this.autoUpdate=!0,this.priorityCallback=null,this._schedulingCallback=e=>{he.requestAnimationFrame(e)},this._runjobs=()=>{this.scheduled=!1,this.tryRunJobs()}}sort(){let e=this.priorityCallback,t=this.items;null!==e&&t.sort(e)}has(e){return this.callbacks.has(e)}add(e,t){let i={callback:t,reject:null,resolve:null,promise:null};return i.promise=new Promise(((t,r)=>{let a=this.items,s=this.callbacks;i.resolve=t,i.reject=r,a.unshift(e),s.set(e,i),this.autoUpdate&&this.scheduleJobRun()})),i.promise}remove(e){let t=this.items,i=this.callbacks,r=t.indexOf(e);if(-1!==r){let a=i.get(e);a.promise.catch((e=>{if("AbortError"!==e.name)throw e})),a.reject(new pe),t.splice(r,1),i.delete(e)}}removeByFilter(e){let{items:t}=this;for(let i=0;i<t.length;i++){let r=t[i];e(r)&&(this.remove(r),i--)}}tryRunJobs(){this.sort();let e=this.items,t=this.callbacks,i=this.maxJobs,r=0,a=()=>{this.currJobs--,this.autoUpdate&&this.scheduleJobRun()};for(;i>this.currJobs&&e.length>0&&r<i;){this.currJobs++,r++;let i,n=e.pop(),{callback:o,resolve:l,reject:c}=t.get(n);t.delete(n);try{i=o(n)}catch(s){c(s),a();continue}i instanceof Promise?i.then(l).catch(c).finally(a):(l(i),a())}}flush(e){let{items:t,callbacks:i}=this,r=t.indexOf(e);if(!i.has(e))return;let a,{callback:s,resolve:n,reject:o}=i.get(e);i.delete(e),t.splice(r,1);try{a=s(e)}catch(l){return void o(l)}return a instanceof Promise?a.then(n).catch(o):n(a),a}scheduleJobRun(){this.scheduled||(this.scheduled=(this._schedulingCallback(this._runjobs),!0))}},fe=6378137,ge={inView:!1,error:1/0,distanceFromCamera:1/0};function be(e){return 4===e||-1===e}function ye(e,t){return ve(e)&&e.traversal.lastFrameVisited===t&&e.traversal.used}function ve(e){return!!e.traversal}function xe(e){let{children:t}=e,i=0===t.length||ve(t[t.length-1]),r=!e.internal.hasUnrenderableContent||be(e.internal.loadingState);return i&&r}function we(e){return e.traversal.unconditionallyRefine}function Te(e,t){if(ve(e)&&(t.ensureChildrenArePreprocessed(e),e.traversal.lastFrameVisited!==t.frameCount&&(e.traversal.wasInFrustum=e.traversal.inFrustum,e.traversal.wasSetActive=e.traversal.active,e.traversal.wasSetVisible=e.traversal.visible,e.traversal.usedLastFrame=e.traversal.used,e.traversal.lastFrameVisited=t.frameCount,e.traversal.used=!1,e.traversal.inFrustum=!1,e.traversal.isLeaf=!1,e.traversal.visible=!1,e.traversal.active=!1,e.traversal.error=1/0,e.traversal.distanceFromCamera=1/0,e.traversal.allChildrenReady=!1,e.traversal.allChildrenLoaded=!1,e.traversal.kicked=!1,e.traversal.allUsedChildrenProcessed=!1,t.calculateTileViewErrorWithPlugin(e,ge),e.traversal.inFrustum=ge.inView,e.traversal.error=ge.error,e.traversal.distanceFromCamera=ge.distanceFromCamera,e.traversal.unconditionallyRefine=e.internal.hasUnrenderableContent,!e.traversal.unconditionallyRefine))){let t=e.parent;for(;t&&t.traversal.unconditionallyRefine;)t=t.parent;t&&t.geometricError<=e.geometricError&&(e.traversal.unconditionallyRefine=!0)}}function _e(e,t,i=!1){if(Te(e,t),i?t.markTileUsed(e):Se(e),we(e)&&xe(e)){let r=e.children;for(let e=0,a=r.length;e<a;e++)_e(r[e],t,i)}}function Ae(e,t){if(Te(e,t),e.traversal.usedLastFrame&&(Se(e),e.traversal.wasSetActive&&(e.traversal.active=!0),(!e.traversal.active||we(e))&&xe(e))){let i=e.children;for(let e=0,r=i.length;e<r;e++)Ae(i[e],t)}}function Se(e){e.traversal.used=!0}function Me(e,t){let{frameCount:i}=t,{children:r}=e;for(let a=0,s=r.length;a<s;a++){let e=r[a];ye(e,i)&&(e.traversal.active&&(e.traversal.kicked=!0,e.traversal.active=!1),Me(e,t))}}function Ce(e){return!we(e)&&(!e.internal.hasContent||be(e.internal.loadingState))}function Ee(e,t){if(Te(e,t),!e.traversal.inFrustum)return;let i=e.parent;if(i&&"ADD"===i.refine&&e.geometricError>0&&e.traversal.error*(i.geometricError/e.geometricError)<=t.errorTarget)return;if(!function(e,t){return!(e.traversal.error<=t.errorTarget&&!we(e)||t.maxDepth>0&&e.internal.depth+1>=t.maxDepth||!xe(e))}(e,t))return void Se(e);let r=!1,a=!1,s=e.children;for(let n=0,o=s.length;n<o;n++){let e=s[n];Ee(e,t),r||(r=ye(e,t.frameCount)),a||(a=e.traversal.inFrustum)}if("REPLACE"!==e.refine||a||0===s.length){if(Se(e),"REPLACE"===e.refine&&r&&(t.loadSiblings||t.loadAncestors))for(let n=0,o=s.length;n<o;n++)_e(s[n],t)}else{e.traversal.inFrustum=!1,t.markTileUsed(e);for(let e=0,i=s.length;e<i;e++)_e(s[e],t,!0)}}function Re(e,t){let i=t.frameCount;if(!ye(e,i))return;let r=e.children,a=!1;for(let n=0,o=r.length;n<o;n++){let e=r[n];a||(a=ye(e,i))}if(a){for(let e=0,i=r.length;e<i;e++)Re(r[e],t);let a=!0;for(let e=0,t=r.length;e<t;e++){let t=r[e];if(ye(t,i)){let e=!we(t),i=!t.internal.hasContent||be(t.internal.loadingState);e&&i||t.traversal.allChildrenLoaded||(a=!1)}}e.traversal.allChildrenLoaded=a}else e.traversal.isLeaf=!0;let s=!0;for(let n=0,o=r.length;n<o;n++){let e=r[n];ye(e,t.frameCount)&&!e.traversal.allUsedChildrenProcessed&&(s=!1)}e.traversal.allUsedChildrenProcessed=s&&xe(e)}function ke(e,t){if(!ye(e,t.frameCount))return;let i=e.children;if("REPLACE"===e.refine&&t.loadAncestors&&!e.traversal.allChildrenLoaded&&!we(e)&&(e.traversal.isLeaf=!0),e.traversal.isLeaf){if(!we(e)&&(e.traversal.active=!0,xe(e)&&e.internal.hasContent&&!be(e.internal.loadingState)))for(let e=0,r=i.length;e<r;e++)Ae(i[e],t);return}let r=i.length>0;for(let a=0,s=i.length;a<s;a++){let e=i[a];ke(e,t),ye(e,t.frameCount)&&(!e.traversal.active||!Ce(e))&&!e.traversal.allChildrenReady&&(r=!1)}e.traversal.allChildrenReady=r,"REPLACE"===e.refine&&!r&&e.traversal.wasSetActive&&Ce(e)&&(e.traversal.active=!0,Me(e,t))}function Pe(e,t){Te(e,t);let i=ye(e,t.frameCount);if(i&&(e.internal.hasUnrenderableContent&&(t.markTileUsed(e),t.queueTileForDownload(e)),e.internal.hasRenderableContent&&"ADD"===e.refine&&(e.traversal.active=!0),(e.traversal.active||e.traversal.kicked)&&e.internal.hasContent&&(t.markTileUsed(e),e.traversal.allUsedChildrenProcessed&&t.queueTileForDownload(e),4!==e.internal.loadingState&&(e.traversal.active=!1)),t.loadAncestors&&e.internal.hasContent&&(t.markTileUsed(e),t.queueTileForDownload(e)),e.internal.virtualChildCount>0&&e.internal.hasContent&&t.markTileUsed(e),e.traversal.visible=e.internal.hasRenderableContent&&e.traversal.active&&e.traversal.inFrustum&&4===e.internal.loadingState,t.stats.used++,e.traversal.inFrustum&&t.stats.inFrustum++),i||ve(e)&&e.traversal.usedLastFrame){let r=!1,a=!1;i?(r=e.traversal.active,a=t.displayActiveTiles&&e.traversal.active||e.traversal.visible):Te(e,t),e.internal.hasRenderableContent&&4===e.internal.loadingState?(r&&t.stats.active++,a&&t.stats.visible++,e.traversal.wasSetActive!==r&&t.invokeOnePlugin((t=>t.setTileActive&&t.setTileActive(e,r))),e.traversal.wasSetVisible!==a&&t.invokeOnePlugin((t=>t.setTileVisible&&t.setTileVisible(e,a)))):e.internal.hasRenderableContent||(a=e.traversal.isLeaf,e.traversal.wasSetVisible!==a&&t.invokeOnePlugin((t=>t.setEmptyTileVisible&&t.setEmptyTileVisible(e,a)))),e.traversal.visible=a,e.traversal.active=r;let s=e.children;for(let e=0,i=s.length;e<i;e++){Pe(s[e],t)}}}function Fe(e,t){Ee(e,t),Re(e,t),ke(e,t),Pe(e,t)}function Le(e,t=null,i=null){let r=[];for(r.push(e),r.push(null),r.push(0);r.length>0;){let e=r.pop(),a=r.pop(),s=r.pop();if(t&&t(s,a,e))return void(i&&i(s,a,e));let n=s.children;if(n)for(let t=n.length-1;t>=0;t--)r.push(n[t]),r.push(s),r.push(e+1);i&&i(s,a,e)}}var De=Symbol("PLUGIN_REGISTERED"),Ue={inView:!0,error:0,distance:1/0},Ie=(e,t)=>{let i=e.priority??1/0,r=t.priority??1/0;if(i!==r)return i>r?1:-1;if(!e.internal||!t.internal)return 0;let a=e.internal.renderer,s=t.internal.renderer,n=!a.loadAncestors,o=!s.loadAncestors;return n&&o?((e,t)=>e.traversal.used===t.traversal.used?e.traversal.inFrustum===t.traversal.inFrustum?e.internal.hasUnrenderableContent===t.internal.hasUnrenderableContent?e.traversal.distanceFromCamera===t.traversal.distanceFromCamera?e.internal.depthFromRenderedParent===t.internal.depthFromRenderedParent?0:e.internal.depthFromRenderedParent>t.internal.depthFromRenderedParent?-1:1:e.traversal.distanceFromCamera>t.traversal.distanceFromCamera?-1:1:e.internal.hasUnrenderableContent?1:-1:e.traversal.inFrustum?1:-1:e.traversal.used?1:-1)(e,t):((e,t)=>{let i=e.priority||0,r=t.priority||0;return i===r?e.traversal&&t.traversal?e.traversal.used===t.traversal.used?e.traversal.error===t.traversal.error?e.traversal.distanceFromCamera===t.traversal.distanceFromCamera?e.internal.depthFromRenderedParent===t.internal.depthFromRenderedParent?0:e.internal.depthFromRenderedParent>t.internal.depthFromRenderedParent?-1:1:e.traversal.distanceFromCamera>t.traversal.distanceFromCamera?-1:1:e.traversal.error>t.traversal.error?1:-1:e.traversal.used?1:-1:0:i>r?1:-1})(e,t)},Oe=new ue;Oe.unloadPriorityCallback=(e,t)=>e.traversal.lastFrameVisited===t.traversal.lastFrameVisited?e.internal.depthFromRenderedParent===t.internal.depthFromRenderedParent?e.internal.loadingState===t.internal.loadingState?e.internal.hasUnrenderableContent===t.internal.hasUnrenderableContent?e.traversal.error===t.traversal.error?0:e.traversal.error>t.traversal.error?-1:1:e.internal.hasUnrenderableContent?-1:1:e.internal.loadingState>t.internal.loadingState?-1:1:e.internal.depthFromRenderedParent>t.internal.depthFromRenderedParent?1:-1:e.traversal.lastFrameVisited>t.traversal.lastFrameVisited?-1:1;var Be=new class{get running(){for(let e of this.originQueues.values())if(e.running)return!0;return!1}get maxJobsPerOrigin(){return this._maxJobsPerOrigin}set maxJobsPerOrigin(e){this._maxJobsPerOrigin=e,this.originQueues.forEach((t=>t.maxJobs=e))}get maxJobs(){return this.maxJobsPerOrigin}set maxJobs(e){this.maxJobsPerOrigin=e}get priorityCallback(){return this._priorityCallback}set priorityCallback(e){this._priorityCallback=e,this.originQueues.forEach((t=>t.priorityCallback=e))}constructor(){this.originQueues=new Map,this._itemQueues=new WeakMap,this._maxJobsPerOrigin=6,this._priorityCallback=null}add(e,t,i,r=null){this.originQueues.forEach(((e,t)=>{e.running||this.originQueues.delete(t)}));let a=null===e?null:function(e){try{let t=typeof location<"u"?location.href:void 0;return new URL(e,t).origin}catch{return null}}(e),s=this.originQueues.get(a);s||(s=new me,s.maxJobs=this._maxJobsPerOrigin,s.priorityCallback=this._priorityCallback,this.originQueues.set(a,s));let n=this._itemQueues.get(t);if(n&&n!==s&&n.has(t))throw Error("DownloadPriorityQueue: Item is already queued with a different url origin.");this._itemQueues.set(t,s);let o=s.add(t,i);return null!==r&&(r.aborted?this.remove(t):r.addEventListener("abort",(()=>this.remove(t)),{once:!0})),o}remove(e){let t=this._itemQueues.get(e);t&&(t.remove(e),this._itemQueues.delete(e))}has(e){let t=this._itemQueues.get(e);return!(!t||!t.has(e))}};Be.maxJobsPerOrigin=25,Be.priorityCallback=Ie;var Ve=new me;Ve.maxJobs=5,Ve.priorityCallback=Ie;var Ne=new me;Ne.maxJobs=25,Ne.priorityCallback=(e,t)=>{let i=e.parent,r=t.parent;return i===r?0:i?r?Ie(i,r):-1:1};var je=class{get root(){let e=this.rootTileset;return e?e.root:null}get loadProgress(){let{stats:e,isLoading:t}=this,i=e.queued+e.downloading+e.parsing,r=e.inCacheSinceLoad+ +!!t;return 0===r?1:1-i/r}get downloadQueue(){return this._downloadQueue}set downloadQueue(e){e instanceof me||(this._downloadQueue=e)}constructor(e=null){this.rootLoadingState=0,this.rootTileset=null,this.rootURL=e,this.fetchOptions={},this.plugins=[],this.queuedTiles=[],this.cachedSinceLoadComplete=new Set,this.isLoading=!1,this.processedTiles=new WeakSet,this.visibleTiles=new Set,this.activeTiles=new Set,this.usedSet=new Set,this.loadingTiles=new Set,this.lruCache=Oe,this.downloadQueue=Be,this.parseQueue=Ve,this.processNodeQueue=Ne,this.stats={inCacheSinceLoad:0,inCache:0,queued:0,downloading:0,parsing:0,loaded:0,failed:0,inFrustum:0,used:0,active:0,visible:0,tilesProcessed:0},this.frameCount=0,this._dispatchNeedsUpdateEvent=function(e){let t=null;return()=>{null===t&&(t=he.requestAnimationFrame((()=>{t=null,e()})))}}((()=>{this.dispatchEvent({type:"needs-update"})})),this.errorTarget=16,this.errorFalloff=0,this.errorFalloffDensity=2e-4,this.displayActiveTiles=!1,this.maxDepth=1/0,this.loadSiblings=!0,this.loadAncestors=!0,this.maxTilesProcessed=250}registerPlugin(e){if(!0===e[De])throw Error("TilesRendererBase: A plugin can only be registered to a single tileset");let t=this.plugins,i=e.priority||0,r=t.length;for(let a=0;a<t.length;a++)if((t[a].priority||0)>i){r=a;break}t.splice(r,0,e),e[De]=!0,e.init&&e.init(this)}unregisterPlugin(e){let t=this.plugins;if("string"==typeof e&&(e=this.getPluginByName(e)),t.includes(e)){let i=t.indexOf(e);return t.splice(i,1),e.dispose&&e.dispose(),!0}return!1}getPluginByName(e){return this.plugins.find((t=>t.name===e))||null}invokeOnePlugin(e){let t=[...this.plugins,this];for(let i=0;i<t.length;i++){let r=e(t[i]);if(r)return r}return null}invokeAllPlugins(e){let t=[...this.plugins,this],i=[];for(let r=0;r<t.length;r++){let a=e(t[r]);a&&i.push(a)}return 0===i.length?null:Promise.all(i)}traverse(e,t,i=!0){this.root&&Le(this.root,((t,...r)=>(i&&this.ensureChildrenArePreprocessed(t,!0),!!e&&e(t,...r))),t)}getAttributions(e=[]){return this.invokeAllPlugins((t=>t!==this&&t.getAttributions&&t.getAttributions(e))),e}update(){let{lruCache:e,usedSet:t,stats:i,root:r,downloadQueue:a,parseQueue:s,processNodeQueue:n}=this;if(0===this.rootLoadingState&&(this.rootLoadingState=2,this.invokeOnePlugin((e=>e.loadRootTileset&&e.loadRootTileset())).then((e=>{let t=this.rootURL;null!==t&&this.invokeAllPlugins((e=>t=e.preprocessURL?e.preprocessURL(t,null):t)),this.rootLoadingState=4,this.rootTileset=e,this.dispatchEvent({type:"needs-update"}),this.dispatchEvent({type:"load-tileset",tileset:e,url:t}),this.dispatchEvent({type:"load-root-tileset",tileset:e,url:t})})).catch((e=>{this.rootLoadingState=-1,this.rootTileset=null,this.dispatchEvent({type:"load-error",tile:null,error:e,url:this.rootURL})}))),!r)return;let o=null;if(this.invokeAllPlugins((e=>{if(e.doTilesNeedUpdate){let t=e.doTilesNeedUpdate();o=null===o?t:!(!o&&!t)}})),!1===o)return this.dispatchEvent({type:"update-before"}),void this.dispatchEvent({type:"update-after"});this.dispatchEvent({type:"update-before"}),i.inFrustum=0,i.used=0,i.active=0,i.visible=0,i.tilesProcessed=0,this.frameCount++,t.forEach((t=>e.markUnused(t))),t.clear(),this.prepareForTraversal(),Fe(r,this),this.removeUnusedPendingTiles();let l=this.queuedTiles;l.sort(e.unloadPriorityCallback);for(let c=0,h=l.length;c<h&&!e.isFull();c++)this.requestTileContents(l[c]);l.length=0,e.scheduleUnload(),!1===(a.running||s.running||n.running)&&!0===this.isLoading&&(this.cachedSinceLoadComplete.clear(),i.inCacheSinceLoad=0,this.dispatchEvent({type:"tiles-load-end"}),this.isLoading=!1),this.dispatchEvent({type:"update-after"})}resetFailedTiles(){-1===this.rootLoadingState&&(this.rootLoadingState=0);let e=this.stats;0!==e.failed&&(this.traverse((e=>{-1===e.internal.loadingState&&(e.internal.loadingState=0)}),null,!1),e.failed=0)}calculateTileViewErrorWithPlugin(e,t){this.calculateTileViewError(e,t);let{errorFalloff:i,errorFalloffDensity:r}=this;if(i>0&&Number.isFinite(t.distanceFromCamera)){let e=t.distanceFromCamera*r;t.error-=i*(1-Math.exp(-e*e))}let a=null,s=0,n=1/0;this.invokeAllPlugins((t=>{t!==this&&t.calculateTileViewError&&(Ue.inView=!0,Ue.error=0,Ue.distance=1/0,t.calculateTileViewError(e,Ue)&&(null===a&&(a=!0),a&&(a=Ue.inView),Ue.inView&&(n=Math.min(n,Ue.distance),s=Math.max(s,Ue.error))))})),t.inView&&!1!==a?(t.error=Math.max(t.error,s),t.distanceFromCamera=Math.min(t.distanceFromCamera,n)):a?(t.inView=!0,t.error=s,t.distanceFromCamera=n):t.inView=!1}dispose(){[...this.plugins].forEach((e=>{this.unregisterPlugin(e)}));let e=this.lruCache,t=[];this.traverse((e=>(t.push(e),!1)),null,!1);for(let i=0,r=t.length;i<r;i++)e.remove(t[i]);this.stats={queued:0,parsing:0,downloading:0,failed:0,inFrustum:0,traversed:0,used:0,active:0,visible:0},this.frameCount=0,this.loadingTiles.clear()}calculateBytesUsed(e,t){return 0}dispatchEvent(e){}addEventListener(e,t){}removeEventListener(e,t){}parseTile(e,t,i){return null}prepareForTraversal(){}disposeTile(e){e.traversal.visible&&(e.internal.hasRenderableContent?this.invokeOnePlugin((t=>t.setTileVisible&&t.setTileVisible(e,!1))):this.invokeOnePlugin((t=>t.setEmptyTileVisible&&t.setEmptyTileVisible(e,!1))),e.traversal.visible=!1),e.traversal.active&&e.internal.hasRenderableContent&&this.invokeOnePlugin((t=>t.setTileActive&&t.setTileActive(e,!1))),e.traversal.active=!1;let{scene:t}=e.engineData;t&&this.dispatchEvent({type:"dispose-model",scene:t,tile:e})}preprocessNode(e,t,i=null){var r;if(this.processedTiles.add(e),this.stats.tilesProcessed++,e.content&&(!("uri"in e.content)&&"url"in e.content&&(e.content.uri=e.content.url,delete e.content.url),e.content.boundingVolume&&!("box"in e.content.boundingVolume||"sphere"in e.content.boundingVolume||"region"in e.content.boundingVolume)&&delete e.content.boundingVolume),e.parent=i,e.children=e.children||[],e.internal={hasContent:!1,hasRenderableContent:!1,hasUnrenderableContent:!1,loadingState:0,basePath:t,depth:-1,depthFromRenderedParent:-1,isVirtual:!1,virtualChildCount:0,renderer:this,...e.internal},null==(r=e.content)?void 0:r.uri){let t=ce(e.content.uri),i=!(!t||!/json$/.test(t));e.internal.hasContent=!0,e.internal.hasUnrenderableContent=i,e.internal.hasRenderableContent=!i}else e.internal.hasContent=!1,e.internal.hasUnrenderableContent=!1,e.internal.hasRenderableContent=!1;i?(e.internal.depth=i.internal.depth+1,e.internal.depthFromRenderedParent=i.internal.depthFromRenderedParent+ +!!e.internal.hasRenderableContent):(e.internal.depth=0,e.internal.depthFromRenderedParent=+!!e.internal.hasRenderableContent),e.traversal={distanceFromCamera:1/0,error:1/0,inFrustum:!1,wasInFrustum:!1,isLeaf:!1,used:!1,usedLastFrame:!1,visible:!1,wasSetVisible:!1,active:!1,wasSetActive:!1,allChildrenReady:!1,allChildrenLoaded:!1,kicked:!1,allUsedChildrenProcessed:!1,lastFrameVisited:-1},e.refine=null===i?e.refine||"REPLACE":e.refine||i.refine,e.engineData={scene:null,metadata:null,boundingVolume:null},Object.defineProperty(e,"cached",{get(){return this.engineData},enumerable:!1,configurable:!0}),this.invokeAllPlugins((r=>{r!==this&&r.preprocessNode&&r.preprocessNode(e,t,i)}))}setTileActive(e,t){t?this.activeTiles.add(e):this.activeTiles.delete(e)}setTileVisible(e,t){t?this.visibleTiles.add(e):this.visibleTiles.delete(e),this.dispatchEvent({type:"tile-visibility-change",scene:e.engineData.scene,tile:e,visible:t})}calculateTileViewError(e,t){}removeUnusedPendingTiles(){let{lruCache:e,loadingTiles:t}=this,i=[];for(let r of t)!e.isUsed(r)&&1===r.internal.loadingState&&i.push(r);for(let r=0;r<i.length;r++)e.remove(i[r])}queueTileForDownload(e){0!==e.internal.loadingState||this.lruCache.isFull()||this.queuedTiles.push(e)}markTileUsed(e){this.usedSet.add(e),this.lruCache.markUsed(e)}fetchData(e,t){return fetch(e,t)}ensureChildrenArePreprocessed(e,t=this.stats.tilesProcessed<this.maxTilesProcessed){let i=e.children;if(0===i.length||i[i.length-1].traversal)return;let r=t=>{for(let i=0,r=t.length;i<r;i++){let r=t[i];r&&!r.traversal&&this.preprocessNode(r,e.internal.basePath,e)}};t?(this.processNodeQueue.remove(e),r(i)):this.processNodeQueue.has(e)||this.processNodeQueue.add(e,(e=>{r(e.children),this._dispatchNeedsUpdateEvent()}))}getBytesUsed(e){let t=0;return this.invokeAllPlugins((i=>{i.calculateBytesUsed&&(t+=i.calculateBytesUsed(e,e.engineData.scene)||0)})),t}recalculateBytesUsed(e=null){let{lruCache:t,processedTiles:i}=this;null===e?t.itemSet.forEach((e=>{i.has(e)&&t.setMemoryUsage(e,this.getBytesUsed(e))})):t.setMemoryUsage(e,this.getBytesUsed(e))}preprocessTileset(e,t,i=null){let[r,a]=e.asset.version.split(".").map((e=>parseInt(e))),s=t.replace(/\/[^/]*$/,"");s=new URL(s,window.location.href).toString(),this.preprocessNode(e.root,s,i)}loadRootTileset(){let e=this.rootURL;return this.invokeAllPlugins((t=>e=t.preprocessURL?t.preprocessURL(e,null):e)),this.invokeOnePlugin((t=>t.fetchData&&t.fetchData(e,this.fetchOptions))).then((t=>{if(!(t instanceof Response))return t;if(t.ok)return t.json();throw Error(`TilesRenderer: Failed to load tileset "${e}" with status ${t.status} : ${t.statusText}`)})).then((t=>(this.preprocessTileset(t,e),t)))}requestTileContents(e){if(0!==e.internal.loadingState)return;let t=!1,i=null,r=new URL(e.content.uri,e.internal.basePath+"/").toString();this.invokeAllPlugins((t=>r=t.preprocessURL?t.preprocessURL(r,e):r));let a=this.stats,s=this.lruCache,n=this.downloadQueue,o=this.parseQueue,l=this.loadingTiles,c=ce(r),h=new AbortController,d=h.signal;return s.add(e,(i=>{h.abort(),t?i.children.length=0:this.invokeAllPlugins((e=>{e.disposeTile&&e.disposeTile(i)})),a.inCache--,this.cachedSinceLoadComplete.has(e)&&(this.cachedSinceLoadComplete.delete(e),a.inCacheSinceLoad--),1===i.internal.loadingState?a.queued--:2===i.internal.loadingState?a.downloading--:3===i.internal.loadingState?a.parsing--:4===i.internal.loadingState&&a.loaded--,i.internal.loadingState=0,o.remove(i),n.remove(i),l.delete(i)}))?(this.isLoading||(this.isLoading=!0,this.dispatchEvent({type:"tiles-load-start"})),s.setMemoryUsage(e,this.getBytesUsed(e)),this.cachedSinceLoadComplete.add(e),a.inCacheSinceLoad++,a.inCache++,a.queued++,e.internal.loadingState=1,l.add(e),n.add(r,e,(t=>{if(d.aborted)return Promise.resolve();e.internal.loadingState=2,a.downloading++,a.queued--;let i=this.invokeOnePlugin((e=>e.fetchData&&e.fetchData(r,{...this.fetchOptions,signal:d})));return this.dispatchEvent({type:"tile-download-start",tile:e,url:r,get uri(){return this.url}}),i})).then((e=>{if(!d.aborted){if(!(e instanceof Response))return e;if(e.ok)return"json"===c?e.json():e.arrayBuffer();throw Error(`Failed to load model with error code ${e.status}`)}})).then((s=>{if(!d.aborted)return a.downloading--,a.parsing++,e.internal.loadingState=3,o.add(e,(a=>d.aborted?Promise.resolve():"json"===c&&s.root?(this.preprocessTileset(s,r,e),e.children.push(s.root),i=s,t=!0,Promise.resolve()):this.invokeOnePlugin((e=>e.parseTile&&e.parseTile(s,a,c,r,d)))))})).then((()=>{if(d.aborted)return;a.parsing--,a.loaded++,e.internal.loadingState=4,l.delete(e),s.setLoaded(e,!0);let n=this.getBytesUsed(e);0===s.getMemoryUsage(e)&&n>0&&s.isFull()?s.remove(e):(s.setMemoryUsage(e,n),this.dispatchEvent({type:"needs-update"}),t&&this.dispatchEvent({type:"load-tileset",tileset:i,url:r}),e.engineData.scene&&this.dispatchEvent({type:"load-model",scene:e.engineData.scene,tile:e,url:r}))})).catch((t=>{d.aborted||("AbortError"===t.name?s.remove(e):(o.remove(e),n.remove(e),1===e.internal.loadingState?a.queued--:2===e.internal.loadingState?a.downloading--:3===e.internal.loadingState?a.parsing--:4===e.internal.loadingState&&a.loaded--,a.failed++,e.internal.loadingState=-1,l.delete(e),s.setLoaded(e,!0),this.dispatchEvent({type:"load-error",tile:e,error:t,url:r})))}))):void 0}};function ze(e){if(null===e||e.byteLength<4)return"";let t;if(t=e instanceof DataView?e:new DataView(e),"{"===String.fromCharCode(t.getUint8(0)))return null;let i="";for(let r=0;r<4;r++)i+=String.fromCharCode(t.getUint8(r));return i}var Ge=new TextDecoder;function He(e){return Ge.decode(e)}function qe(e){return e.replace(/[\\/][^\\/]+$/,"")+"/"}var We=class{constructor(){this.fetchOptions={},this.workingPath=""}loadAsync(e){return fetch(e,this.fetchOptions).then((t=>{if(!t.ok)throw Error(`Failed to load file "${e}" with status ${t.status} : ${t.statusText}`);return t.arrayBuffer()})).then((t=>(""===this.workingPath&&(this.workingPath=qe(e)),this.parse(t))))}resolveExternalURL(e){return new URL(e,this.workingPath).href}parse(e){throw Error("LoaderBase: Parse not implemented.")}};function Ke(e,t,i,r,a,s){let n;switch(r){case"SCALAR":n=1;break;case"VEC2":n=2;break;case"VEC3":n=3;break;case"VEC4":n=4;break;default:throw Error(`FeatureTable : Feature type not provided for "${s}".`)}let o,l=i*n;switch(a){case"BYTE":o=new Int8Array(e,t,l);break;case"UNSIGNED_BYTE":o=new Uint8Array(e,t,l);break;case"SHORT":o=new Int16Array(e,t,l);break;case"UNSIGNED_SHORT":o=new Uint16Array(e,t,l);break;case"INT":o=new Int32Array(e,t,l);break;case"UNSIGNED_INT":o=new Uint32Array(e,t,l);break;case"FLOAT":o=new Float32Array(e,t,l);break;case"DOUBLE":o=new Float64Array(e,t,l);break;default:throw Error(`FeatureTable : Feature component type not provided for "${s}".`)}return o}var Je=class{constructor(e,t,i,r){this.buffer=e,this.binOffset=t+i,this.binLength=r;let a=null;if(0!==i){let r=new Uint8Array(e,t,i);a=JSON.parse(He(r))}else a={};this.header=a}getKeys(){return Object.keys(this.header).filter((e=>"extensions"!==e))}getData(e,t,i=null,r=null){let a=this.header;if(!(e in a))return null;let s=a[e];if(!(s instanceof Object)||Array.isArray(s))return s;{let{buffer:a,binOffset:n,binLength:o}=this,l=s.byteOffset||0,c=s.type||r,h=s.componentType||i;if("type"in s&&r&&s.type!==r)throw Error("FeatureTable: Specified type does not match expected type.");let d=n+l,u=Ke(a,d,t,c,h,e);if(d+u.byteLength>n+o)throw Error("FeatureTable: Feature data read outside binary body length.");return u}}getBuffer(e,t){let{buffer:i,binOffset:r}=this;return i.slice(r+e,r+e+t)}},Xe=class{constructor(e){this.batchTable=e;let t=e.header.extensions["3DTILES_batch_table_hierarchy"];this.classes=t.classes;for(let r of this.classes){let e=r.instances;for(let t in e)r.instances[t]=this._parseProperty(e[t],r.length,t)}if(this.instancesLength=t.instancesLength,this.classIds=this._parseProperty(t.classIds,this.instancesLength,"classIds"),t.parentCounts?this.parentCounts=this._parseProperty(t.parentCounts,this.instancesLength,"parentCounts"):this.parentCounts=Array(this.instancesLength).fill(1),t.parentIds){let e=this.parentCounts.reduce(((e,t)=>e+t),0);this.parentIds=this._parseProperty(t.parentIds,e,"parentIds")}else this.parentIds=null;this.instancesIds=[];let i={};for(let r of this.classIds)i[r]=i[r]??0,this.instancesIds.push(i[r]),i[r]++}_parseProperty(e,t,i){if(Array.isArray(e))return e;{let{buffer:r,binOffset:a}=this.batchTable;return Ke(r,a+e.byteOffset,t,"SCALAR",e.componentType||"UNSIGNED_SHORT",i)}}getDataFromId(e,t={}){let i=this.parentCounts[e];if(this.parentIds&&i>0){let r=0;for(let t=0;t<e;t++)r+=this.parentCounts[t];for(let a=0;a<i;a++){let i=this.parentIds[r+a];i!==e&&this.getDataFromId(i,t)}}let r=this.classIds[e],a=this.classes[r].instances,s=this.classes[r].name,n=this.instancesIds[e];for(let o in a)t[s]=t[s]||{},t[s][o]=a[o][n];return t}},Qe=class extends Je{constructor(e,t,i,r,a){super(e,i,r,a),this.count=t,this.extensions={};let s=this.header.extensions;s&&s["3DTILES_batch_table_hierarchy"]&&(this.extensions["3DTILES_batch_table_hierarchy"]=new Xe(this))}getDataFromId(e,t={}){if(e<0||e>=this.count)throw Error(`BatchTable: id value "${e}" out of bounds for "${this.count}" features number.`);for(let i of this.getKeys())t[i]=super.getData(i,this.count)[e];for(let i in this.extensions){let r=this.extensions[i];r.getDataFromId instanceof Function&&(t[i]=t[i]||{},r.getDataFromId(e,t[i]))}return t}getPropertyArray(e){return super.getData(e,this.count)}},Ye=class extends We{parse(e){let t=new DataView(e),i=(ze(t),t.getUint32(4,!0)),r=t.getUint32(8,!0),a=t.getUint32(12,!0),s=t.getUint32(16,!0),n=t.getUint32(20,!0),o=t.getUint32(24,!0),l=new Je(e.slice(28,28+a+s),0,a,s),c=28+a+s,h=new Qe(e.slice(c,c+n+o),l.getData("BATCH_LENGTH"),0,n,o),d=c+n+o;return{version:i,featureTable:l,batchTable:h,glbBytes:new Uint8Array(e,d,r-d)}}},Ze=class extends We{parse(e){let t=new DataView(e),i=(ze(t),t.getUint32(4,!0)),r=t.getUint32(8,!0),a=t.getUint32(12,!0),s=t.getUint32(16,!0),n=t.getUint32(20,!0),o=t.getUint32(24,!0),l=t.getUint32(28,!0),c=new Je(e.slice(32,32+a+s),0,a,s),h=32+a+s,d=new Qe(e.slice(h,h+n+o),c.getData("INSTANCES_LENGTH"),0,n,o),u=h+n+o,p=new Uint8Array(e,u,r-u),m=null,f=null,g=null;if(l)m=p,f=Promise.resolve();else{let e=this.resolveExternalURL(He(p));g=qe(e),f=fetch(e,this.fetchOptions).then((t=>{if(!t.ok)throw Error(`I3DMLoaderBase : Failed to load file "${e}" with status ${t.status} : ${t.statusText}`);return t.arrayBuffer()})).then((e=>{m=new Uint8Array(e)}))}return f.then((()=>({version:i,featureTable:c,batchTable:d,glbBytes:m,gltfWorkingPath:g})))}},$e=class extends We{parse(e){let t=new DataView(e),i=(ze(t),t.getUint32(4,!0)),r=(t.getUint32(8,!0),t.getUint32(12,!0)),a=t.getUint32(16,!0),s=t.getUint32(20,!0),n=t.getUint32(24,!0),o=new Je(e.slice(28,28+r+a),0,r,a),l=28+r+a,c=new Qe(e.slice(l,l+s+n),o.getData("BATCH_LENGTH")||o.getData("POINTS_LENGTH"),0,s,n);return Promise.resolve({version:i,featureTable:o,batchTable:c})}},et=class extends We{parse(e){let t=new DataView(e),i=(ze(t),t.getUint32(4,!0)),r=(t.getUint32(8,!0),t.getUint32(12,!0)),a=[],s=16;for(let n=0;n<r;n++){let t=new DataView(e,s,12),i=ze(t),r=t.getUint32(4,!0),n=t.getUint32(8,!0),o=new Uint8Array(e,s,n);a.push({type:i,buffer:o,version:r}),s+=n}return{version:i,tiles:a}}};function tt(e,t){if(t===l.TrianglesDrawMode)return e;if(t===l.TriangleFanDrawMode||t===l.TriangleStripDrawMode){let i=e.getIndex();if(null===i){const t=[],r=e.getAttribute("position");if(void 0===r)return e;for(let e=0;e<r.count;e++)t.push(e);e.setIndex(t),i=e.getIndex()}const r=i.count-2,a=[];if(t===l.TriangleFanDrawMode)for(let e=1;e<=r;e++)a.push(i.getX(0)),a.push(i.getX(e)),a.push(i.getX(e+1));else for(let e=0;e<r;e++)e%2==0?(a.push(i.getX(e)),a.push(i.getX(e+1)),a.push(i.getX(e+2))):(a.push(i.getX(e+2)),a.push(i.getX(e+1)),a.push(i.getX(e)));return a.length,e.setIndex(a),e.clearGroups(),e}return e}function it(e){const t=new Map,i=new Map,r=e.clone();return rt(e,r,(function(e,r){t.set(r,e),i.set(e,r)})),r.traverse((function(e){if(!e.isSkinnedMesh)return;const r=e,a=t.get(e),s=a.skeleton.bones;r.skeleton=a.skeleton.clone(),r.bindMatrix.copy(a.bindMatrix),r.skeleton.bones=s.map((function(e){return i.get(e)})),r.bind(r.skeleton,r.bindMatrix)})),r}function rt(e,t,i){i(e,t);for(let r=0;r<e.children.length;r++)rt(e.children[r],t.children[r],i)}class at extends l.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new dt(e)})),this.register((function(e){return new ut(e)})),this.register((function(e){return new wt(e)})),this.register((function(e){return new Tt(e)})),this.register((function(e){return new _t(e)})),this.register((function(e){return new mt(e)})),this.register((function(e){return new ft(e)})),this.register((function(e){return new gt(e)})),this.register((function(e){return new bt(e)})),this.register((function(e){return new ht(e)})),this.register((function(e){return new yt(e)})),this.register((function(e){return new pt(e)})),this.register((function(e){return new xt(e)})),this.register((function(e){return new vt(e)})),this.register((function(e){return new lt(e)})),this.register((function(e){return new At(e,ot.EXT_MESHOPT_COMPRESSION)})),this.register((function(e){return new At(e,ot.KHR_MESHOPT_COMPRESSION)})),this.register((function(e){return new St(e)}))}load(e,t,i,r){const a=this;let s;if(""!==this.resourcePath)s=this.resourcePath;else if(""!==this.path){const t=l.LoaderUtils.extractUrlBase(e);s=l.LoaderUtils.resolveURL(t,this.path)}else s=l.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const n=function(t){r&&r(t),a.manager.itemError(e),a.manager.itemEnd(e)},o=new l.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(i){try{a.parse(i,s,(function(i){t(i),a.manager.itemEnd(e)}),n)}catch(r){n(r)}}),i,n)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,i,r){let a;const s={},n={},o=new TextDecoder;if("string"==typeof e)a=JSON.parse(e);else if(e instanceof ArrayBuffer){if(o.decode(new Uint8Array(e,0,4))===Mt){try{s[ot.KHR_BINARY_GLTF]=new Rt(e)}catch(c){return void(r&&r(c))}a=JSON.parse(s[ot.KHR_BINARY_GLTF].content)}else a=JSON.parse(o.decode(e))}else a=e;if(void 0===a.asset||a.asset.version[0]<2)return void(r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new ei(a,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const e=this.pluginCallbacks[h](l);e.name,n[e.name]=e,s[e.name]=!0}if(a.extensionsUsed)for(let h=0;h<a.extensionsUsed.length;++h){const e=a.extensionsUsed[h],t=a.extensionsRequired||[];switch(e){case ot.KHR_MATERIALS_UNLIT:s[e]=new ct;break;case ot.KHR_DRACO_MESH_COMPRESSION:s[e]=new kt(a,this.dracoLoader);break;case ot.KHR_TEXTURE_TRANSFORM:s[e]=new Pt;break;case ot.KHR_MESH_QUANTIZATION:s[e]=new Ft;break;default:t.indexOf(e)>=0&&n[e]}}l.setExtensions(s),l.setPlugins(n),l.parse(i,r)}parseAsync(e,t){const i=this;return new Promise((function(r,a){i.parse(e,t,r,a)}))}}function st(){let e={};return{get:function(t){return e[t]},add:function(t,i){e[t]=i},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function nt(e,t,i){const r=e.json.materials[t];return r.extensions&&r.extensions[i]?r.extensions[i]:null}const ot={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class lt{constructor(e){this.parser=e,this.name=ot.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,r=t.length;i<r;i++){const r=t[i];r.extensions&&r.extensions[this.name]&&void 0!==r.extensions[this.name].light&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,i="light:"+e;let r=t.cache.get(i);if(r)return r;const a=t.json,s=((a.extensions&&a.extensions[this.name]||{}).lights||[])[e];let n;const o=new l.Color(16777215);void 0!==s.color&&o.setRGB(s.color[0],s.color[1],s.color[2],l.LinearSRGBColorSpace);const c=void 0!==s.range?s.range:0;switch(s.type){case"directional":n=new l.DirectionalLight(o),n.target.position.set(0,0,-1),n.add(n.target);break;case"point":n=new l.PointLight(o),n.distance=c;break;case"spot":n=new l.SpotLight(o),n.distance=c,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,n.angle=s.spot.outerConeAngle,n.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,n.target.position.set(0,0,-1),n.add(n.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return n.position.set(0,0,0),Jt(n,s),void 0!==s.intensity&&(n.intensity=s.intensity),n.name=t.createUniqueName(s.name||"light_"+e),r=Promise.resolve(n),t.cache.add(i,r),r}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,i=this.parser,r=i.json.nodes[e],a=(r.extensions&&r.extensions[this.name]||{}).light;return void 0===a?null:this._loadLight(a).then((function(e){return i._getNodeRef(t.cache,a,e)}))}}let ct=class{constructor(){this.name=ot.KHR_MATERIALS_UNLIT}getMaterialType(){return l.MeshBasicMaterial}extendParams(e,t,i){const r=[];e.color=new l.Color(1,1,1),e.opacity=1;const a=t.pbrMetallicRoughness;if(a){if(Array.isArray(a.baseColorFactor)){const t=a.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],l.LinearSRGBColorSpace),e.opacity=t[3]}void 0!==a.baseColorTexture&&r.push(i.assignTexture(e,"map",a.baseColorTexture,l.SRGBColorSpace))}return Promise.all(r)}},ht=class{constructor(e){this.parser=e,this.name=ot.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=nt(this.parser,e,this.name);return null===i||void 0!==i.emissiveStrength&&(t.emissiveIntensity=i.emissiveStrength),Promise.resolve()}},dt=class{constructor(e){this.parser=e,this.name=ot.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return null!==nt(this.parser,e,this.name)?l.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=nt(this.parser,e,this.name);if(null===i)return Promise.resolve();const r=[];if(void 0!==i.clearcoatFactor&&(t.clearcoat=i.clearcoatFactor),void 0!==i.clearcoatTexture&&r.push(this.parser.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),void 0!==i.clearcoatRoughnessFactor&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),void 0!==i.clearcoatRoughnessTexture&&r.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),void 0!==i.clearcoatNormalTexture&&(r.push(this.parser.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),void 0!==i.clearcoatNormalTexture.scale)){const e=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new l.Vector2(e,e)}return Promise.all(r)}},ut=class{constructor(e){this.parser=e,this.name=ot.KHR_MATERIALS_DISPERSION}getMaterialType(e){return null!==nt(this.parser,e,this.name)?l.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=nt(this.parser,e,this.name);return null===i||(t.dispersion=void 0!==i.dispersion?i.dispersion:0),Promise.resolve()}},pt=class{constructor(e){this.parser=e,this.name=ot.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return null!==nt(this.parser,e,this.name)?l.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=nt(this.parser,e,this.name);if(null===i)return Promise.resolve();const r=[];return void 0!==i.iridescenceFactor&&(t.iridescence=i.iridescenceFactor),void 0!==i.iridescenceTexture&&r.push(this.parser.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),void 0!==i.iridescenceIor&&(t.iridescenceIOR=i.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==i.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),void 0!==i.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),void 0!==i.iridescenceThicknessTexture&&r.push(this.parser.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(r)}},mt=class{constructor(e){this.parser=e,this.name=ot.KHR_MATERIALS_SHEEN}getMaterialType(e){return null!==nt(this.parser,e,this.name)?l.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=nt(this.parser,e,this.name);if(null===i)return Promise.resolve();const r=[];if(t.sheenColor=new l.Color(0,0,0),t.sheenRoughness=0,t.sheen=1,void 0!==i.sheenColorFactor){const e=i.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],l.LinearSRGBColorSpace)}return void 0!==i.sheenRoughnessFactor&&(t.sheenRoughness=i.sheenRoughnessFactor),void 0!==i.sheenColorTexture&&r.push(this.parser.assignTexture(t,"sheenColorMap",i.sheenColorTexture,l.SRGBColorSpace)),void 0!==i.sheenRoughnessTexture&&r.push(this.parser.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(r)}},ft=class{constructor(e){this.parser=e,this.name=ot.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return null!==nt(this.parser,e,this.name)?l.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=nt(this.parser,e,this.name);if(null===i)return Promise.resolve();const r=[];return void 0!==i.transmissionFactor&&(t.transmission=i.transmissionFactor),void 0!==i.transmissionTexture&&r.push(this.parser.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(r)}},gt=class{constructor(e){this.parser=e,this.name=ot.KHR_MATERIALS_VOLUME}getMaterialType(e){return null!==nt(this.parser,e,this.name)?l.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=nt(this.parser,e,this.name);if(null===i)return Promise.resolve();const r=[];t.thickness=void 0!==i.thicknessFactor?i.thicknessFactor:0,void 0!==i.thicknessTexture&&r.push(this.parser.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;const a=i.attenuationColor||[1,1,1];return t.attenuationColor=(new l.Color).setRGB(a[0],a[1],a[2],l.LinearSRGBColorSpace),Promise.all(r)}},bt=class{constructor(e){this.parser=e,this.name=ot.KHR_MATERIALS_IOR}getMaterialType(e){return null!==nt(this.parser,e,this.name)?l.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=nt(this.parser,e,this.name);return null===i||(t.ior=void 0!==i.ior?i.ior:1.5,0===t.ior&&(t.ior=1e3)),Promise.resolve()}},yt=class{constructor(e){this.parser=e,this.name=ot.KHR_MATERIALS_SPECULAR}getMaterialType(e){return null!==nt(this.parser,e,this.name)?l.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=nt(this.parser,e,this.name);if(null===i)return Promise.resolve();const r=[];t.specularIntensity=void 0!==i.specularFactor?i.specularFactor:1,void 0!==i.specularTexture&&r.push(this.parser.assignTexture(t,"specularIntensityMap",i.specularTexture));const a=i.specularColorFactor||[1,1,1];return t.specularColor=(new l.Color).setRGB(a[0],a[1],a[2],l.LinearSRGBColorSpace),void 0!==i.specularColorTexture&&r.push(this.parser.assignTexture(t,"specularColorMap",i.specularColorTexture,l.SRGBColorSpace)),Promise.all(r)}},vt=class{constructor(e){this.parser=e,this.name=ot.EXT_MATERIALS_BUMP}getMaterialType(e){return null!==nt(this.parser,e,this.name)?l.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=nt(this.parser,e,this.name);if(null===i)return Promise.resolve();const r=[];return t.bumpScale=void 0!==i.bumpFactor?i.bumpFactor:1,void 0!==i.bumpTexture&&r.push(this.parser.assignTexture(t,"bumpMap",i.bumpTexture)),Promise.all(r)}},xt=class{constructor(e){this.parser=e,this.name=ot.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return null!==nt(this.parser,e,this.name)?l.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=nt(this.parser,e,this.name);if(null===i)return Promise.resolve();const r=[];return void 0!==i.anisotropyStrength&&(t.anisotropy=i.anisotropyStrength),void 0!==i.anisotropyRotation&&(t.anisotropyRotation=i.anisotropyRotation),void 0!==i.anisotropyTexture&&r.push(this.parser.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(r)}};class wt{constructor(e){this.parser=e,this.name=ot.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,i=t.json,r=i.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const a=r.extensions[this.name],s=t.options.ktx2Loader;if(!s){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,a.source,s)}}class Tt{constructor(e){this.parser=e,this.name=ot.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,i=this.parser,r=i.json,a=r.textures[e];if(!a.extensions||!a.extensions[t])return null;const s=a.extensions[t],n=r.images[s.source];let o=i.textureLoader;if(n.uri){const e=i.options.manager.getHandler(n.uri);null!==e&&(o=e)}return i.loadTextureImage(e,s.source,o)}}class _t{constructor(e){this.parser=e,this.name=ot.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,i=this.parser,r=i.json,a=r.textures[e];if(!a.extensions||!a.extensions[t])return null;const s=a.extensions[t],n=r.images[s.source];let o=i.textureLoader;if(n.uri){const e=i.options.manager.getHandler(n.uri);null!==e&&(o=e)}return i.loadTextureImage(e,s.source,o)}}class At{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const e=i.extensions[this.name],r=this.parser.getDependency("buffer",e.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then((function(t){const i=e.byteOffset||0,r=e.byteLength||0,s=e.count,n=e.byteStride,o=new Uint8Array(t,i,r);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(s,n,o,e.mode,e.filter).then((function(e){return e.buffer})):a.ready.then((function(){const t=new ArrayBuffer(s*n);return a.decodeGltfBuffer(new Uint8Array(t),s,n,o,e.mode,e.filter),t}))}))}return null}}let St=class{constructor(e){this.name=ot.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||void 0===i.mesh)return null;const r=t.meshes[i.mesh];for(const o of r.primitives)if(o.mode!==It.TRIANGLES&&o.mode!==It.TRIANGLE_STRIP&&o.mode!==It.TRIANGLE_FAN&&void 0!==o.mode)return null;const a=i.extensions[this.name].attributes,s=[],n={};for(const o in a)s.push(this.parser.getDependency("accessor",a[o]).then((e=>(n[o]=e,n[o]))));return s.length<1?null:(s.push(this.parser.createNodeMesh(e)),Promise.all(s).then((e=>{const t=e.pop(),i=t.isGroup?t.children:[t],r=e[0].count,a=[];for(const s of i){const e=new l.Matrix4,t=new l.Vector3,i=new l.Quaternion,o=new l.Vector3(1,1,1),c=new l.InstancedMesh(s.geometry,s.material,r);for(let a=0;a<r;a++)n.TRANSLATION&&t.fromBufferAttribute(n.TRANSLATION,a),n.ROTATION&&i.fromBufferAttribute(n.ROTATION,a),n.SCALE&&o.fromBufferAttribute(n.SCALE,a),c.setMatrixAt(a,e.compose(t,i,o));let h=null;for(const r in n)if("_COLOR_0"===r){const e=n[r];c.instanceColor=new l.InstancedBufferAttribute(e.array,e.itemSize,e.normalized)}else if("TRANSLATION"!==r&&"ROTATION"!==r&&"SCALE"!==r){if(null===h){const e=c.geometry;h=new l.BufferGeometry,h.name=e.name;for(const t in e.attributes)h.setAttribute(t,e.attributes[t]);for(const t in e.morphAttributes)h.morphAttributes[t]=e.morphAttributes[t];null!==e.index&&h.setIndex(e.index),h.morphTargetsRelative=e.morphTargetsRelative;for(const t of e.groups)h.addGroup(t.start,t.count,t.materialIndex);null!==e.boundingBox&&(h.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(h.boundingSphere=e.boundingSphere.clone()),h.drawRange.start=e.drawRange.start,h.drawRange.count=e.drawRange.count,h.userData=Object.assign({},e.userData),c.geometry=h}const e=n[r];h.setAttribute(r,new l.InstancedBufferAttribute(e.array,e.itemSize,e.normalized))}l.Object3D.prototype.copy.call(c,s),this.parser.assignFinalMaterial(c),a.push(c)}return t.isGroup?(t.clear(),t.add(...a),t):a[0]})))}};const Mt="glTF",Ct=1313821514,Et=5130562;class Rt{constructor(e){this.name=ot.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Mt)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-12,a=new DataView(e,12);let s=0;for(;s<r;){const t=a.getUint32(s,!0);s+=4;const r=a.getUint32(s,!0);if(s+=4,r===Ct){const r=new Uint8Array(e,12+s,t);this.content=i.decode(r)}else if(r===Et){const i=12+s;this.body=e.slice(i,i+t)}s+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class kt{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=ot.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const i=this.json,r=this.dracoLoader,a=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,n={},o={},c={};for(const l in s){const e=jt[l]||l.toLowerCase();n[e]=s[l]}for(const l in e.attributes){const t=jt[l]||l.toLowerCase();if(void 0!==s[l]){const r=i.accessors[e.attributes[l]],a=Ot[r.componentType];c[t]=a.name,o[t]=!0===r.normalized}}return t.getDependency("bufferView",a).then((function(e){return new Promise((function(t,i){r.decodeDracoFile(e,(function(e){for(const t in e.attributes){const i=e.attributes[t],r=o[t];void 0!==r&&(i.normalized=r)}t(e)}),n,c,l.LinearSRGBColorSpace,i)}))}))}}class Pt{constructor(){this.name=ot.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((void 0===t.texCoord||t.texCoord===e.channel)&&void 0===t.offset&&void 0===t.rotation&&void 0===t.scale)return e;if(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),void 0!==t.rotation){const t=Math.cos(e.rotation),i=Math.sin(e.rotation);e.matrix.set(e.repeat.x*t,e.repeat.y*i,e.offset.x,-e.repeat.x*i,e.repeat.y*t,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}}class Ft{constructor(){this.name=ot.KHR_MESH_QUANTIZATION}}class Lt extends l.Interpolant{constructor(e,t,i,r){super(e,t,i,r)}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,a=e*r*3+r;for(let s=0;s!==r;s++)t[s]=i[a+s];return t}interpolate_(e,t,i,r){const a=this.resultBuffer,s=this.sampleValues,n=this.valueSize,o=2*n,l=3*n,c=r-t,h=(i-t)/c,d=h*h,u=d*h,p=e*l,m=p-l,f=-2*u+3*d,g=u-d,b=1-f,y=g-d+h;for(let v=0;v!==n;v++){const e=s[m+v+n],t=s[m+v+o]*c,i=s[p+v+n],r=s[p+v]*c;a[v]=b*e+y*t+f*i+g*r}return a}}const Dt=new l.Quaternion;class Ut extends Lt{interpolate_(e,t,i,r){const a=super.interpolate_(e,t,i,r);return Dt.fromArray(a).normalize().toArray(a),a}}const It={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Ot={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Bt={9728:l.NearestFilter,9729:l.LinearFilter,9984:l.NearestMipmapNearestFilter,9985:l.LinearMipmapNearestFilter,9986:l.NearestMipmapLinearFilter,9987:l.LinearMipmapLinearFilter},Vt={33071:l.ClampToEdgeWrapping,33648:l.MirroredRepeatWrapping,10497:l.RepeatWrapping},Nt={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},jt={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},zt={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Gt={CUBICSPLINE:void 0,LINEAR:l.InterpolateLinear,STEP:l.InterpolateDiscrete},Ht="OPAQUE",qt="MASK",Wt="BLEND";function Kt(e,t,i){for(const r in i.extensions)void 0===e[r]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=i.extensions[r])}function Jt(e,t){void 0!==t.extras&&"object"==typeof t.extras&&Object.assign(e.userData,t.extras)}function Xt(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let i=0,r=t.weights.length;i<r;i++)e.morphTargetInfluences[i]=t.weights[i];if(t.extras&&Array.isArray(t.extras.targetNames)){const i=t.extras.targetNames;if(e.morphTargetInfluences.length===i.length){e.morphTargetDictionary={};for(let t=0,r=i.length;t<r;t++)e.morphTargetDictionary[i[t]]=t}}}function Qt(e){let t;const i=e.extensions&&e.extensions[ot.KHR_DRACO_MESH_COMPRESSION];if(t=i?"draco:"+i.bufferView+":"+i.indices+":"+Yt(i.attributes):e.indices+":"+Yt(e.attributes)+":"+e.mode,void 0!==e.targets)for(let r=0,a=e.targets.length;r<a;r++)t+=":"+Yt(e.targets[r]);return t}function Yt(e){let t="";const i=Object.keys(e).sort();for(let r=0,a=i.length;r<a;r++)t+=i[r]+":"+e[i[r]]+";";return t}function Zt(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const $t=new l.Matrix4;class ei{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new st,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,r=-1,a=!1,s=-1;if("undefined"!=typeof navigator&&void 0!==navigator.userAgent){const e=navigator.userAgent;i=!0===/^((?!chrome|android).)*safari/i.test(e);const t=e.match(/Version\/(\d+)/);r=i&&t?parseInt(t[1],10):-1,a=e.indexOf("Firefox")>-1,s=a?e.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||i&&r<17||a&&s<98?this.textureLoader=new l.TextureLoader(this.options.manager):this.textureLoader=new l.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new l.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const i=this,r=this.json,a=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])})).then((function(t){const s={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:i,userData:{}};return Kt(a,s,r),Jt(s,r),Promise.all(i._invokeAll((function(e){return e.afterRoot&&e.afterRoot(s)}))).then((function(){for(const e of s.scenes)e.updateMatrixWorld();e(s)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let r=0,a=t.length;r<a;r++){const i=t[r].joints;for(let t=0,r=i.length;t<r;t++)e[i[t]].isBone=!0}for(let r=0,a=e.length;r<a;r++){const t=e[r];void 0!==t.mesh&&(this._addNodeRef(this.meshCache,t.mesh),void 0!==t.skin&&(i[t.mesh].isSkinnedMesh=!0)),void 0!==t.camera&&this._addNodeRef(this.cameraCache,t.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,i){if(e.refs[t]<=1)return i;const r=i.clone(),a=(e,t)=>{const i=this.associations.get(e);null!=i&&this.associations.set(t,i);for(const[r,s]of e.children.entries())a(s,t.children[r])};return a(i,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i<t.length;i++){const r=e(t[i]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const i=[];for(let r=0;r<t.length;r++){const a=e(t[r]);a&&i.push(a)}return i}getDependency(e,t){const i=e+":"+t;let r=this.cache.get(i);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne((function(e){return e.loadNode&&e.loadNode(t)}));break;case"mesh":r=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":r=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne((function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)})),!r)throw new Error("Unknown type: "+e)}this.cache.add(i,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const i=this,r=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(r.map((function(t,r){return i.getDependency(e,r)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],i=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[ot.KHR_BINARY_GLTF].body);const r=this.options;return new Promise((function(e,a){i.load(l.LoaderUtils.resolveURL(t.uri,r.path),e,void 0,(function(){a(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const i=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+i)}))}loadAccessor(e){const t=this,i=this.json,r=this.json.accessors[e];if(void 0===r.bufferView&&void 0===r.sparse){const e=Nt[r.type],t=Ot[r.componentType],i=!0===r.normalized,a=new t(r.count*e);return Promise.resolve(new l.BufferAttribute(a,e,i))}const a=[];return void 0!==r.bufferView?a.push(this.getDependency("bufferView",r.bufferView)):a.push(null),void 0!==r.sparse&&(a.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),a.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(a).then((function(e){const a=e[0],s=Nt[r.type],n=Ot[r.componentType],o=n.BYTES_PER_ELEMENT,c=o*s,h=r.byteOffset||0,d=void 0!==r.bufferView?i.bufferViews[r.bufferView].byteStride:void 0,u=!0===r.normalized;let p,m;if(d&&d!==c){const e=Math.floor(h/d),i="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+e+":"+r.count;let c=t.cache.get(i);c||(p=new n(a,e*d,r.count*d/o),c=new l.InterleavedBuffer(p,d/o),t.cache.add(i,c)),m=new l.InterleavedBufferAttribute(c,s,h%d/o,u)}else p=null===a?new n(r.count*s):new n(a,h,r.count*s),m=new l.BufferAttribute(p,s,u);if(void 0!==r.sparse){const t=Nt.SCALAR,i=Ot[r.sparse.indices.componentType],o=r.sparse.indices.byteOffset||0,c=r.sparse.values.byteOffset||0,h=new i(e[1],o,r.sparse.count*t),d=new n(e[2],c,r.sparse.count*s);null!==a&&(m=new l.BufferAttribute(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let e=0,r=h.length;e<r;e++){const t=h[e];if(m.setX(t,d[e*s]),s>=2&&m.setY(t,d[e*s+1]),s>=3&&m.setZ(t,d[e*s+2]),s>=4&&m.setW(t,d[e*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=u}return m}))}loadTexture(e){const t=this.json,i=this.options,r=t.textures[e].source,a=t.images[r];let s=this.textureLoader;if(a.uri){const e=i.manager.getHandler(a.uri);null!==e&&(s=e)}return this.loadTextureImage(e,r,s)}loadTextureImage(e,t,i){const r=this,a=this.json,s=a.textures[e],n=a.images[t],o=(n.uri||n.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];const c=this.loadImageSource(t,i).then((function(t){t.flipY=!1,t.name=s.name||n.name||"",""===t.name&&"string"==typeof n.uri&&!1===n.uri.startsWith("data:image/")&&(t.name=n.uri);const i=(a.samplers||{})[s.sampler]||{};return t.magFilter=Bt[i.magFilter]||l.LinearFilter,t.minFilter=Bt[i.minFilter]||l.LinearMipmapLinearFilter,t.wrapS=Vt[i.wrapS]||l.RepeatWrapping,t.wrapT=Vt[i.wrapT]||l.RepeatWrapping,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==l.NearestFilter&&t.minFilter!==l.LinearFilter,r.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=c,c}loadImageSource(e,t){const i=this,r=this.json,a=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const s=r.images[e],n=self.URL||self.webkitURL;let o=s.uri||"",c=!1;if(void 0!==s.bufferView)o=i.getDependency("bufferView",s.bufferView).then((function(e){c=!0;const t=new Blob([e],{type:s.mimeType});return o=n.createObjectURL(t),o}));else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(o).then((function(e){return new Promise((function(i,r){let s=i;!0===t.isImageBitmapLoader&&(s=function(e){const t=new l.Texture(e);t.needsUpdate=!0,i(t)}),t.load(l.LoaderUtils.resolveURL(e,a.path),s,void 0,r)}))})).then((function(e){var t;return!0===c&&n.revokeObjectURL(o),Jt(e,s),e.userData.mimeType=s.mimeType||((t=s.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":t.search(/\.ktx2($|\?)/i)>0||0===t.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),e})).catch((function(e){throw e}));return this.sourceCache[e]=h,h}assignTexture(e,t,i,r){const a=this;return this.getDependency("texture",i.index).then((function(s){if(!s)return null;if(void 0!==i.texCoord&&i.texCoord>0&&((s=s.clone()).channel=i.texCoord),a.extensions[ot.KHR_TEXTURE_TRANSFORM]){const e=void 0!==i.extensions?i.extensions[ot.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=a.associations.get(s);s=a.extensions[ot.KHR_TEXTURE_TRANSFORM].extendTexture(s,e),a.associations.set(s,t)}}return void 0!==r&&(s.colorSpace=r),e[t]=s,s}))}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const r=void 0===t.attributes.tangent,a=void 0!==t.attributes.color,s=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+i.uuid;let t=this.cache.get(e);t||(t=new l.PointsMaterial,l.Material.prototype.copy.call(t,i),t.color.copy(i.color),t.map=i.map,t.sizeAttenuation=!1,this.cache.add(e,t)),i=t}else if(e.isLine){const e="LineBasicMaterial:"+i.uuid;let t=this.cache.get(e);t||(t=new l.LineBasicMaterial,l.Material.prototype.copy.call(t,i),t.color.copy(i.color),t.map=i.map,this.cache.add(e,t)),i=t}if(r||a||s){let e="ClonedMaterial:"+i.uuid+":";r&&(e+="derivative-tangents:"),a&&(e+="vertex-colors:"),s&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=i.clone(),a&&(t.vertexColors=!0),s&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(i))),i=t}e.material=i}getMaterialType(){return l.MeshStandardMaterial}loadMaterial(e){const t=this,i=this.json,r=this.extensions,a=i.materials[e];let s;const n={},o=[];if((a.extensions||{})[ot.KHR_MATERIALS_UNLIT]){const e=r[ot.KHR_MATERIALS_UNLIT];s=e.getMaterialType(),o.push(e.extendParams(n,a,t))}else{const i=a.pbrMetallicRoughness||{};if(n.color=new l.Color(1,1,1),n.opacity=1,Array.isArray(i.baseColorFactor)){const e=i.baseColorFactor;n.color.setRGB(e[0],e[1],e[2],l.LinearSRGBColorSpace),n.opacity=e[3]}void 0!==i.baseColorTexture&&o.push(t.assignTexture(n,"map",i.baseColorTexture,l.SRGBColorSpace)),n.metalness=void 0!==i.metallicFactor?i.metallicFactor:1,n.roughness=void 0!==i.roughnessFactor?i.roughnessFactor:1,void 0!==i.metallicRoughnessTexture&&(o.push(t.assignTexture(n,"metalnessMap",i.metallicRoughnessTexture)),o.push(t.assignTexture(n,"roughnessMap",i.metallicRoughnessTexture))),s=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),o.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,n)}))))}!0===a.doubleSided&&(n.side=l.DoubleSide);const c=a.alphaMode||Ht;if(c===Wt?(n.transparent=!0,n.depthWrite=!1):(n.transparent=!1,c===qt&&(n.alphaTest=void 0!==a.alphaCutoff?a.alphaCutoff:.5)),void 0!==a.normalTexture&&s!==l.MeshBasicMaterial&&(o.push(t.assignTexture(n,"normalMap",a.normalTexture)),n.normalScale=new l.Vector2(1,1),void 0!==a.normalTexture.scale)){const e=a.normalTexture.scale;n.normalScale.set(e,e)}if(void 0!==a.occlusionTexture&&s!==l.MeshBasicMaterial&&(o.push(t.assignTexture(n,"aoMap",a.occlusionTexture)),void 0!==a.occlusionTexture.strength&&(n.aoMapIntensity=a.occlusionTexture.strength)),void 0!==a.emissiveFactor&&s!==l.MeshBasicMaterial){const e=a.emissiveFactor;n.emissive=(new l.Color).setRGB(e[0],e[1],e[2],l.LinearSRGBColorSpace)}return void 0!==a.emissiveTexture&&s!==l.MeshBasicMaterial&&o.push(t.assignTexture(n,"emissiveMap",a.emissiveTexture,l.SRGBColorSpace)),Promise.all(o).then((function(){const i=new s(n);return a.name&&(i.name=a.name),Jt(i,a),t.associations.set(i,{materials:e}),a.extensions&&Kt(r,i,a),i}))}createUniqueName(e){const t=l.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,r=this.primitiveCache;function a(e){return i[ot.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(i){return ti(i,e,t)}))}const s=[];for(let n=0,o=e.length;n<o;n++){const i=e[n],o=Qt(i),c=r[o];if(c)s.push(c.promise);else{let e;e=i.extensions&&i.extensions[ot.KHR_DRACO_MESH_COMPRESSION]?a(i):ti(new l.BufferGeometry,i,t),i.mode===It.TRIANGLE_STRIP?e=e.then((e=>tt(e,l.TriangleStripDrawMode))):i.mode===It.TRIANGLE_FAN&&(e=e.then((e=>tt(e,l.TriangleFanDrawMode)))),r[o]={primitive:i,promise:e},s.push(e)}}return Promise.all(s)}loadMesh(e){const t=this,i=this.json,r=this.extensions,a=i.meshes[e],s=a.primitives,n=[];for(let c=0,h=s.length;c<h;c++){const e=void 0===s[c].material?(void 0===(o=this.cache).DefaultMaterial&&(o.DefaultMaterial=new l.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:l.FrontSide})),o.DefaultMaterial):this.getDependency("material",s[c].material);n.push(e)}var o;return n.push(t.loadGeometries(s)),Promise.all(n).then((async function(i){const n=i.slice(0,i.length-1),o=i[i.length-1],c=[];for(let d=0,u=o.length;d<u;d++){const i=o[d],h=s[d];let u;const p=n[d];if(h.mode===It.TRIANGLES||h.mode===It.TRIANGLE_STRIP||h.mode===It.TRIANGLE_FAN||void 0===h.mode){const e=!0===a.isSkinnedMesh,t=i.hasAttribute("skinIndex")&&i.hasAttribute("skinWeight");u=e&&t?new l.SkinnedMesh(i,p):new l.Mesh(i,p),!0===u.isSkinnedMesh&&u.normalizeSkinWeights()}else if(h.mode===It.LINES)u=new l.LineSegments(i,p);else if(h.mode===It.LINE_STRIP)u=new l.Line(i,p);else if(h.mode===It.LINE_LOOP)u=new l.LineLoop(i,p);else{if(h.mode!==It.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+h.mode);u=new l.Points(i,p)}Object.keys(u.geometry.morphAttributes).length>0&&Xt(u,a),u.name=t.createUniqueName(a.name||"mesh_"+e),Jt(u,a),h.extensions&&Kt(r,u,h),t.assignFinalMaterial(u),c.push(u)}for(let r=0,a=c.length;r<a;r++)t.associations.set(c[r],{meshes:e,primitives:r});if(1===c.length)return a.extensions&&Kt(r,c[0],a),c[0];const h=new l.Group;a.extensions&&Kt(r,h,a),t.associations.set(h,{meshes:e});for(let e=0,t=c.length;e<t;e++)h.add(c[e]);return h}))}loadCamera(e){let t;const i=this.json.cameras[e],r=i[i.type];if(r)return"perspective"===i.type?t=new l.PerspectiveCamera(l.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===i.type&&(t=new l.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),Jt(t,i),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],i=[];for(let r=0,a=t.joints.length;r<a;r++)i.push(this._loadNodeShallow(t.joints[r]));return void 0!==t.inverseBindMatrices?i.push(this.getDependency("accessor",t.inverseBindMatrices)):i.push(null),Promise.all(i).then((function(e){const t=e.pop(),i=e,r=[],a=[];for(let s=0,n=i.length;s<n;s++){const e=i[s];if(e){r.push(e);const i=new l.Matrix4;null!==t&&i.fromArray(t.array,16*s),a.push(i)}}return new l.Skeleton(r,a)}))}loadAnimation(e){const t=this.json,i=this,r=t.animations[e],a=r.name?r.name:"animation_"+e,s=[],n=[],o=[],c=[],h=[];for(let l=0,d=r.channels.length;l<d;l++){const e=r.channels[l],t=r.samplers[e.sampler],i=e.target,a=i.node,d=void 0!==r.parameters?r.parameters[t.input]:t.input,u=void 0!==r.parameters?r.parameters[t.output]:t.output;void 0!==i.node&&(s.push(this.getDependency("node",a)),n.push(this.getDependency("accessor",d)),o.push(this.getDependency("accessor",u)),c.push(t),h.push(i))}return Promise.all([Promise.all(s),Promise.all(n),Promise.all(o),Promise.all(c),Promise.all(h)]).then((function(e){const t=e[0],s=e[1],n=e[2],o=e[3],c=e[4],h=[];for(let r=0,a=t.length;r<a;r++){const e=t[r],a=s[r],l=n[r],d=o[r],u=c[r];if(void 0===e)continue;e.updateMatrix&&e.updateMatrix();const p=i._createAnimationTracks(e,a,l,d,u);if(p)for(let t=0;t<p.length;t++)h.push(p[t])}const d=new l.AnimationClip(a,void 0,h);return Jt(d,r),d}))}createNodeMesh(e){const t=this.json,i=this,r=t.nodes[e];return void 0===r.mesh?null:i.getDependency("mesh",r.mesh).then((function(e){const t=i._getNodeRef(i.meshCache,r.mesh,e);return void 0!==r.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,i=r.weights.length;t<i;t++)e.morphTargetInfluences[t]=r.weights[t]})),t}))}loadNode(e){const t=this,i=this.json.nodes[e],r=t._loadNodeShallow(e),a=[],s=i.children||[];for(let o=0,l=s.length;o<l;o++)a.push(t.getDependency("node",s[o]));const n=void 0===i.skin?Promise.resolve(null):t.getDependency("skin",i.skin);return Promise.all([r,Promise.all(a),n]).then((function(e){const t=e[0],i=e[1],r=e[2];null!==r&&t.traverse((function(e){e.isSkinnedMesh&&e.bind(r,$t)}));for(let a=0,s=i.length;a<s;a++)t.add(i[a]);if(void 0!==t.userData.pivot&&i.length>0){const e=t.userData.pivot,r=i[0];t.pivot=(new l.Vector3).fromArray(e),t.position.x-=e[0],t.position.y-=e[1],t.position.z-=e[2],r.position.set(0,0,0),delete t.userData.pivot}return t}))}_loadNodeShallow(e){const t=this.json,i=this.extensions,r=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];const a=t.nodes[e],s=a.name?r.createUniqueName(a.name):"",n=[],o=r._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return o&&n.push(o),void 0!==a.camera&&n.push(r.getDependency("camera",a.camera).then((function(e){return r._getNodeRef(r.cameraCache,a.camera,e)}))),r._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){n.push(e)})),this.nodeCache[e]=Promise.all(n).then((function(t){let n;if(n=!0===a.isBone?new l.Bone:t.length>1?new l.Group:1===t.length?t[0]:new l.Object3D,n!==t[0])for(let e=0,i=t.length;e<i;e++)n.add(t[e]);if(a.name&&(n.userData.name=a.name,n.name=s),Jt(n,a),a.extensions&&Kt(i,n,a),void 0!==a.matrix){const e=new l.Matrix4;e.fromArray(a.matrix),n.applyMatrix4(e)}else void 0!==a.translation&&n.position.fromArray(a.translation),void 0!==a.rotation&&n.quaternion.fromArray(a.rotation),void 0!==a.scale&&n.scale.fromArray(a.scale);if(r.associations.has(n)){if(void 0!==a.mesh&&r.meshCache.refs[a.mesh]>1){const e=r.associations.get(n);r.associations.set(n,{...e})}}else r.associations.set(n,{});return r.associations.get(n).nodes=e,n})),this.nodeCache[e]}loadScene(e){const t=this.extensions,i=this.json.scenes[e],r=this,a=new l.Group;i.name&&(a.name=r.createUniqueName(i.name)),Jt(a,i),i.extensions&&Kt(t,a,i);const s=i.nodes||[],n=[];for(let o=0,l=s.length;o<l;o++)n.push(r.getDependency("node",s[o]));return Promise.all(n).then((function(e){for(let t=0,i=e.length;t<i;t++){const i=e[t];null!==i.parent?a.add(it(i)):a.add(i)}return r.associations=(e=>{const t=new Map;for(const[i,a]of r.associations)(i instanceof l.Material||i instanceof l.Texture)&&t.set(i,a);return e.traverse((e=>{const i=r.associations.get(e);null!=i&&t.set(e,i)})),t})(a),a}))}_createAnimationTracks(e,t,i,r,a){const s=[],n=e.name?e.name:e.uuid,o=[];function c(e){e.morphTargetInfluences&&o.push(e.name?e.name:e.uuid)}let h;switch(zt[a.path]===zt.weights?(c(e),e.isGroup&&e.children.forEach(c)):o.push(n),zt[a.path]){case zt.weights:h=l.NumberKeyframeTrack;break;case zt.rotation:h=l.QuaternionKeyframeTrack;break;case zt.translation:case zt.scale:h=l.VectorKeyframeTrack;break;default:if(1===i.itemSize)h=l.NumberKeyframeTrack;else h=l.VectorKeyframeTrack}const d=void 0!==r.interpolation?Gt[r.interpolation]:l.InterpolateLinear,u=this._getArrayFromAccessor(i);for(let l=0,p=o.length;l<p;l++){const e=new h(o[l]+"."+zt[a.path],t.array,u,d);"CUBICSPLINE"===r.interpolation&&this._createCubicSplineTrackInterpolant(e),s.push(e)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const e=Zt(t.constructor),i=new Float32Array(t.length);for(let r=0,a=t.length;r<a;r++)i[r]=t[r]*e;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof l.QuaternionKeyframeTrack?Ut:Lt)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function ti(e,t,i){const r=t.attributes,a=[];function s(t,r){return i.getDependency("accessor",t).then((function(t){e.setAttribute(r,t)}))}for(const n in r){const t=jt[n]||n.toLowerCase();t in e.attributes||a.push(s(r[n],t))}if(void 0!==t.indices&&!e.index){const r=i.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));a.push(r)}return l.ColorManagement.workingColorSpace,l.LinearSRGBColorSpace,Jt(e,t),function(e,t,i){const r=t.attributes,a=new l.Box3;if(void 0===r.POSITION)return;{const e=i.json.accessors[r.POSITION],t=e.min,s=e.max;if(void 0===t||void 0===s)return;if(a.set(new l.Vector3(t[0],t[1],t[2]),new l.Vector3(s[0],s[1],s[2])),e.normalized){const t=Zt(Ot[e.componentType]);a.min.multiplyScalar(t),a.max.multiplyScalar(t)}}const s=t.targets;if(void 0!==s){const e=new l.Vector3,t=new l.Vector3;for(let r=0,a=s.length;r<a;r++){const a=s[r];if(void 0!==a.POSITION){const r=i.json.accessors[a.POSITION],s=r.min,n=r.max;if(void 0!==s&&void 0!==n){if(t.setX(Math.max(Math.abs(s[0]),Math.abs(n[0]))),t.setY(Math.max(Math.abs(s[1]),Math.abs(n[1]))),t.setZ(Math.max(Math.abs(s[2]),Math.abs(n[2]))),r.normalized){const e=Zt(Ot[r.componentType]);t.multiplyScalar(e)}e.max(t)}}}a.expandByVector(e)}e.boundingBox=a;const n=new l.Sphere;a.getCenter(n.center),n.radius=a.min.distanceTo(a.max)/2,e.boundingSphere=n}(e,t,i),Promise.all(a).then((function(){return void 0!==t.targets?function(e,t,i){let r=!1,a=!1,s=!1;for(let c=0,h=t.length;c<h;c++){const e=t[c];if(void 0!==e.POSITION&&(r=!0),void 0!==e.NORMAL&&(a=!0),void 0!==e.COLOR_0&&(s=!0),r&&a&&s)break}if(!r&&!a&&!s)return Promise.resolve(e);const n=[],o=[],l=[];for(let c=0,h=t.length;c<h;c++){const h=t[c];if(r){const t=void 0!==h.POSITION?i.getDependency("accessor",h.POSITION):e.attributes.position;n.push(t)}if(a){const t=void 0!==h.NORMAL?i.getDependency("accessor",h.NORMAL):e.attributes.normal;o.push(t)}if(s){const t=void 0!==h.COLOR_0?i.getDependency("accessor",h.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(n),Promise.all(o),Promise.all(l)]).then((function(t){const i=t[0],n=t[1],o=t[2];return r&&(e.morphAttributes.position=i),a&&(e.morphAttributes.normal=n),s&&(e.morphAttributes.color=o),e.morphTargetsRelative=!0,e}))}(e,t.targets,i):e}))}var ii=class extends Ye{constructor(e=l.DefaultLoadingManager){super(),this.manager=e,this.adjustmentTransform=new l.Matrix4}parse(e){let t=super.parse(e),i=t.glbBytes.slice().buffer;return new Promise(((e,r)=>{let a=this.manager,s=this.fetchOptions,n=a.getHandler("path.gltf")||new at(a);"include"===s.credentials&&"cors"===s.mode&&n.setCrossOrigin("use-credentials"),"credentials"in s&&n.setWithCredentials("include"===s.credentials),s.headers&&n.setRequestHeader(s.headers);let o=this.workingPath;!/[\\/]$/.test(o)&&o.length&&(o+="/");let l=this.adjustmentTransform;n.parse(i,o,(i=>{let{batchTable:r,featureTable:a}=t,{scene:s}=i,n=a.getData("RTC_CENTER",1,"FLOAT","VEC3");n&&(s.position.x+=n[0],s.position.y+=n[1],s.position.z+=n[2]),i.scene.updateMatrix(),i.scene.matrix.multiply(l),i.scene.matrix.decompose(i.scene.position,i.scene.quaternion,i.scene.scale),i.batchTable=r,i.featureTable=a,s.batchTable=r,s.featureTable=a,e(i)}),r)}))}};function ri(e){let t=e>>11,i=e>>5&63,r=31&e;return[Math.round(t/31*255),Math.round(i/63*255),Math.round(r/31*255)]}var ai=new l.Vector2;function si(e,t,i=new l.Vector3){ai.set(e,t).divideScalar(256).multiplyScalar(2).subScalar(1),i.set(ai.x,ai.y,1-Math.abs(ai.x)-Math.abs(ai.y));let r=l.MathUtils.clamp(-i.z,0,1);return i.x>=0?i.setX(i.x-r):i.setX(i.x+r),i.y>=0?i.setY(i.y-r):i.setY(i.y+r),i.normalize(),i}var ni={RGB:"color",POSITION:"position"},oi=class extends $e{constructor(e=l.DefaultLoadingManager){super(),this.manager=e}parse(e){return super.parse(e).then((async e=>{let t,{featureTable:i,batchTable:r}=e,a=new l.PointsMaterial,s=i.header.extensions,n=new l.Vector3;if(s&&s["3DTILES_draco_point_compression"]){let{byteOffset:e,byteLength:r,properties:n}=s["3DTILES_draco_point_compression"],o=this.manager.getHandler("draco.drc");if(null==o)throw Error("PNTSLoader: dracoLoader not available.");let l={};for(let t in n)if(t in ni&&t in n){l[ni[t]]=n[t]}let c={attributeIDs:l,attributeTypes:{position:"Float32Array",color:"Uint8Array"},useUniqueIDs:!0},h=i.getBuffer(e,r);t=await o.decodeGeometry(h,c),t.attributes.color&&(a.vertexColors=!0)}else{let e=i.getData("POINTS_LENGTH"),r=i.getData("POSITION",e,"FLOAT","VEC3"),s=i.getData("NORMAL",e,"FLOAT","VEC3"),o=i.getData("NORMAL",e,"UNSIGNED_BYTE","VEC2"),c=i.getData("RGB",e,"UNSIGNED_BYTE","VEC3"),h=i.getData("RGBA",e,"UNSIGNED_BYTE","VEC4"),d=i.getData("RGB565",e,"UNSIGNED_SHORT","SCALAR"),u=i.getData("CONSTANT_RGBA",e,"UNSIGNED_BYTE","VEC4"),p=i.getData("POSITION_QUANTIZED",e,"UNSIGNED_SHORT","VEC3"),m=i.getData("QUANTIZED_VOLUME_SCALE",e,"FLOAT","VEC3"),f=i.getData("QUANTIZED_VOLUME_OFFSET",e,"FLOAT","VEC3");if(t=new l.BufferGeometry,p){let i=new Float32Array(3*e);for(let t=0;t<e;t++)for(let e=0;e<3;e++){let r=3*t+e;i[r]=p[r]/65535*m[e]}n.x=f[0],n.y=f[1],n.z=f[2],t.setAttribute("position",new l.BufferAttribute(i,3,!1))}else t.setAttribute("position",new l.BufferAttribute(r,3,!1));if(null!==s)t.setAttribute("normal",new l.BufferAttribute(s,3,!1));else if(null!==o){let i=new Float32Array(3*e),r=new l.Vector3;for(let t=0;t<e;t++){let e=si(o[2*t],o[2*t+1],r);i[3*t]=e.x,i[3*t+1]=e.y,i[3*t+2]=e.z}t.setAttribute("normal",new l.BufferAttribute(i,3,!1))}if(null!==h)t.setAttribute("color",new l.BufferAttribute(h,4,!0)),a.vertexColors=!0,a.transparent=!0,a.depthWrite=!1;else if(null!==c)t.setAttribute("color",new l.BufferAttribute(c,3,!0)),a.vertexColors=!0;else if(null!==d){let i=new Uint8Array(3*e);for(let t=0;t<e;t++){let e=ri(d[t]);for(let r=0;r<3;r++){i[3*t+r]=e[r]}}t.setAttribute("color",new l.BufferAttribute(i,3,!0)),a.vertexColors=!0}else if(null!==u){a.color=new l.Color(u[0],u[1],u[2]);let e=u[3]/255;e<1&&(a.opacity=e,a.transparent=!0,a.depthWrite=!1)}}let o=new l.Points(t,a);o.position.copy(n),e.scene=o,e.scene.featureTable=i,e.scene.batchTable=r;let c=i.getData("RTC_CENTER",1,"FLOAT","VEC3");return c&&(e.scene.position.x+=c[0],e.scene.position.y+=c[1],e.scene.position.z+=c[2]),e}))}};var li=new l.Spherical,ci=new l.Vector3,hi=new l.Vector3,di=new l.Vector3,ui=new l.Matrix4,pi=new l.Matrix4,mi=new l.Sphere,fi=new l.Euler,gi=new l.Vector3,bi=new l.Vector3,yi=new l.Vector3,vi=new l.Vector3,xi=new l.Ray,wi=class{constructor(e=1,t=1,i=1){this.name="",this.radius=new l.Vector3(e,t,i)}intersectRay(e,t){return ui.makeScale(...this.radius).invert(),mi.center.set(0,0,0),mi.radius=1,xi.copy(e).applyMatrix4(ui),xi.intersectSphere(mi,t)?(ui.makeScale(...this.radius),t.applyMatrix4(ui),t):null}getEastNorthUpFrame(e,t,i,r){return i.isMatrix4&&(r=i,i=0),this.getEastNorthUpAxes(e,t,gi,bi,yi),this.getCartographicToPosition(e,t,i,vi),r.makeBasis(gi,bi,yi).setPosition(vi)}getOrientedEastNorthUpFrame(e,t,i,r,a,s,n){return this.getObjectFrame(e,t,i,r,a,s,n,0)}getObjectFrame(e,t,i,r,a,s,n,o=2){return this.getEastNorthUpFrame(e,t,i,ui),fi.set(a,s,-r,"ZXY"),n.makeRotationFromEuler(fi).premultiply(ui),1===o?(fi.set(Math.PI/2,0,0,"XYZ"),pi.makeRotationFromEuler(fi),n.multiply(pi)):2===o&&(fi.set(-Math.PI/2,0,Math.PI,"XYZ"),pi.makeRotationFromEuler(fi),n.multiply(pi)),n}getCartographicFromObjectFrame(e,t,i=2){return 1===i?(fi.set(-Math.PI/2,0,0,"XYZ"),pi.makeRotationFromEuler(fi).premultiply(e)):2===i?(fi.set(-Math.PI/2,0,Math.PI,"XYZ"),pi.makeRotationFromEuler(fi).premultiply(e)):pi.copy(e),vi.setFromMatrixPosition(pi),this.getPositionToCartographic(vi,t),this.getEastNorthUpFrame(t.lat,t.lon,0,ui).invert(),pi.premultiply(ui),fi.setFromRotationMatrix(pi,"ZXY"),t.azimuth=-fi.z,t.elevation=fi.x,t.roll=fi.y,t}getEastNorthUpAxes(e,t,i,r,a,s=vi){this.getCartographicToPosition(e,t,0,s),this.getCartographicToNormal(e,t,a),i.set(-s.y,s.x,0).normalize(),r.crossVectors(a,i).normalize()}getCartographicToPosition(e,t,i,r){this.getCartographicToNormal(e,t,ci);let a=this.radius;hi.copy(ci),hi.x*=a.x**2,hi.y*=a.y**2,hi.z*=a.z**2;let s=Math.sqrt(ci.dot(hi));return hi.divideScalar(s),r.copy(hi).addScaledVector(ci,i)}getPositionToCartographic(e,t){this.getPositionToSurfacePoint(e,hi),this.getPositionToNormal(hi,ci);let i=di.subVectors(e,hi);return t.lon=Math.atan2(ci.y,ci.x),t.lat=Math.asin(ci.z),t.height=Math.sign(i.dot(e))*i.length(),t}getCartographicToNormal(e,t,i){return li.set(1,function(e){return-e+Math.PI/2}(e),t),i.setFromSpherical(li).normalize(),function(e){let{x:t,y:i,z:r}=e;e.x=r,e.y=t,e.z=i}(i),i}getPositionToNormal(e,t){let i=this.radius;return t.copy(e),t.x/=i.x**2,t.y/=i.y**2,t.z/=i.z**2,t.normalize(),t}getPositionToSurfacePoint(e,t){let i=this.radius,r=1/i.x**2,a=1/i.y**2,s=1/i.z**2,n=e.x*e.x*r,o=e.y*e.y*a,l=e.z*e.z*s,c=n+o+l,h=Math.sqrt(1/c),d=hi.copy(e).multiplyScalar(h);if(c<.1)return isFinite(h)?t.copy(d):null;let u,p,m,f,g,b,y,v,x,w,T,_=di.set(d.x*r*2,d.y*a*2,d.z*s*2),A=(1-h)*e.length()/(.5*_.length()),S=0;do{A-=S,m=1/(1+A*r),f=1/(1+A*a),g=1/(1+A*s),b=m*m,y=f*f,v=g*g,x=b*m,w=y*f,T=v*g,u=n*b+o*y+l*v-1,p=n*x*r+o*w*a+l*T*s,S=u/(-2*p)}while(Math.abs(u)>1e-12);return t.set(e.x*m,e.y*f,e.z*g)}calculateHorizonDistance(e,t){let i=this.calculateEffectiveRadius(e);return Math.sqrt(2*i*t+t**2)}calculateEffectiveRadius(e){let t=this.radius.x,i=1-this.radius.z**2/t**2,r=e*l.MathUtils.DEG2RAD,a=Math.sin(r)**2;return t/Math.sqrt(1-i*a)}getPositionElevation(e){this.getPositionToSurfacePoint(e,hi);let t=di.subVectors(e,hi);return Math.sign(t.dot(e))*t.length()}closestPointToRayEstimate(e,t){return this.intersectRay(e,t)?t:(ui.makeScale(...this.radius).invert(),xi.copy(e).applyMatrix4(ui),hi.set(0,0,0),xi.closestPointToPoint(hi,t).normalize(),ui.makeScale(...this.radius),t.applyMatrix4(ui))}copy(e){return this.radius.copy(e.radius),this}clone(){return(new this.constructor).copy(this)}},Ti=new wi(fe,fe,6356752.314245179);Ti.name="WGS84 Earth";var _i=new l.Vector3,Ai=new l.Vector3,Si=new l.Vector3,Mi=new l.Vector3,Ci=new l.Quaternion,Ei=new l.Vector3,Ri=new l.Matrix4,ki=new l.Matrix4,Pi=new l.Vector3,Fi=new l.Matrix4,Li=new l.Quaternion,Di={};function Ui(e,t,i,r){if(e=e/i*2-1,t=t/i*2-1,r.x=e,r.y=t,r.z=1-Math.abs(e)-Math.abs(t),r.z<0){let e=r.x;r.x=(1-Math.abs(r.y))*(e>=0?1:-1),r.y=(1-Math.abs(e))*(r.y>=0?1:-1)}return r.normalize(),r}var Ii=class extends Ze{constructor(e=l.DefaultLoadingManager){super(),this.manager=e,this.adjustmentTransform=new l.Matrix4,this.ellipsoid=Ti.clone()}resolveExternalURL(e){return this.manager.resolveURL(super.resolveExternalURL(e))}parse(e){return super.parse(e).then((e=>{let{featureTable:t,batchTable:i}=e,r=e.glbBytes.slice().buffer;return new Promise(((a,s)=>{let n=this.fetchOptions,o=this.manager,c=o.getHandler("path.gltf")||new at(o);"include"===n.credentials&&"cors"===n.mode&&c.setCrossOrigin("use-credentials"),"credentials"in n&&c.setWithCredentials("include"===n.credentials),n.headers&&c.setRequestHeader(n.headers);let h=e.gltfWorkingPath??this.workingPath;/[\\/]$/.test(h)||(h+="/");let d=this.adjustmentTransform;c.parse(r,h,(e=>{let r=t.getData("INSTANCES_LENGTH"),s=t.getData("POSITION",r,"FLOAT","VEC3"),n=t.getData("POSITION_QUANTIZED",r,"UNSIGNED_SHORT","VEC3"),o=t.getData("QUANTIZED_VOLUME_OFFSET",1,"FLOAT","VEC3"),c=t.getData("QUANTIZED_VOLUME_SCALE",1,"FLOAT","VEC3"),h=t.getData("NORMAL_UP",r,"FLOAT","VEC3"),u=t.getData("NORMAL_RIGHT",r,"FLOAT","VEC3"),p=t.getData("NORMAL_UP_OCT32P",r,"UNSIGNED_SHORT","VEC2"),m=t.getData("NORMAL_RIGHT_OCT32P",r,"UNSIGNED_SHORT","VEC2"),f=t.getData("SCALE_NON_UNIFORM",r,"FLOAT","VEC3"),g=t.getData("SCALE",r,"FLOAT","SCALAR"),b=t.getData("RTC_CENTER",1,"FLOAT","VEC3"),y=t.getData("EAST_NORTH_UP");if(!s&&n){s=new Float32Array(3*r);for(let e=0;e<r;e++)s[3*e+0]=o[0]+n[3*e+0]/65535*c[0],s[3*e+1]=o[1]+n[3*e+1]/65535*c[1],s[3*e+2]=o[2]+n[3*e+2]/65535*c[2]}let v=new l.Vector3;for(let t=0;t<r;t++)v.x+=s[3*t+0]/r,v.y+=s[3*t+1]/r,v.z+=s[3*t+2]/r;let x=[],w=[];e.scene.updateMatrixWorld(),e.scene.traverse((e=>{if(e.isMesh){w.push(e);let{geometry:t,material:i}=e,a=new l.InstancedMesh(t,i,r);a.position.copy(v),b&&(a.position.x+=b[0],a.position.y+=b[1],a.position.z+=b[2]),x.push(a)}}));for(let t=0;t<r;t++){Mi.set(s[3*t+0]-v.x,s[3*t+1]-v.y,s[3*t+2]-v.z),Ci.identity(),h&&u?(Ai.set(h[3*t+0],h[3*t+1],h[3*t+2]),Si.set(u[3*t+0],u[3*t+1],u[3*t+2]),_i.crossVectors(Si,Ai).normalize(),Ri.makeBasis(Si,Ai,_i),Ci.setFromRotationMatrix(Ri)):p&&m&&(Ui(p[2*t+0],p[2*t+1],65535,Ai),Ui(m[2*t+0],m[2*t+1],65535,Si),_i.crossVectors(Si,Ai).normalize(),Ri.makeBasis(Si,Ai,_i),Ci.setFromRotationMatrix(Ri)),Ei.set(1,1,1),f&&Ei.set(f[3*t+0],f[3*t+1],f[3*t+2]),g&&Ei.multiplyScalar(g[t]);for(let e=0,i=x.length;e<i;e++){let i=x[e];Li.copy(Ci),y&&(i.updateMatrixWorld(),Pi.copy(Mi).applyMatrix4(i.matrixWorld),this.ellipsoid.getPositionToCartographic(Pi,Di),this.ellipsoid.getEastNorthUpFrame(Di.lat,Di.lon,Fi),Li.setFromRotationMatrix(Fi)),Ri.compose(Mi,Li,Ei).multiply(d);let r=w[e];ki.multiplyMatrices(Ri,r.matrixWorld),i.setMatrixAt(t,ki)}}e.scene.clear(),e.scene.add(...x),e.batchTable=i,e.featureTable=t,e.scene.batchTable=i,e.scene.featureTable=t,a(e)}),s)}))}))}},Oi=class extends et{constructor(e=l.DefaultLoadingManager){super(),this.manager=e,this.adjustmentTransform=new l.Matrix4,this.ellipsoid=Ti.clone()}parse(e){let t=super.parse(e),{manager:i,ellipsoid:r,adjustmentTransform:a}=this,s=[];for(let n in t.tiles){let{type:e,buffer:o}=t.tiles[n];switch(e){case"b3dm":{let e=o.slice(),t=new ii(i);t.workingPath=this.workingPath,t.fetchOptions=this.fetchOptions,t.adjustmentTransform.copy(a);let r=t.parse(e.buffer);s.push(r);break}case"pnts":{let e=o.slice(),t=new oi(i);t.workingPath=this.workingPath,t.fetchOptions=this.fetchOptions;let r=t.parse(e.buffer);s.push(r);break}case"i3dm":{let e=o.slice(),t=new Ii(i);t.workingPath=this.workingPath,t.fetchOptions=this.fetchOptions,t.ellipsoid.copy(r),t.adjustmentTransform.copy(a);let n=t.parse(e.buffer);s.push(n);break}}}return Promise.all(s).then((e=>{let t=new l.Group;return e.forEach((e=>{t.add(e.scene)})),{tiles:e,scene:t}}))}},Bi=new l.Matrix4,Vi=class extends l.Group{constructor(e){super(),this.isTilesGroup=!0,this.name="TilesRenderer.TilesGroup",this.tilesRenderer=e,this.matrixWorldInverse=new l.Matrix4}raycast(e,t){return this.tilesRenderer.raycast(e,t),!1}updateMatrixWorld(e){if(this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldNeedsUpdate||e){null===this.parent?Bi.copy(this.matrix):Bi.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1;let e=Bi.elements,t=this.matrixWorld.elements,i=!1;for(let r=0;r<16;r++){let a=e[r],s=t[r];if(Math.abs(a-s)>2**-52){i=!0;break}}if(i){this.matrixWorld.copy(Bi),this.matrixWorldInverse.copy(Bi).invert();let e=this.children;for(let a=0,s=e.length;a<s;a++)e[a].updateMatrixWorld();let{tilesRenderer:t}=this,{activeTiles:i,visibleTiles:r}=t;i.forEach((e=>{r.has(e)||e.engineData.scene.updateMatrixWorld(!0)}))}}}updateWorldMatrix(e,t){this.parent&&e&&this.parent.updateWorldMatrix(e,!1),this.updateMatrixWorld(!0)}},Ni=new l.Ray;function ji(e,t,i,r,a=null){if(!function(e){return"traversal"in e}(t))return;let{group:s,activeTiles:n}=e,{boundingVolume:o}=t.engineData;if(null===a&&(a=Ni).copy(i.ray).applyMatrix4(s.matrixWorldInverse),!t.traversal.used||!o.intersectsRay(a))return;n.has(t)&&function(e,t,i,r){let{scene:a}=e.engineData;i.invokeOnePlugin((i=>i.raycastTile&&i.raycastTile(e,a,t,r)))||t.intersectObject(a,!0,r)}(t,i,e,r);let l=t.children;for(let c=0,h=l.length;c<h;c++)ji(e,l[c],i,r,a)}var zi=new l.Vector3,Gi=new l.Vector3,Hi=new l.Vector3,qi=new l.Ray,Wi=class{constructor(e=new l.Box3,t=new l.Matrix4){this.box=e.clone(),this.transform=t.clone(),this.inverseTransform=new l.Matrix4,this.points=Array(8).fill().map((()=>new l.Vector3)),this.planes=[,,,,,,].fill().map((()=>new l.Plane))}copy(e){return this.box.copy(e.box),this.transform.copy(e.transform),this.update(),this}clone(){return(new this.constructor).copy(this)}clampPoint(e,t){return t.copy(e).applyMatrix4(this.inverseTransform).clamp(this.box.min,this.box.max).applyMatrix4(this.transform)}distanceToPoint(e){return this.clampPoint(e,Hi).distanceTo(e)}containsPoint(e){return Hi.copy(e).applyMatrix4(this.inverseTransform),this.box.containsPoint(Hi)}intersectsRay(e){return qi.copy(e).applyMatrix4(this.inverseTransform),qi.intersectsBox(this.box)}intersectRay(e,t){return qi.copy(e).applyMatrix4(this.inverseTransform),qi.intersectBox(this.box,t)?(t.applyMatrix4(this.transform),t):null}update(){let{points:e,inverseTransform:t,transform:i,box:r}=this;t.copy(i).invert();let{min:a,max:s}=r,n=0;for(let o=-1;o<=1;o+=2)for(let t=-1;t<=1;t+=2)for(let r=-1;r<=1;r+=2)e[n].set(o<0?a.x:s.x,t<0?a.y:s.y,r<0?a.z:s.z).applyMatrix4(i),n++;this.updatePlanes()}updatePlanes(){zi.copy(this.box.min).applyMatrix4(this.transform),Gi.copy(this.box.max).applyMatrix4(this.transform),Hi.set(0,0,1).transformDirection(this.transform),this.planes[0].setFromNormalAndCoplanarPoint(Hi,zi),this.planes[1].setFromNormalAndCoplanarPoint(Hi,Gi).negate(),Hi.set(0,1,0).transformDirection(this.transform),this.planes[2].setFromNormalAndCoplanarPoint(Hi,zi),this.planes[3].setFromNormalAndCoplanarPoint(Hi,Gi).negate(),Hi.set(1,0,0).transformDirection(this.transform),this.planes[4].setFromNormalAndCoplanarPoint(Hi,zi),this.planes[5].setFromNormalAndCoplanarPoint(Hi,Gi).negate()}intersectsSphere(e){return this.clampPoint(e.center,Hi),Hi.distanceToSquared(e.center)<=e.radius*e.radius}intersectsFrustum(e){return this._intersectsPlaneShape(e.planes,e.points)}intersectsOBB(e){return this._intersectsPlaneShape(e.planes,e.points)}_intersectsPlaneShape(e,t){let i=this.points,r=this.planes;for(let a=0;a<6;a++){let t=e[a],r=-1/0;for(let e=0;e<8;e++){let a=i[e],s=t.distanceToPoint(a);r=r<s?s:r}if(r<0)return!1}for(let a=0;a<6;a++){let e=r[a],i=-1/0;for(let r=0;r<8;r++){let a=t[r],s=e.distanceToPoint(a);i=i<s?s:i}if(i<0)return!1}return!0}},Ki=Math.PI,Ji=Ki/2,Xi=new l.Vector3,Qi=new l.Vector3,Yi=new l.Vector3,Zi=new l.Vector3,$i=new l.Matrix4,er=new l.Box3,tr=new l.Matrix4;function ir(e,t){t.radius=Math.max(t.radius,e.distanceToSquared(t.center))}function rr(e){return e.x!==e.y}var ar=class extends wi{constructor(e=1,t=1,i=1,r=-Ji,a=Ji,s=0,n=2*Ki,o=0,l=0){super(e,t,i),this.latStart=r,this.latEnd=a,this.lonStart=s,this.lonEnd=n,this.heightStart=o,this.heightEnd=l}getBoundingBox(e,t){rr(this.radius);let i,{latStart:r,latEnd:a,lonStart:s,lonEnd:n,heightStart:o,heightEnd:l}=this,c=.5*(r+a),h=.5*(s+n),d=r>0,u=a<0;i=d?r:u?a:0;let{min:p,max:m}=e;p.setScalar(1/0),m.setScalar(-1/0),n-s<=Ki?(this.getCartographicToNormal(c,h,Yi),Qi.set(0,0,1),Xi.crossVectors(Qi,Yi).normalize(),Qi.crossVectors(Yi,Xi).normalize(),t.makeBasis(Xi,Qi,Yi),$i.copy(t).invert(),this.getCartographicToPosition(i,s,l,Zi).applyMatrix4($i),m.x=Math.abs(Zi.x),p.x=-m.x,this.getCartographicToPosition(a,s,l,Zi).applyMatrix4($i),m.y=Zi.y,this.getCartographicToPosition(a,h,l,Zi).applyMatrix4($i),m.y=Math.max(Zi.y,m.y),this.getCartographicToPosition(r,s,l,Zi).applyMatrix4($i),p.y=Zi.y,this.getCartographicToPosition(r,h,l,Zi).applyMatrix4($i),p.y=Math.min(Zi.y,p.y),this.getCartographicToPosition(c,h,l,Zi).applyMatrix4($i),m.z=Zi.z,this.getCartographicToPosition(r,s,o,Zi).applyMatrix4($i),p.z=Zi.z,this.getCartographicToPosition(a,s,o,Zi).applyMatrix4($i),p.z=Math.min(Zi.z,p.z)):(this.getCartographicToPosition(i,h,l,Yi),Yi.z=0,Yi.length()<1e-10?Yi.set(1,0,0):Yi.normalize(),Qi.set(0,0,1),Xi.crossVectors(Yi,Qi).normalize(),t.makeBasis(Xi,Qi,Yi),$i.copy(t).invert(),this.getCartographicToPosition(i,h+Ji,l,Zi).applyMatrix4($i),m.x=Math.abs(Zi.x),p.x=-m.x,this.getCartographicToPosition(a,0,u?o:l,Zi).applyMatrix4($i),m.y=Zi.y,this.getCartographicToPosition(r,0,d?o:l,Zi).applyMatrix4($i),p.y=Zi.y,this.getCartographicToPosition(i,h,l,Zi).applyMatrix4($i),m.z=Zi.z,this.getCartographicToPosition(i,n,l,Zi).applyMatrix4($i),p.z=Zi.z),e.getCenter(Zi),e.min.sub(Zi).multiplyScalar(1.0000000000001),e.max.sub(Zi).multiplyScalar(1.0000000000001),Zi.applyMatrix4(t),t.setPosition(Zi)}getBoundingSphere(e){rr(this.radius),this.getBoundingBox(er,tr),e.center.setFromMatrixPosition(tr),e.radius=0;let t,{latStart:i,latEnd:r,lonStart:a,lonEnd:s,heightStart:n,heightEnd:o}=this,l=.5*(i+r),c=.5*(a+s);t=i>0?i:r<0?r:0,this.getCartographicToPosition(t,a,o,Zi),ir(Zi,e),this.getCartographicToPosition(r,a,o,Zi),ir(Zi,e),this.getCartographicToPosition(r,c,o,Zi),ir(Zi,e),this.getCartographicToPosition(i,a,o,Zi),ir(Zi,e),this.getCartographicToPosition(i,c,o,Zi),ir(Zi,e),this.getCartographicToPosition(l,c,o,Zi),ir(Zi,e),this.getCartographicToPosition(i,a,n,Zi),ir(Zi,e),s-a>Ki&&(this.getCartographicToPosition(t,c+Ki,o,Zi),ir(Zi,e)),e.radius=1.0000000000001*Math.sqrt(e.radius)}},sr=new l.Vector3,nr=new l.Vector3,or=new l.Vector3,lr=new l.Vector3,cr=new l.Vector3,hr=class{constructor(){this.sphere=null,this.obb=null,this.region=null,this.regionObb=null}intersectsRay(e){let t=this.sphere,i=this.obb||this.regionObb;return!(t&&!e.intersectsSphere(t)||i&&!i.intersectsRay(e))}intersectRay(e,t=null){let i=this.sphere,r=this.obb||this.regionObb,a=-1/0,s=-1/0;i&&e.intersectSphere(i,lr)&&(a=i.containsPoint(e.origin)?0:e.origin.distanceToSquared(lr)),r&&r.intersectRay(e,cr)&&(s=r.containsPoint(e.origin)?0:e.origin.distanceToSquared(cr));let n=Math.max(a,s);return n===-1/0?null:(e.at(Math.sqrt(n),t),t)}distanceToPoint(e){let t=this.sphere,i=this.obb||this.regionObb,r=-1/0,a=-1/0;return t&&(r=Math.max(t.distanceToPoint(e),0)),i&&(a=i.distanceToPoint(e)),r>a?r:a}intersectsFrustum(e){let t=this.obb||this.regionObb,i=this.sphere;return!(i&&!e.intersectsSphere(i)||t&&!t.intersectsFrustum(e))&&!(!i&&!t)}intersectsSphere(e){let t=this.obb||this.regionObb,i=this.sphere;return!(i&&!i.intersectsSphere(e)||t&&!t.intersectsSphere(e))&&!(!i&&!t)}intersectsOBB(e){let t=this.obb||this.regionObb,i=this.sphere;return!(i&&!e.intersectsSphere(i)||t&&!t.intersectsOBB(e))&&!(!i&&!t)}getOBB(e,t){let i=this.obb||this.regionObb;i?(e.copy(i.box),t.copy(i.transform)):(this.getAABB(e),t.identity())}getAABB(e){if(this.sphere)this.sphere.getBoundingBox(e);else{let t=this.obb||this.regionObb;e.copy(t.box).applyMatrix4(t.transform)}}getSphere(e){if(this.sphere)e.copy(this.sphere);else if(this.region)this.region.getBoundingSphere(e);else{let t=this.obb||this.regionObb;t.box.getBoundingSphere(e),e.applyMatrix4(t.transform)}}setObbData(e,t){let i=new Wi;sr.set(e[3],e[4],e[5]),nr.set(e[6],e[7],e[8]),or.set(e[9],e[10],e[11]);let r=sr.length(),a=nr.length(),s=or.length();sr.normalize(),nr.normalize(),or.normalize(),0===r&&sr.crossVectors(nr,or),0===a&&nr.crossVectors(sr,or),0===s&&or.crossVectors(sr,nr),i.transform.set(sr.x,nr.x,or.x,e[0],sr.y,nr.y,or.y,e[1],sr.z,nr.z,or.z,e[2],0,0,0,1).premultiply(t),i.box.min.set(-r,-a,-s),i.box.max.set(r,a,s),i.update(),this.obb=i}setSphereData(e,t,i,r,a){let s=new l.Sphere;s.center.set(e,t,i),s.radius=r,s.applyMatrix4(a),this.sphere=s}setRegionData(e,t,i,r,a,s,n){let o=new ar(...e.radius,i,a,t,r,s,n),l=new Wi;o.getBoundingBox(l.box,l.transform),l.update(),this.region=o,this.regionObb=l}},dr=new l.Matrix3;var ur=class extends l.Frustum{constructor(){super(),this.points=Array(8).fill().map((()=>new l.Vector3))}setFromProjectionMatrix(...e){return super.setFromProjectionMatrix(...e),this.calculateFrustumPoints(),this}calculateFrustumPoints(){let{planes:e,points:t}=this;[[e[0],e[3],e[4]],[e[1],e[3],e[4]],[e[0],e[2],e[4]],[e[1],e[2],e[4]],[e[0],e[3],e[5]],[e[1],e[3],e[5]],[e[0],e[2],e[5]],[e[1],e[2],e[5]]].forEach(((e,i)=>{!function(e,t,i,r){let a=dr.set(e.normal.x,e.normal.y,e.normal.z,t.normal.x,t.normal.y,t.normal.z,i.normal.x,i.normal.y,i.normal.z);r.set(-e.constant,-t.constant,-i.constant),r.applyMatrix3(a.invert())}(e[0],e[1],e[2],t[i])}))}};function pr(e,t,i,r){try{return l.TextureUtils.getByteLength(e,t,i,r)}catch{return 0}}function mr(e){var t,i;if(!e)return 0;if(e.isExternalTexture)return(null==(t=e.userData)?void 0:t.byteLength)??0;let{format:r,type:a,image:s,mipmaps:n}=e;if(e.isCompressedTexture&&Array.isArray(n)&&n.length>0){let e=0;for(let t of n)(null==(i=null==t?void 0:t.data)?void 0:i.byteLength)?e+=t.data.byteLength:e+=pr(t.width,t.height,r,a);return e}if(!s)return 0;let o=pr(s.width,s.height,r,a);return o*=e.generateMipmaps?4/3:1,o}var fr=Symbol("INITIAL_FRUSTUM_CULLED"),gr=new l.Matrix4,br=new l.Vector3,yr=new l.Vector2,vr=new l.Vector3(1,0,0),xr=new l.Vector3(0,1,0),wr=()=>null;function Tr(e,t){e.traverse((e=>{e.frustumCulled=e[fr]&&t}))}var _r=class extends je{get autoDisableRendererCulling(){return this._autoDisableRendererCulling}set autoDisableRendererCulling(e){this._autoDisableRendererCulling!==e&&(super._autoDisableRendererCulling=e,this.forEachLoadedModel((t=>{Tr(t,!e)})))}constructor(...e){super(...e),this.accelerateRaycast=!0,this.group=new Vi(this),this.ellipsoid=Ti.clone(),this.cameras=[],this.cameraMap=new Map,this.cameraInfo=[],this._upRotationMatrix=new l.Matrix4,this._bytesUsed=new WeakMap,this._autoDisableRendererCulling=!0,this.manager=new l.LoadingManager,this._listeners={}}addEventListener(e,t){l.EventDispatcher.prototype.addEventListener.call(this,e,t)}hasEventListener(e,t){return l.EventDispatcher.prototype.hasEventListener.call(this,e,t)}removeEventListener(e,t){l.EventDispatcher.prototype.removeEventListener.call(this,e,t)}dispatchEvent(e){l.EventDispatcher.prototype.dispatchEvent.call(this,e)}getBoundingBox(e){if(!this.root)return!1;let t=this.root.engineData.boundingVolume;return!!t&&(t.getAABB(e),!0)}getOrientedBoundingBox(e,t){if(!this.root)return!1;let i=this.root.engineData.boundingVolume;return!!i&&(i.getOBB(e,t),!0)}getBoundingSphere(e){if(!this.root)return!1;let t=this.root.engineData.boundingVolume;return!!t&&(t.getSphere(e),!0)}forEachLoadedModel(e){this.traverse((t=>{let i=t.engineData&&t.engineData.scene;i&&e(i,t)}),null,!1)}raycast(e,t){if(this.root)if(this.accelerateRaycast)ji(this,this.root,e,t);else{let i=e.firstHitOnly?[]:t;for(let t of this.activeTiles){let{scene:r}=t.engineData;this.invokeOnePlugin((a=>a.raycastTile&&a.raycastTile(t,r,e,i)))||e.intersectObject(r,!0,i)}e.firstHitOnly&&i.length>0&&(i.sort(((e,t)=>e.distance-t.distance)),t.push(i[0]))}}hasCamera(e){return this.cameraMap.has(e)}setCamera(e){let t=this.cameras,i=this.cameraMap;return!i.has(e)&&(i.set(e,new l.Vector2),t.push(e),this.dispatchEvent({type:"add-camera",camera:e}),!0)}setResolution(e,t,i){let r=this.cameraMap;if(!r.has(e))return!1;let a=t.isVector2?t.x:t,s=t.isVector2?t.y:i,n=r.get(e);return(n.width!==a||n.height!==s)&&(n.set(a,s),this.dispatchEvent({type:"camera-resolution-change"})),!0}getResolution(e,t){let i=this.cameraMap.get(e);return i?t.copy(i):null}setResolutionFromRenderer(e,t){return t.getSize(yr),this.setResolution(e,yr.x,yr.y)}deleteCamera(e){let t=this.cameras,i=this.cameraMap;if(i.has(e)){let r=t.indexOf(e);return t.splice(r,1),i.delete(e),this.dispatchEvent({type:"delete-camera",camera:e}),!0}return!1}loadRootTileset(...e){return super.loadRootTileset(...e).then((e=>{let{asset:t,extensions:i={}}=e;switch((t&&t.gltfUpAxis||"y").toLowerCase()){case"x":this._upRotationMatrix.makeRotationAxis(xr,-Math.PI/2);break;case"y":this._upRotationMatrix.makeRotationAxis(vr,Math.PI/2)}if("3DTILES_ellipsoid"in i){let e=i["3DTILES_ellipsoid"],{ellipsoid:t}=this;t.name=e.body,e.radii?t.radius.set(...e.radii):t.radius.set(1,1,1)}return e}))}prepareForTraversal(){let e=this.group,t=this.cameras,i=this.cameraMap,r=this.cameraInfo;for(;r.length>t.length;)r.pop();for(;r.length<t.length;)r.push({frustum:new ur,isOrthographic:!1,sseDenominator:-1,position:new l.Vector3,invScale:-1,pixelSize:0});br.setFromMatrixScale(e.matrixWorldInverse),Math.abs(Math.max(br.x-br.y,br.x-br.z));for(let a=0,s=r.length;a<s;a++){let s=t[a],n=r[a],o=n.frustum,l=n.position,c=i.get(s);0===c.width||c.height;let h=s.projectionMatrix.elements;if(n.isOrthographic=1===h[15],n.isOrthographic){let e=2/h[0],t=2/h[5];n.pixelSize=Math.max(t/c.height,e/c.width)}else n.sseDenominator=2/h[5]/c.height;gr.copy(e.matrixWorld),gr.premultiply(s.matrixWorldInverse),gr.premultiply(s.projectionMatrix),o.setFromProjectionMatrix(gr,s.coordinateSystem,s.reversedDepth),l.set(0,0,0),l.applyMatrix4(s.matrixWorld),l.applyMatrix4(e.matrixWorldInverse)}}update(){if(super.update(),0===this.cameras.length&&this.root){let e=!1;this.invokeAllPlugins((t=>e||(e=!(t===this||!t.calculateTileViewError))))}}preprocessNode(e,t,i=null){super.preprocessNode(e,t,i);let r=new l.Matrix4;if(e.transform){let t=e.transform;for(let e=0;e<16;e++)r.elements[e]=t[e]}i&&r.premultiply(i.engineData.transform);let a=(new l.Matrix4).copy(r).invert(),s=new hr;"sphere"in e.boundingVolume&&s.setSphereData(...e.boundingVolume.sphere,r),"box"in e.boundingVolume&&s.setObbData(e.boundingVolume.box,r),"region"in e.boundingVolume&&s.setRegionData(this.ellipsoid,...e.boundingVolume.region),e.engineData.transform=r,e.engineData.transformInverse=a,e.engineData.boundingVolume=s,e.engineData.geometry=null,e.engineData.materials=null,e.engineData.textures=null,e.toJSON=wr}async parseTile(e,t,i,r,a){let s=t.engineData,n=qe(r),o=this.fetchOptions,c=this.manager,h=null,d=s.transform,u=this._upRotationMatrix,p=(ze(e)||i).toLowerCase();switch(p){case"b3dm":{let t=new ii(c);t.workingPath=n,t.fetchOptions=o,t.adjustmentTransform.copy(u),h=t.parse(e);break}case"pnts":{let t=new oi(c);t.workingPath=n,t.fetchOptions=o,h=t.parse(e);break}case"i3dm":{let t=new Ii(c);t.workingPath=n,t.fetchOptions=o,t.adjustmentTransform.copy(u),t.ellipsoid.copy(this.ellipsoid),h=t.parse(e);break}case"cmpt":{let t=new Oi(c);t.workingPath=n,t.fetchOptions=o,t.adjustmentTransform.copy(u),t.ellipsoid.copy(this.ellipsoid),h=t.parse(e).then((e=>e.scene));break}case"gltf":case"glb":{let t=c.getHandler("path.gltf")||c.getHandler("path.glb")||new at(c);t.setWithCredentials("include"===o.credentials),t.setRequestHeader(o.headers||{}),"include"===o.credentials&&"cors"===o.mode&&t.setCrossOrigin("use-credentials");let i=t.resourcePath||t.path||n;!/[\\/]$/.test(i)&&i.length&&(i+="/"),h=t.parseAsync(e,i).then((e=>{e.scene=e.scene||new l.Group;let{scene:t}=e;return t.updateMatrix(),t.matrix.multiply(u).decompose(t.position,t.quaternion,t.scale),e}));break}default:h=this.invokeOnePlugin((s=>s.parseToMesh&&s.parseToMesh(e,t,i,r,a)))}let m,f,g=await h;if(null===g)throw Error(`TilesRenderer: Content type "${p}" not supported.`);g.isObject3D?(m=g,f=null):(m=g.scene,f=g),m.updateMatrix(),m.matrix.premultiply(d),m.matrix.decompose(m.position,m.quaternion,m.scale),await this.invokeAllPlugins((e=>e.processTileModel&&e.processTileModel(m,t))),m.traverse((e=>{e[fr]=e.frustumCulled,e.userData.tile=t})),Tr(m,!this.autoDisableRendererCulling);let b=[],y=[],v=[];if(m.traverse((e=>{if(e.geometry&&y.push(e.geometry),e.material){let t=e.material;b.push(e.material);for(let e in t){let i=t[e];i&&i.isTexture&&v.push(i)}}})),a.aborted)for(let l=0,x=v.length;l<x;l++){let e=v[l];e.image instanceof ImageBitmap&&e.image.close(),e.dispose()}else s.materials=b,s.geometry=y,s.textures=v,s.scene=m,s.metadata=f}disposeTile(e){super.disposeTile(e);let t=e.engineData;if(t.scene){let e=t.materials,i=t.geometry,r=t.textures,a=t.scene.parent;t.scene.traverse((e=>{e.userData.meshFeatures&&e.userData.meshFeatures.dispose(),e.userData.structuralMetadata&&e.userData.structuralMetadata.dispose()}));for(let t=0,s=i.length;t<s;t++)i[t].dispose();for(let t=0,s=e.length;t<s;t++)e[t].dispose();for(let t=0,s=r.length;t<s;t++){let e=r[t];e.image instanceof ImageBitmap&&e.image.close(),e.dispose()}a&&a.remove(t.scene),t.scene=null,t.materials=null,t.textures=null,t.geometry=null,t.metadata=null}}setTileActive(e,t){super.setTileActive(e,t);let i=e.engineData.scene;i&&(t?(i.parent=this.group,i.updateMatrixWorld(!0)):i.parent=null)}setTileVisible(e,t){let i=e.engineData.scene,{activeTiles:r,group:a}=this;i&&(t?a.add(i):(a.remove(i),r.has(e)&&(i.parent=a))),super.setTileVisible(e,t)}calculateBytesUsed(e,t){let i=this._bytesUsed;return!i.has(e)&&t&&i.set(e,function(e){let t=new Set,i=0;return e.traverse((e=>{if(e.geometry&&!t.has(e.geometry)&&(i+=function(e){let t=0;for(const r in e.attributes){const i=e.getAttribute(r);t+=i.count*i.itemSize*i.array.BYTES_PER_ELEMENT}const i=e.getIndex();return t+=i?i.count*i.itemSize*i.array.BYTES_PER_ELEMENT:0,t}(e.geometry),t.add(e.geometry)),e.material){let r=e.material;for(let e in r){let a=r[e];a&&a.isTexture&&!t.has(a)&&(i+=mr(a),t.add(a))}}})),i}(t)),i.get(e)??null}calculateTileViewError(e,t){let i=e.engineData,r=this.cameras,a=this.cameraInfo,s=i.boundingVolume,n=!1,o=0,l=1/0,c=0,h=1/0;for(let d=0,u=r.length;d<u;d++){let t,i,r=a[d];if(r.isOrthographic){let a=r.pixelSize;t=e.geometricError/a,i=1/0}else{let a=r.sseDenominator;i=s.distanceToPoint(r.position),t=0===i?1/0:e.geometricError/(i*a)}let u=a[d].frustum;s.intersectsFrustum(u)&&(n=!0,o=Math.max(o,t),l=Math.min(l,i)),c=Math.max(c,t),h=Math.min(h,i)}n?(t.inView=!0,t.error=o,t.distanceFromCamera=l):(t.inView=!1,t.error=c,t.distanceFromCamera=h)}dispose(){super.dispose(),this.group.removeFromParent()}};const Ar=new l.Matrix4,Sr=new l.Matrix4,Mr=new l.Vector3,Cr=new l.Vector3,Er=new l.Vector3,Rr=new l.Vector3,kr=new l.Vector3,Pr=new l.Vector3,Fr=new l.Quaternion,Lr=new l.Vector3,Dr=new l.Vector3,Ur=new l.Ray,Ir=new wi,Or=new l.Vector2,Br={};class Vr extends le{get tilesGroup(){return this.ellipsoidFrame}get ellipsoidFrame(){return this.ellipsoidGroup.matrixWorld}get ellipsoidFrameInverse(){const{ellipsoidGroup:e,ellipsoidFrame:t,_ellipsoidFrameInverse:i}=this;return e.matrixWorldInverse?e.matrixWorldInverse:i.copy(t).invert()}constructor(e=null,t=null,i=null,r=null){super(e,t,i),this.isGlobeControls=!0,this._dragMode=0,this._rotationMode=0,this.maxZoom=.01,this.nearMargin=.25,this.farMargin=0,this.useFallbackPlane=!1,this.autoAdjustCameraRotation=!1,this.globeInertia=new l.Quaternion,this.globeInertiaFactor=0,this.ellipsoid=Ti.clone(),this.ellipsoidGroup=new l.Group,this._ellipsoidFrameInverse=new l.Matrix4,null!==r&&this.setTilesRenderer(r)}setTilesRenderer(e){super.setTilesRenderer(e),null!==e&&this.setEllipsoid(e.ellipsoid,e.group)}setEllipsoid(e,t){this.ellipsoid=e||Ti.clone(),this.ellipsoidGroup=t||new l.Group}getPivotPoint(e){const{camera:t,ellipsoidFrame:i,ellipsoidFrameInverse:r,ellipsoid:a}=this;return Rr.set(0,0,-1).transformDirection(t.matrixWorld),Ur.origin.copy(t.position),Ur.direction.copy(Rr),Ur.applyMatrix4(r),a.closestPointToRayEstimate(Ur,Cr).applyMatrix4(i),(null===super.getPivotPoint(e)||Mr.subVectors(e,Ur.origin).dot(Ur.direction)>Mr.subVectors(Cr,Ur.origin).dot(Ur.direction))&&e.copy(Cr),e}getVectorToCenter(e){const{ellipsoidFrame:t,camera:i}=this;return e.setFromMatrixPosition(t).sub(i.position)}getDistanceToCenter(){return this.getVectorToCenter(Cr).length()}getUpDirection(e,t){const{ellipsoidFrame:i,ellipsoidFrameInverse:r,ellipsoid:a}=this;Cr.copy(e).applyMatrix4(r),a.getPositionToNormal(Cr,t),t.transformDirection(i)}getCameraUpDirection(e){const{ellipsoidFrame:t,ellipsoidFrameInverse:i,ellipsoid:r,camera:a}=this;a.isOrthographicCamera?(this._getVirtualOrthoCameraPosition(Cr),Cr.applyMatrix4(i),r.getPositionToNormal(Cr,e),e.transformDirection(t)):this.getUpDirection(a.position,e)}update(e=Math.min(this.clock.getDelta(),.064)){if(!this.enabled||!this.camera||0===e)return;const{camera:t,pivotMesh:i}=this;this._isNearControls()?this.scaleZoomOrientationAtEdges=this.zoomDelta<0:(0!==this.state&&1!==this._dragMode&&1!==this._rotationMode&&(i.visible=!1),this.scaleZoomOrientationAtEdges=!1);const r=this.needsUpdate||this._inertiaNeedsUpdate();super.update(e),this.adjustCamera(t),r&&this._isNearControls()&&(this.getCameraUpDirection(Pr),this._alignCameraUp(Pr,1),this.getCameraUpDirection(Pr),this._clampRotation(Pr))}adjustCamera(e){super.adjustCamera(e);const{ellipsoidFrame:t,ellipsoidFrameInverse:i,ellipsoid:r,nearMargin:a,farMargin:s}=this,n=Math.max(...r.radius);if(e.isPerspectiveCamera){const o=Cr.setFromMatrixPosition(t).sub(e.position).length(),c=a*n,h=l.MathUtils.clamp((o-n)/c,0,1),d=l.MathUtils.lerp(1,1e3,h);e.near=Math.max(d,o-n-c),Mr.copy(e.position).applyMatrix4(i),r.getPositionToCartographic(Mr,Br);const u=Math.max(r.getPositionElevation(Mr),2550),p=r.calculateHorizonDistance(Br.lat,u);e.far=p+.1+n*s,e.updateProjectionMatrix()}else{this._getVirtualOrthoCameraPosition(e.position,e),e.updateMatrixWorld(),Ar.copy(e.matrixWorld).invert(),Cr.setFromMatrixPosition(t).applyMatrix4(Ar);const i=-Cr.z;e.near=i-n*(1+a),e.far=i+.1+n*s,e.position.addScaledVector(Rr,e.near),e.far-=e.near,e.near=0,e.updateProjectionMatrix(),e.updateMatrixWorld()}}setState(...e){super.setState(...e),this._dragMode=0,this._rotationMode=0}_updateInertia(e){super._updateInertia(e);const{globeInertia:t,enableDamping:i,dampingFactor:r,camera:a,cameraRadius:s,minDistance:n,inertiaTargetDistance:o,ellipsoidFrame:l}=this;if(!this.enableDamping||this.inertiaStableFrames>1)return this.globeInertiaFactor=0,void this.globeInertia.identity();const c=Math.pow(2,-e/r),h=Math.max(a.near,s,n,o),d=25e-5;if(Er.setFromMatrixPosition(l),0!==this.globeInertiaFactor){L(Ur,Cr.set(0,0,-1),a),Ur.applyMatrix4(a.matrixWorldInverse),Ur.direction.normalize(),Ur.recast(-Ur.direction.dot(Ur.origin)).at(h/Ur.direction.z,Cr),Cr.applyMatrix4(a.matrixWorld),L(Ur,Mr.set(d,d,-1),a),Ur.applyMatrix4(a.matrixWorldInverse),Ur.direction.normalize(),Ur.recast(-Ur.direction.dot(Ur.origin)).at(h/Ur.direction.z,Mr),Mr.applyMatrix4(a.matrixWorld),Cr.sub(Er).normalize(),Mr.sub(Er).normalize(),this.globeInertiaFactor*=c;const r=Cr.angleTo(Mr)/e;(2*Math.acos(t.w)*this.globeInertiaFactor<r||!i)&&(this.globeInertiaFactor=0,t.identity())}0!==this.globeInertiaFactor&&(1!==t.w||0===t.x&&0===t.y&&0===t.z||(t.w=Math.min(t.w,1-1e-9)),Er.setFromMatrixPosition(l),Fr.identity().slerp(t,this.globeInertiaFactor*e),P(Er,Fr,Sr),a.matrixWorld.premultiply(Sr),a.matrixWorld.decompose(a.position,a.quaternion,Cr))}_inertiaNeedsUpdate(){return super._inertiaNeedsUpdate()||0!==this.globeInertiaFactor}_updatePosition(e){if(1===this.state){0===this._dragMode&&(this._dragMode=this._isNearControls()?1:-1);const{raycaster:t,camera:i,pivotPoint:r,pointerTracker:a,domElement:s,ellipsoidFrame:n,ellipsoidFrameInverse:o}=this,l=Mr,c=kr;a.getCenterPoint(Or),F(Or,s,Or),L(t,Or,i),t.ray.applyMatrix4(o);const h=Cr.copy(r).applyMatrix4(o).length();if(Ir.radius.setScalar(h),!Ir.intersectRay(t.ray,Cr))return this.resetState(),void this._updateInertia(e);Cr.applyMatrix4(n),Er.setFromMatrixPosition(n),l.subVectors(r,Er).normalize(),c.subVectors(Cr,Er).normalize(),Fr.setFromUnitVectors(c,l),P(Er,Fr,Sr),i.matrixWorld.premultiply(Sr),i.matrixWorld.decompose(i.position,i.quaternion,Cr),a.getMoveDistance()/e<2*window.devicePixelRatio?this.inertiaStableFrames++:(this.globeInertia.copy(Fr),this.globeInertiaFactor=1/e,this.inertiaStableFrames=0)}}_updateRotation(...e){1===this._rotationMode||this._isNearControls()||0!==this.rotationSpeed&&"mouse"===this.pointerTracker.getPointerType()&&this.pointerTracker.isRightClicked()?(this._rotationMode=1,super._updateRotation(...e)):(this.pivotMesh.visible=!1,this._rotationMode=-1)}_updateZoom(){const{zoomDelta:e,ellipsoid:t,zoomSpeed:i,zoomPoint:r,camera:a,maxZoom:s,state:n}=this;if(3!==n&&0===e)return;this.rotationInertia.set(0,0),this.dragInertia.set(0,0,0),this.globeInertia.identity(),this.globeInertiaFactor=0;const o=l.MathUtils.clamp(l.MathUtils.mapLinear(Math.abs(e),0,20,0,1),0,1);if(this._isNearControls()||e>0){if(this._updateZoomDirection(),e<0&&(this.zoomPointSet||this._updateZoomPoint())){Rr.set(0,0,-1).transformDirection(a.matrixWorld).normalize(),Dr.copy(this.up).multiplyScalar(-1),this.getUpDirection(r,Lr);const e=l.MathUtils.clamp(l.MathUtils.mapLinear(-Lr.dot(Dr),1,.95,0,1),0,1),t=1-Rr.dot(Dr),i=a.isOrthographicCamera?.05:1,s=l.MathUtils.clamp(3*o,0,1),n=Math.min(e*t*i*s,.1);Dr.lerpVectors(Rr,Dr,n).normalize(),Fr.setFromUnitVectors(Rr,Dr),P(r,Fr,Sr),a.matrixWorld.premultiply(Sr),a.matrixWorld.decompose(a.position,a.quaternion,Dr),this.zoomDirection.subVectors(r,a.position).normalize()}super._updateZoom()}else if(a.isPerspectiveCamera){const r=this._getPerspectiveTransitionDistance(),a=this._getMaxPerspectiveDistance(),s=l.MathUtils.mapLinear(this.getDistanceToCenter(),r,a,0,1);this._tiltTowardsCenter(l.MathUtils.lerp(0,.4,s*o)),this._alignCameraUpToNorth(l.MathUtils.lerp(0,.2,s*o));const n=e*(this.getDistanceToCenter()-t.radius.x)*i*.0025,c=Math.max(n,Math.min(this.getDistanceToCenter()-a,0));this.getVectorToCenter(Cr).normalize(),this.camera.position.addScaledVector(Cr,c),this.camera.updateMatrixWorld(),this.zoomDelta=0}else{const e=this._getOrthographicTransitionZoom(),t=this._getMinOrthographicZoom(),r=l.MathUtils.mapLinear(a.zoom,e,t,0,1);this._tiltTowardsCenter(l.MathUtils.lerp(0,.4,r*o)),this._alignCameraUpToNorth(l.MathUtils.lerp(0,.2,r*o));const n=this.zoomDelta,c=Math.pow(.95,Math.abs(.05*n)),h=n>0?1/Math.abs(c):c,d=t/a.zoom,u=Math.max(h*i,Math.min(d,1));a.zoom=Math.min(s,a.zoom*u),a.updateProjectionMatrix(),this.zoomDelta=0,this.zoomDirectionSet=!1}}_alignCameraUpToNorth(e){const{ellipsoidFrame:t}=this;Pr.set(0,0,1).transformDirection(t),this._alignCameraUp(Pr,e)}_tiltTowardsCenter(e){const{camera:t,ellipsoidFrame:i}=this;Rr.set(0,0,-1).transformDirection(t.matrixWorld).normalize(),Cr.setFromMatrixPosition(i).sub(t.position).normalize(),Cr.lerp(Rr,1-e).normalize(),Fr.setFromUnitVectors(Rr,Cr),t.quaternion.premultiply(Fr),t.updateMatrixWorld()}_getPerspectiveTransitionDistance(){const{camera:e,ellipsoid:t}=this;if(!e.isPerspectiveCamera)throw new Error;const i=Math.max(...t.radius),r=2*Math.atan(Math.tan(l.MathUtils.DEG2RAD*e.fov*.5)*e.aspect),a=i/Math.tan(l.MathUtils.DEG2RAD*e.fov*.5),s=i/Math.tan(.5*r);return Math.max(a,s)}_getMaxPerspectiveDistance(){const{camera:e,ellipsoid:t}=this;if(!e.isPerspectiveCamera)throw new Error;const i=Math.max(...t.radius),r=2*Math.atan(Math.tan(l.MathUtils.DEG2RAD*e.fov*.5)*e.aspect),a=i/Math.tan(l.MathUtils.DEG2RAD*e.fov*.5),s=i/Math.tan(.5*r);return 2*Math.max(a,s)}_getOrthographicTransitionZoom(){const{camera:e,ellipsoid:t}=this;if(!e.isOrthographicCamera)throw new Error;const i=e.top-e.bottom,r=e.right-e.left;return 2*Math.max(i,r)/(2*Math.max(...t.radius))}_getMinOrthographicZoom(){const{camera:e,ellipsoid:t}=this;if(!e.isOrthographicCamera)throw new Error;const i=e.top-e.bottom,r=e.right-e.left;return.7*Math.min(i,r)/(2*Math.max(...t.radius))}_getVirtualOrthoCameraPosition(e,t=this.camera){const{ellipsoidFrame:i,ellipsoidFrameInverse:r,ellipsoid:a}=this;if(!t.isOrthographicCamera)throw new Error;Ur.origin.copy(t.position),Ur.direction.set(0,0,-1).transformDirection(t.matrixWorld),Ur.applyMatrix4(r),a.closestPointToRayEstimate(Ur,Mr).applyMatrix4(i);const s=t.top-t.bottom,n=t.right-t.left,o=Math.max(s,n)/t.zoom;Rr.set(0,0,-1).transformDirection(t.matrixWorld);const l=Mr.sub(t.position).dot(Rr);e.copy(t.position).addScaledVector(Rr,l-4*o)}_isNearControls(){const{camera:e}=this;return e.isPerspectiveCamera?this.getDistanceToCenter()<this._getPerspectiveTransitionDistance():e.zoom>this._getOrthographicTransitionZoom()}_raycast(e){const t=super._raycast(e);if(null===t){const{ellipsoid:t,ellipsoidFrame:i,ellipsoidFrameInverse:r}=this;Ur.copy(e.ray).applyMatrix4(r);const a=t.intersectRay(Ur,Cr);return null!==a?{point:a.clone().applyMatrix4(i)}:null}return t}}const Nr=new WeakMap,jr="undefined"==typeof document?require("url").pathToFileURL(__dirname+"/assets/viewer/draco-decoder-c55a594e8ffd.wasm").href:new URL("assets/viewer/draco-decoder-c55a594e8ffd.wasm",document.currentScript&&"SCRIPT"===document.currentScript.tagName.toUpperCase()&&document.currentScript.src||document.baseURI).href,zr="undefined"==typeof document?require("url").pathToFileURL(__dirname+"/assets/viewer/draco-wasm-wrapper-e8049906ef3f.js").href:new URL("assets/viewer/draco-wasm-wrapper-e8049906ef3f.js",document.currentScript&&"SCRIPT"===document.currentScript.tagName.toUpperCase()&&document.currentScript.src||document.baseURI).href,Gr="undefined"==typeof document?require("url").pathToFileURL(__dirname+"/assets/viewer/draco-decoder-30e4d486fa02.js").href:new URL("assets/viewer/draco-decoder-30e4d486fa02.js",document.currentScript&&"SCRIPT"===document.currentScript.tagName.toUpperCase()&&document.currentScript.src||document.baseURI).href;class Hr extends l.Loader{constructor(e){super(e),this.decoderPaths={js:zr,wasm:jr,dep_js:Gr},this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){const{decoderPaths:t}=this;return"object"==typeof e?(t.js=e.js,t.wasm=e.wasm,t.dep_js=null):(t.js=l.LoaderUtils.resolveURL("draco_wasm_wrapper.js",e),t.wasm=l.LoaderUtils.resolveURL("draco_decoder.wasm",e),t.dep_js=l.LoaderUtils.resolveURL("draco_decoder.js",e)),this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,i,r){const a=new l.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(e=>{this.parse(e,t,r)}),i,r)}parse(e,t,i=()=>{}){this.decodeDracoFile(e,t,null,null,l.SRGBColorSpace,i).catch(i)}decodeDracoFile(e,t,i,r,a=l.LinearSRGBColorSpace,s=()=>{}){const n={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:a};return this.decodeGeometry(e,n).then(t).catch(s)}decodeGeometry(e,t){const i=JSON.stringify(t);if(Nr.has(e)){const t=Nr.get(e);if(t.key===i)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const a=this.workerNextTaskID++,s=e.byteLength,n=this._getWorker(a,s).then((i=>(r=i,new Promise(((i,s)=>{r._callbacks[a]={resolve:i,reject:s},r.postMessage({type:"decode",id:a,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return n.catch((()=>!0)).then((()=>{r&&a&&this._releaseTask(r,a)})),Nr.set(e,{key:i,promise:n}),n}_createGeometry(e){const t=new l.BufferGeometry;e.index&&t.setIndex(new l.BufferAttribute(e.index.array,1));for(let i=0;i<e.attributes.length;i++){const{name:r,array:a,itemSize:s,stride:n,vertexColorSpace:o}=e.attributes[i];let c;if(s===n)c=new l.BufferAttribute(a,s);else{const e=new l.InterleavedBuffer(a,n);c=new l.InterleavedBufferAttribute(e,s,0)}"color"===r&&(this._assignVertexColorSpace(c,o),c.normalized=a instanceof Float32Array==!1),t.setAttribute(r,c)}return t}_assignVertexColorSpace(e,t){if(t!==l.SRGBColorSpace)return;const i=new l.Color;for(let r=0,a=e.count;r<a;r++)i.fromBufferAttribute(e,r),l.ColorManagement.colorSpaceToWorking(i,l.SRGBColorSpace),e.setXYZ(r,i.r,i.g,i.b)}_loadLibrary(e,t){const i=new l.FileLoader(this.manager);return i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise(((t,r)=>{i.load(e,t,void 0,r)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[],{decoderPaths:i}=this;if(e){if(null===i.dep_js)throw new Error("THREE.DRACOLoader: WebAssembly is required when using a custom decoder paths.");t.push(this._loadLibrary(i.dep_js,"text"))}else t.push(this._loadLibrary(i.js,"text")),t.push(this._loadLibrary(i.wasm,"arraybuffer"));return this.decoderPending=Promise.all(t).then((t=>{const i=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const r=qr.toString(),a=["/* draco decoder */",i,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([a]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const i=t.data;switch(i.type){case"decode":e._callbacks[i.id].resolve(i);break;case"error":e._callbacks[i.id].reject(i)}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));const i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i}))}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,""!==this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),this}}function qr(){let e,t;function i(e,t,i,r,a,s){const n=i.num_points(),o=s.num_components(),l=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,a),c=o*a.BYTES_PER_ELEMENT,h=4*Math.ceil(c/4),d=h/a.BYTES_PER_ELEMENT,u=n*c,p=n*h,m=e._malloc(u);t.GetAttributeDataArrayForAllPoints(i,s,l,u,m);const f=new a(e.HEAPF32.buffer,m,u/a.BYTES_PER_ELEMENT);let g;if(c===h)g=f.slice();else{g=new a(p/a.BYTES_PER_ELEMENT);let e=0;for(let t=0,i=f.length;t<i;t++){for(let i=0;i<o;i++)g[e+i]=f[t*o+i];e+=d}}return e._free(m),{name:r,count:n,itemSize:o,array:g,stride:d}}onmessage=function(r){const a=r.data;switch(a.type){case"init":e=a.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const r=a.buffer,s=a.taskConfig;t.then((e=>{const t=e.draco,n=new t.Decoder;try{const e=function(e,t,r,a){const s=a.attributeIDs,n=a.attributeTypes;let o,l;const c=t.GetEncodedGeometryType(r);if(c===e.TRIANGULAR_MESH)o=new e.Mesh,l=t.DecodeArrayToMesh(r,r.byteLength,o);else{if(c!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");o=new e.PointCloud,l=t.DecodeArrayToPointCloud(r,r.byteLength,o)}if(!l.ok()||0===o.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const h={index:null,attributes:[]};for(const d in s){const r=self[n[d]];let l,c;if(a.useUniqueIDs)c=s[d],l=t.GetAttributeByUniqueId(o,c);else{if(c=t.GetAttributeId(o,e[s[d]]),-1===c)continue;l=t.GetAttribute(o,c)}const u=i(e,t,o,d,r,l);"color"===d&&(u.vertexColorSpace=a.vertexColorSpace),h.attributes.push(u)}c===e.TRIANGULAR_MESH&&(h.index=function(e,t,i){const r=i.num_faces(),a=3*r,s=4*a,n=e._malloc(s);t.GetTrianglesUInt32Array(i,s,n);const o=new Uint32Array(e.HEAPF32.buffer,n,a).slice();return e._free(n),{array:o,itemSize:1}}(e,t,o));return e.destroy(o),h}(t,n,new Int8Array(r),s),o=e.attributes.map((e=>e.array.buffer));e.index&&o.push(e.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:e},o)}catch(o){self.postMessage({type:"error",id:a.id,error:o.message})}finally{t.destroy(n)}}))}}}let Wr=class{constructor(e=4){this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0,this.workerCreator=null}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){const i=this.workersResolve[e];if(i&&i(t),this.queue.length){const{resolve:t,msg:i,transfer:r}=this.queue.shift();this.workersResolve[e]=t,this.workers[e].postMessage(i,r)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise((i=>{const r=this._getIdleWorker();-1!==r?(this._initWorker(r),this.workerStatus|=1<<r,this.workersResolve[r]=i,this.workers[r].postMessage(e,t)):this.queue.push({resolve:i,msg:e,transfer:t})}))}dispose(){this.workers.forEach((e=>e.terminate())),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}};const Kr=9,Jr=15,Xr=16,Qr=22,Yr=37,Zr=43,$r=76,ea=83,ta=91,ia=97,ra=100,aa=103,sa=109,na=122,oa=123,la=131,ca=132,ha=133,da=134,ua=137,pa=138,ma=139,fa=140,ga=141,ba=142,ya=145,va=146,xa=148,wa=152,Ta=153,_a=154,Aa=155,Sa=156,Ma=157,Ca=158,Ea=165,Ra=166,ka=1000054e3,Pa=1000054001,Fa=1000054004,La=1000054005,Da=1000066e3,Ua=1000066004;class Ia{constructor(e,t,i,r){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(e.buffer,e.byteOffset+t,i),this._littleEndian=r,this._offset=0}_nextUint8(){const e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){const e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){const e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){const e=this._dataView.getUint32(this._offset,this._littleEndian)+2**32*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,e}_nextInt32(){const e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint8Array(e){const t=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,e);return this._offset+=e,t}_skip(e){return this._offset+=e,this}_scan(e,t=0){const i=this._offset;let r=0;for(;this._dataView.getUint8(this._offset)!==t&&r<e;)r++,this._offset++;return r<e&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+i,r)}}const Oa=[171,75,84,88,32,50,48,187,13,10,26,10];function Ba(e){return(new TextDecoder).decode(e)}let Va,Na,ja;const za={env:{emscripten_notify_memory_growth:function(e){ja=new Uint8Array(Na.exports.memory.buffer)}}};class Ga{init(){return Va||(Va="undefined"!=typeof fetch?fetch("undefined"==typeof document?require("url").pathToFileURL(__dirname+"/assets/viewer/zstd-decoder-67d12d34f82e.wasm").href:new URL("assets/viewer/zstd-decoder-67d12d34f82e.wasm",document.currentScript&&"SCRIPT"===document.currentScript.tagName.toUpperCase()&&document.currentScript.src||document.baseURI).href).then((e=>e.arrayBuffer())).then((e=>WebAssembly.instantiate(e,za))).then(this._init):fetch("undefined"==typeof document?require("url").pathToFileURL(__dirname+"/assets/viewer/zstd-decoder-67d12d34f82e.wasm").href:new URL("assets/viewer/zstd-decoder-67d12d34f82e.wasm",document.currentScript&&"SCRIPT"===document.currentScript.tagName.toUpperCase()&&document.currentScript.src||document.baseURI).href).then((e=>e.arrayBuffer())).then((e=>WebAssembly.instantiate(e,za))).then(this._init),Va)}_init(e){Na=e.instance,za.env.emscripten_notify_memory_growth(0)}decode(e,t=0){if(!Na)throw new Error("ZSTDDecoder: Await .init() before decoding.");const i=e.byteLength,r=Na.exports.malloc(i);ja.set(e,r),t=t||Number(Na.exports.ZSTD_findDecompressedSize(r,i));const a=Na.exports.malloc(t),s=Na.exports.ZSTD_decompress(a,t,r,i),n=ja.slice(a,a+s);return Na.exports.free(r),Na.exports.free(a),n}}l.ColorManagement.spaces[l.SRGBColorSpace];const Ha="undefined"==typeof document?require("url").pathToFileURL(__dirname+"/assets/viewer/basis-transcoder-6cf17dc88935.wasm").href:new URL("assets/viewer/basis-transcoder-6cf17dc88935.wasm",document.currentScript&&"SCRIPT"===document.currentScript.tagName.toUpperCase()&&document.currentScript.src||document.baseURI).href,qa="undefined"==typeof document?require("url").pathToFileURL(__dirname+"/assets/viewer/basis-transcoder-8478b5b6d6b7.js").href:new URL("assets/viewer/basis-transcoder-8478b5b6d6b7.js",document.currentScript&&"SCRIPT"===document.currentScript.tagName.toUpperCase()&&document.currentScript.src||document.baseURI).href,Wa=new WeakMap;let Ka;class Ja extends l.Loader{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new Wr,this.workerSourceURL="",this.workerConfig=null}setTranscoderPath(e){return this.transcoderPath=e,this}setWorkerLimit(e){return this.workerPool.setWorkerLimit(e),this}async detectSupportAsync(e){return await e.init(),this.detectSupport(e)}detectSupport(e){return!0===e.isWebGPURenderer?this.workerConfig={astcSupported:e.hasFeature("texture-compression-astc"),astcHDRSupported:!1,etc1Supported:e.hasFeature("texture-compression-etc1"),etc2Supported:e.hasFeature("texture-compression-etc2"),dxtSupported:e.hasFeature("texture-compression-s3tc"),bptcSupported:e.hasFeature("texture-compression-bc"),pvrtcSupported:e.hasFeature("texture-compression-pvrtc")}:(this.workerConfig={astcSupported:e.extensions.has("WEBGL_compressed_texture_astc"),astcHDRSupported:e.extensions.has("WEBGL_compressed_texture_astc")&&e.extensions.get("WEBGL_compressed_texture_astc").getSupportedProfiles().includes("hdr"),etc1Supported:e.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:e.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:e.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:e.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:e.extensions.has("WEBGL_compressed_texture_pvrtc")||e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},"undefined"!=typeof navigator&&void 0!==navigator.platform&&void 0!==navigator.userAgent&&navigator.platform.indexOf("Linux")>=0&&navigator.userAgent.indexOf("Android")<0&&this.workerConfig.astcSupported&&this.workerConfig.etc2Supported&&this.workerConfig.bptcSupported&&this.workerConfig.dxtSupported&&(this.workerConfig.astcSupported=!1,this.workerConfig.etc1Supported=!1,this.workerConfig.etc2Supported=!1)),this}init(){if(!this.transcoderPending){const e=new l.FileLoader(this.manager);e.setWithCredentials(this.withCredentials);const t=new l.FileLoader(this.manager);let i,r;t.setWithCredentials(this.withCredentials),t.setResponseType("arraybuffer"),""===this.transcoderPath?(i=e.loadAsync(qa),r=t.loadAsync(Ha)):(e.setPath(this.transcoderPath),i=e.loadAsync("basis_transcoder.js"),t.setPath(this.transcoderPath),r=t.loadAsync("basis_transcoder.wasm")),this.transcoderPending=Promise.all([i,r]).then((([e,t])=>{const i=Ja.BasisWorker.toString(),r=["/* constants */","let _EngineFormat = "+JSON.stringify(Ja.EngineFormat),"let _EngineType = "+JSON.stringify(Ja.EngineType),"let _TranscoderFormat = "+JSON.stringify(Ja.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(Ja.BasisFormat),"/* basis_transcoder.js */",e,"/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r])),this.transcoderBinary=t,this.workerPool.setWorkerCreator((()=>{const e=new Worker(this.workerSourceURL),t=this.transcoderBinary.slice(0);return e.postMessage({type:"init",config:this.workerConfig,transcoderBinary:t},[t]),e}))}))}return this.transcoderPending}load(e,t,i,r){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const a=new l.FileLoader(this.manager);a.setPath(this.path),a.setCrossOrigin(this.crossOrigin),a.setWithCredentials(this.withCredentials),a.setRequestHeader(this.requestHeader),a.setResponseType("arraybuffer"),a.load(e,(e=>{this.parse(e,t,r)}),i,r)}parse(e,t,i){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");if(Wa.has(e)){return Wa.get(e).promise.then(t).catch(i)}this._createTexture(e).then((e=>t?t(e):null)).catch(i)}_createTextureFrom(e,t){const{type:i,error:r,data:{faces:a,width:s,height:n,format:o,type:c,dfdFlags:h}}=e;if("error"===i)return Promise.reject(r);let d;if(6===t.faceCount)d=new l.CompressedCubeTexture(a,o,c);else{const e=a[0].mipmaps;d=t.layerCount>1?new l.CompressedArrayTexture(e,s,n,t.layerCount,o,c):new l.CompressedTexture(e,s,n,o,c)}return d.minFilter=1===a[0].mipmaps.length?l.LinearFilter:l.LinearMipmapLinearFilter,d.magFilter=l.LinearFilter,d.generateMipmaps=!1,d.needsUpdate=!0,d.colorSpace=$a(t),d.premultiplyAlpha=!!(1&h),d}async _createTexture(e,t={}){const i=function(e){const t=new Uint8Array(e.buffer,e.byteOffset,Oa.length);if(t[0]!==Oa[0]||t[1]!==Oa[1]||t[2]!==Oa[2]||t[3]!==Oa[3]||t[4]!==Oa[4]||t[5]!==Oa[5]||t[6]!==Oa[6]||t[7]!==Oa[7]||t[8]!==Oa[8]||t[9]!==Oa[9]||t[10]!==Oa[10]||t[11]!==Oa[11])throw new Error("Missing KTX 2.0 identifier.");const i={vkFormat:0,typeSize:1,pixelWidth:0,pixelHeight:0,pixelDepth:0,layerCount:0,faceCount:1,levelCount:0,supercompressionScheme:0,levels:[],dataFormatDescriptor:[{vendorId:0,descriptorType:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],keyValue:{},globalData:null},r=17*Uint32Array.BYTES_PER_ELEMENT,a=new Ia(e,Oa.length,r,!0);i.vkFormat=a._nextUint32(),i.typeSize=a._nextUint32(),i.pixelWidth=a._nextUint32(),i.pixelHeight=a._nextUint32(),i.pixelDepth=a._nextUint32(),i.layerCount=a._nextUint32(),i.faceCount=a._nextUint32(),i.levelCount=a._nextUint32(),i.supercompressionScheme=a._nextUint32();const s=a._nextUint32(),n=a._nextUint32(),o=a._nextUint32(),l=a._nextUint32(),c=a._nextUint64(),h=a._nextUint64(),d=3*Math.max(i.levelCount,1)*8,u=new Ia(e,Oa.length+r,d,!0);for(let O=0,B=Math.max(i.levelCount,1);O<B;O++)i.levels.push({levelData:new Uint8Array(e.buffer,e.byteOffset+u._nextUint64(),u._nextUint64()),uncompressedByteLength:u._nextUint64()});const p=new Ia(e,s,n,!0);p._skip(4);const m=p._nextUint16(),f=p._nextUint16(),g=p._nextUint16(),b=p._nextUint16(),y={vendorId:m,descriptorType:f,versionNumber:g,colorModel:p._nextUint8(),colorPrimaries:p._nextUint8(),transferFunction:p._nextUint8(),flags:p._nextUint8(),texelBlockDimension:[p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8()],bytesPlane:[p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8()],samples:[]},v=(b/4-6)/4;for(let O=0;O<v;O++){const e={bitOffset:p._nextUint16(),bitLength:p._nextUint8(),channelType:p._nextUint8(),samplePosition:[p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};64&e.channelType?(e.sampleLower=p._nextInt32(),e.sampleUpper=p._nextInt32()):(e.sampleLower=p._nextUint32(),e.sampleUpper=p._nextUint32()),y.samples[O]=e}i.dataFormatDescriptor.length=0,i.dataFormatDescriptor.push(y);const x=new Ia(e,o,l,!0);for(;x._offset<l;){const e=x._nextUint32(),t=x._scan(e),r=Ba(t);if(i.keyValue[r]=x._nextUint8Array(e-t.byteLength-1),r.match(/^ktx/i)){const e=Ba(i.keyValue[r]);i.keyValue[r]=e.substring(0,e.lastIndexOf("\0"))}x._skip(e%4?4-e%4:0)}if(h<=0)return i;const w=new Ia(e,c,h,!0),T=w._nextUint16(),_=w._nextUint16(),A=w._nextUint32(),S=w._nextUint32(),M=w._nextUint32(),C=w._nextUint32(),E=[];for(let O=0,B=Math.max(i.levelCount,1);O<B;O++)E.push({imageFlags:w._nextUint32(),rgbSliceByteOffset:w._nextUint32(),rgbSliceByteLength:w._nextUint32(),alphaSliceByteOffset:w._nextUint32(),alphaSliceByteLength:w._nextUint32()});const R=c+w._offset,k=R+A,P=k+S,F=P+M,L=new Uint8Array(e.buffer,e.byteOffset+R,A),D=new Uint8Array(e.buffer,e.byteOffset+k,S),U=new Uint8Array(e.buffer,e.byteOffset+P,M),I=new Uint8Array(e.buffer,e.byteOffset+F,C);return i.globalData={endpointCount:T,selectorCount:_,imageDescs:E,endpointsData:L,selectorsData:D,tablesData:U,extendedData:I},i}(new Uint8Array(e)),r=i.vkFormat===Da&&167===i.dataFormatDescriptor[0].colorModel;if(!(0===i.vkFormat||r&&!this.workerConfig.astcHDRSupported))return async function(e){const{vkFormat:t}=e;if(void 0===Ya[t])throw new Error("THREE.KTX2Loader: Unsupported vkFormat: "+t);Za[t];let i;2===e.supercompressionScheme&&(Ka||(Ka=new Promise((async e=>{const t=new Ga;await t.init(),e(t)}))),i=await Ka);const r=[];for(let n=0;n<e.levels.length;n++){const a=Math.max(1,e.pixelWidth>>n),s=Math.max(1,e.pixelHeight>>n),o=e.pixelDepth?Math.max(1,e.pixelDepth>>n):0,c=e.levels[n];let h,d;if(0===e.supercompressionScheme)h=c.levelData;else{if(2!==e.supercompressionScheme)throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");h=i.decode(c.levelData,c.uncompressedByteLength)}d=Za[t]===l.FloatType?new Float32Array(h.buffer,h.byteOffset,h.byteLength/Float32Array.BYTES_PER_ELEMENT):Za[t]===l.HalfFloatType||Za[t]===l.UnsignedShortType?new Uint16Array(h.buffer,h.byteOffset,h.byteLength/Uint16Array.BYTES_PER_ELEMENT):Za[t]===l.UnsignedInt5999Type||Za[t]===l.UnsignedInt101111Type?new Uint32Array(h.buffer,h.byteOffset,h.byteLength/Uint32Array.BYTES_PER_ELEMENT):h,r.push({data:d,width:a,height:s,depth:o})}const a=0===e.levelCount||r.length>1;let s;if(Xa.has(Ya[t]))s=0===e.pixelDepth?new l.DataTexture(r[0].data,e.pixelWidth,e.pixelHeight):new l.Data3DTexture(r[0].data,e.pixelWidth,e.pixelHeight,e.pixelDepth),s.minFilter=a?l.NearestMipmapNearestFilter:l.NearestFilter,s.magFilter=l.NearestFilter,s.generateMipmaps=0===e.levelCount,s.normalized=Qa.has(t);else{if(e.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");s=new l.CompressedTexture(r,e.pixelWidth,e.pixelHeight),s.minFilter=a?l.LinearMipmapLinearFilter:l.LinearFilter,s.magFilter=l.LinearFilter}return s.mipmaps=r,s.type=Za[t],s.format=Ya[t],s.colorSpace=$a(e),s.needsUpdate=!0,Promise.resolve(s)}(i);const a=t,s=this.init().then((()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:a},[e]))).then((e=>this._createTextureFrom(e.data,i)));return Wa.set(e,{promise:s}),s}dispose(){this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL)}}Ja.BasisFormat={ETC1S:0,UASTC:1,UASTC_HDR:2},Ja.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16,BC6H:22,RGB_HALF:24,RGBA_HALF:25},Ja.EngineFormat={RGBAFormat:l.RGBAFormat,RGBA_ASTC_4x4_Format:l.RGBA_ASTC_4x4_Format,RGB_BPTC_UNSIGNED_Format:l.RGB_BPTC_UNSIGNED_Format,RGBA_BPTC_Format:l.RGBA_BPTC_Format,RGBA_ETC2_EAC_Format:l.RGBA_ETC2_EAC_Format,RGBA_PVRTC_4BPPV1_Format:l.RGBA_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT5_Format:l.RGBA_S3TC_DXT5_Format,RGB_ETC1_Format:l.RGB_ETC1_Format,RGB_ETC2_Format:l.RGB_ETC2_Format,RGB_PVRTC_4BPPV1_Format:l.RGB_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT1_Format:l.RGBA_S3TC_DXT1_Format},Ja.EngineType={UnsignedByteType:l.UnsignedByteType,HalfFloatType:l.HalfFloatType,FloatType:l.FloatType},Ja.BasisWorker=function(){let e,t,i;const r=_EngineFormat,a=_EngineType,s=_TranscoderFormat,n=_BasisFormat;self.addEventListener("message",(function(r){const s=r.data;switch(s.type){case"init":e=s.config,o=s.transcoderBinary,t=new Promise((e=>{i={wasmBinary:o,onRuntimeInitialized:e},BASIS(i)})).then((()=>{i.initializeBasis(),i.KTX2File}));break;case"transcode":t.then((()=>{try{const{faces:t,buffers:r,width:o,height:d,hasAlpha:u,format:p,type:m,dfdFlags:f}=function(t){const r=new i.KTX2File(new Uint8Array(t));function s(){r.close(),r.delete()}if(!r.isValid())throw s(),new Error("THREE.KTX2Loader:\tInvalid or unsupported .ktx2 file");let o;if(r.isUASTC())o=n.UASTC;else if(r.isETC1S())o=n.ETC1S;else{if(!r.isHDR())throw new Error("THREE.KTX2Loader: Unknown Basis encoding");o=n.UASTC_HDR}const d=r.getWidth(),u=r.getHeight(),p=r.getLayers()||1,m=r.getLevels(),f=r.getFaces(),g=r.getHasAlpha(),b=r.getDFDFlags(),{transcoderFormat:y,engineFormat:v,engineType:x}=function(t,i,r,a){const s=l[t];for(let n=0;n<s.length;n++){const o=s[n];if(o.if&&!e[o.if])continue;if(!o.basisFormat.includes(t))continue;if(a&&o.transcoderFormat.length<2)continue;if(o.needsPowerOfTwo&&(!c(i)||!c(r)))continue;return{transcoderFormat:o.transcoderFormat[a?1:0],engineFormat:o.engineFormat[a?1:0],engineType:o.engineType[0]}}throw new Error("THREE.KTX2Loader: Failed to identify transcoding target.")}(o,d,u,g);if(!d||!u||!m)throw s(),new Error("THREE.KTX2Loader:\tInvalid texture");if(!r.startTranscoding())throw s(),new Error("THREE.KTX2Loader: .startTranscoding failed");const w=[],T=[];for(let e=0;e<f;e++){const t=[];for(let i=0;i<m;i++){const n=[];let o,l;for(let t=0;t<p;t++){const c=r.getImageLevelInfo(i,t,e);0===e&&0===i&&0===t&&(c.origWidth%4!=0||c.origHeight),m>1?(o=c.origWidth,l=c.origHeight):(o=c.width,l=c.height);let h=new Uint8Array(r.getImageTranscodedSizeInBytes(i,t,0,y));const d=r.transcodeImage(h,i,t,e,y,0,-1,-1);if(x===a.HalfFloatType&&(h=new Uint16Array(h.buffer,h.byteOffset,h.byteLength/Uint16Array.BYTES_PER_ELEMENT)),!d)throw s(),new Error("THREE.KTX2Loader: .transcodeImage failed.");n.push(h)}const c=h(n);t.push({data:c,width:o,height:l}),T.push(c.buffer)}w.push({mipmaps:t,width:d,height:u,format:v,type:x})}return s(),{faces:w,buffers:T,width:d,height:u,hasAlpha:g,dfdFlags:b,format:v,type:x}}(s.buffer);self.postMessage({type:"transcode",id:s.id,data:{faces:t,width:o,height:d,hasAlpha:u,format:p,type:m,dfdFlags:f}},r)}catch(t){self.postMessage({type:"error",id:s.id,error:t.message})}}))}var o}));const o=[{if:"astcSupported",basisFormat:[n.UASTC],transcoderFormat:[s.ASTC_4x4,s.ASTC_4x4],engineFormat:[r.RGBA_ASTC_4x4_Format,r.RGBA_ASTC_4x4_Format],engineType:[a.UnsignedByteType],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[n.ETC1S,n.UASTC],transcoderFormat:[s.BC7_M5,s.BC7_M5],engineFormat:[r.RGBA_BPTC_Format,r.RGBA_BPTC_Format],engineType:[a.UnsignedByteType],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[n.ETC1S,n.UASTC],transcoderFormat:[s.BC1,s.BC3],engineFormat:[r.RGBA_S3TC_DXT1_Format,r.RGBA_S3TC_DXT5_Format],engineType:[a.UnsignedByteType],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[n.ETC1S,n.UASTC],transcoderFormat:[s.ETC1,s.ETC2],engineFormat:[r.RGB_ETC2_Format,r.RGBA_ETC2_EAC_Format],engineType:[a.UnsignedByteType],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[n.ETC1S,n.UASTC],transcoderFormat:[s.ETC1],engineFormat:[r.RGB_ETC1_Format],engineType:[a.UnsignedByteType],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[n.ETC1S,n.UASTC],transcoderFormat:[s.PVRTC1_4_RGB,s.PVRTC1_4_RGBA],engineFormat:[r.RGB_PVRTC_4BPPV1_Format,r.RGBA_PVRTC_4BPPV1_Format],engineType:[a.UnsignedByteType],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0},{if:"bptcSupported",basisFormat:[n.UASTC_HDR],transcoderFormat:[s.BC6H],engineFormat:[r.RGB_BPTC_UNSIGNED_Format],engineType:[a.HalfFloatType],priorityHDR:1,needsPowerOfTwo:!1},{basisFormat:[n.ETC1S,n.UASTC],transcoderFormat:[s.RGBA32,s.RGBA32],engineFormat:[r.RGBAFormat,r.RGBAFormat],engineType:[a.UnsignedByteType,a.UnsignedByteType],priorityETC1S:100,priorityUASTC:100,needsPowerOfTwo:!1},{basisFormat:[n.UASTC_HDR],transcoderFormat:[s.RGBA_HALF],engineFormat:[r.RGBAFormat],engineType:[a.HalfFloatType],priorityHDR:100,needsPowerOfTwo:!1}],l={[n.ETC1S]:o.filter((e=>e.basisFormat.includes(n.ETC1S))).sort(((e,t)=>e.priorityETC1S-t.priorityETC1S)),[n.UASTC]:o.filter((e=>e.basisFormat.includes(n.UASTC))).sort(((e,t)=>e.priorityUASTC-t.priorityUASTC)),[n.UASTC_HDR]:o.filter((e=>e.basisFormat.includes(n.UASTC_HDR))).sort(((e,t)=>e.priorityHDR-t.priorityHDR))};function c(e){return e<=2||!(e&e-1)&&0!==e}function h(e){if(1===e.length)return e[0];let t=0;for(let a=0;a<e.length;a++){t+=e[a].byteLength}const i=new Uint8Array(t);let r=0;for(let a=0;a<e.length;a++){const t=e[a];i.set(t,r),r+=t.byteLength}return i}};const Xa=new Set([l.RGBAFormat,l.RGBFormat,l.RGFormat,l.RedFormat]),Qa=new Set([91]),Ya={[sa]:l.RGBAFormat,[aa]:l.RGFormat,[ra]:l.RedFormat,[ia]:l.RGBAFormat,[ea]:l.RGFormat,[$r]:l.RedFormat,[ta]:l.RGBAFormat,[Zr]:l.RGBAFormat,[Yr]:l.RGBAFormat,[Qr]:l.RGFormat,[Xr]:l.RGFormat,[Jr]:l.RedFormat,[Kr]:l.RedFormat,[oa]:l.RGBFormat,[na]:l.RGBFormat,[wa]:l.RGBA_ETC2_EAC_Format,[xa]:l.RGB_ETC2_Format,[Ta]:l.R11_EAC_Format,[_a]:l.SIGNED_R11_EAC_Format,[Aa]:l.RG11_EAC_Format,[Sa]:l.SIGNED_RG11_EAC_Format,[Da]:l.RGBA_ASTC_4x4_Format,[Ca]:l.RGBA_ASTC_4x4_Format,[Ma]:l.RGBA_ASTC_4x4_Format,[Ua]:l.RGBA_ASTC_6x6_Format,[Ra]:l.RGBA_ASTC_6x6_Format,[Ea]:l.RGBA_ASTC_6x6_Format,[da]:l.RGBA_S3TC_DXT1_Format,[ha]:l.RGBA_S3TC_DXT1_Format,[ca]:l.RGB_S3TC_DXT1_Format,[la]:l.RGB_S3TC_DXT1_Format,[pa]:l.RGBA_S3TC_DXT5_Format,[ua]:l.RGBA_S3TC_DXT5_Format,[fa]:l.SIGNED_RED_RGTC1_Format,[ma]:l.RED_RGTC1_Format,[ba]:l.SIGNED_RED_GREEN_RGTC2_Format,[ga]:l.RED_GREEN_RGTC2_Format,[va]:l.RGBA_BPTC_Format,[ya]:l.RGBA_BPTC_Format,[La]:l.RGBA_PVRTC_4BPPV1_Format,[Pa]:l.RGBA_PVRTC_4BPPV1_Format,[Fa]:l.RGBA_PVRTC_2BPPV1_Format,[ka]:l.RGBA_PVRTC_2BPPV1_Format},Za={[sa]:l.FloatType,[aa]:l.FloatType,[ra]:l.FloatType,[ia]:l.HalfFloatType,[ea]:l.HalfFloatType,[$r]:l.HalfFloatType,[ta]:l.UnsignedShortType,[Zr]:l.UnsignedByteType,[Yr]:l.UnsignedByteType,[Qr]:l.UnsignedByteType,[Xr]:l.UnsignedByteType,[Jr]:l.UnsignedByteType,[Kr]:l.UnsignedByteType,[oa]:l.UnsignedInt5999Type,[na]:l.UnsignedInt101111Type,[wa]:l.UnsignedByteType,[xa]:l.UnsignedByteType,[Ta]:l.UnsignedByteType,[_a]:l.UnsignedByteType,[Aa]:l.UnsignedByteType,[Sa]:l.UnsignedByteType,[Da]:l.HalfFloatType,[Ca]:l.UnsignedByteType,[Ma]:l.UnsignedByteType,[Ua]:l.HalfFloatType,[Ra]:l.UnsignedByteType,[Ea]:l.UnsignedByteType,[da]:l.UnsignedByteType,[ha]:l.UnsignedByteType,[ca]:l.UnsignedByteType,[la]:l.UnsignedByteType,[pa]:l.UnsignedByteType,[ua]:l.UnsignedByteType,[fa]:l.UnsignedByteType,[ma]:l.UnsignedByteType,[ba]:l.UnsignedByteType,[ga]:l.UnsignedByteType,[va]:l.UnsignedByteType,[ya]:l.UnsignedByteType,[La]:l.UnsignedByteType,[Pa]:l.UnsignedByteType,[Fa]:l.UnsignedByteType,[ka]:l.UnsignedByteType};function $a(e){const t=e.dataFormatDescriptor[0];return 1===t.colorPrimaries?2===t.transferFunction?l.SRGBColorSpace:l.LinearSRGBColorSpace:10===t.colorPrimaries?2===t.transferFunction?"display-p3":"display-p3-linear":(t.colorPrimaries,l.NoColorSpace)}function es(e,t,i,r){let a=!1,s=!1;const n=new Set,o=e.dispose.bind(e),l=t=>{n.delete(t),a&&!s&&0===n.size&&(s=!0,("transcoderPending"!==r||e[r])&&o())};for(const c of[t,i]){const t=e[c].bind(e);e[c]=(...e)=>{if(a)return Promise.reject(new DOMException("Tile decoders disposed","AbortError"));const i=Promise.resolve(t(...e));return n.add(i),i.then((()=>l(i)),(()=>l(i))),i}}return e.preload&&(e.preload=()=>(a||e[t]().catch((()=>{})),e)),e.dispose=()=>(a=!0,l(null),e),e}class ts{constructor(e){this.renderer=e,this.draco=null,this.ktx2=null,this.disposed=!1}getDraco(){if(this.disposed)throw new Error("Tile decoders disposed");if(!this.draco){const e=new Hr;e.decoderConfig.type="js",this.draco=es(e,"_initDecoder","decodeGeometry","decoderPending")}return this.draco}getKTX2(){if(this.disposed)throw new Error("Tile decoders disposed");return this.ktx2||(this.ktx2=es(new Ja,"init","_createTexture","transcoderPending"),this.ktx2.detectSupport(this.renderer)),this.ktx2}dispose(){var e,t;this.disposed||(this.disposed=!0,null==(e=this.draco)||e.dispose(),null==(t=this.ktx2)||t.dispose())}}function is(e,t,i){var r;e.setCamera(t);const a=(null==(r=i.xr)?void 0:r.isPresenting)?i.xr.getCamera().cameras[0]:null,s=null==a?void 0:a.viewport;s&&s.width>0&&s.height>0?e.setResolution(t,s.width,s.height):e.setResolutionFromRenderer(t,i)}const rs={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]};class as{constructor(){this.textureUtils=null,this.pluginCallbacks=[],this.register((function(e){return new Os(e)})),this.register((function(e){return new Bs(e)})),this.register((function(e){return new zs(e)})),this.register((function(e){return new Gs(e)})),this.register((function(e){return new Hs(e)})),this.register((function(e){return new qs(e)})),this.register((function(e){return new Vs(e)})),this.register((function(e){return new Ns(e)})),this.register((function(e){return new js(e)})),this.register((function(e){return new Ws(e)})),this.register((function(e){return new Ks(e)})),this.register((function(e){return new Js(e)})),this.register((function(e){return new Xs(e)})),this.register((function(e){return new Qs(e)}))}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}setTextureUtils(e){return this.textureUtils=e,this}parse(e,t,i,r){const a=new Is,s=[];for(let n=0,o=this.pluginCallbacks.length;n<o;n++)s.push(this.pluginCallbacks[n](a));a.setPlugins(s),a.setTextureUtils(this.textureUtils),a.writeAsync(e,t,r).catch(i)}parseAsync(e,t){const i=this;return new Promise((function(r,a){i.parse(e,r,a,t)}))}}const ss=0,ns=1,os=2,ls=3,cs=4,hs=5120,ds=5121,us=5122,ps=5123,ms=5124,fs=5125,gs=5126,bs=34962,ys=34963,vs=9728,xs=9729,ws=9984,Ts=9985,_s=9986,As=9987,Ss=33071,Ms=33648,Cs=10497,Es="KHR_mesh_quantization",Rs={};Rs[l.NearestFilter]=vs,Rs[l.NearestMipmapNearestFilter]=ws,Rs[l.NearestMipmapLinearFilter]=_s,Rs[l.LinearFilter]=xs,Rs[l.LinearMipmapNearestFilter]=Ts,Rs[l.LinearMipmapLinearFilter]=As,Rs[l.ClampToEdgeWrapping]=Ss,Rs[l.RepeatWrapping]=Cs,Rs[l.MirroredRepeatWrapping]=Ms;const ks={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},Ps=new l.Color;function Fs(e,t){return e.length===t.length&&e.every((function(e,i){return e===t[i]}))}function Ls(e){return 4*Math.ceil(e/4)}function Ds(e,t=0){const i=Ls(e.byteLength);if(i!==e.byteLength){const r=new Uint8Array(i);if(r.set(new Uint8Array(e)),0!==t)for(let a=e.byteLength;a<i;a++)r[a]=t;return r.buffer}return e}function Us(){return"undefined"==typeof document&&"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas")}class Is{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter r"+l.REVISION}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map,normalMaps:new Map},this.textureUtils=null}setPlugins(e){this.plugins=e}setTextureUtils(e){this.textureUtils=e}async writeAsync(e,t,i={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1,copyright:null},i),this.options.animations.length>0&&(this.options.trs=!0),await this.processInputAsync(e),await Promise.all(this.pending);const r=this,a=r.buffers,s=r.json;i=r.options;const n=r.extensionsUsed,o=r.extensionsRequired,l=new Blob(a,{type:"application/octet-stream"}),c=Object.keys(n),h=Object.keys(o);if(c.length>0&&(s.extensionsUsed=c),h.length>0&&(s.extensionsRequired=h),s.buffers&&s.buffers.length>0&&(s.buffers[0].byteLength=l.size),i.copyright&&(s.asset.copyright=i.copyright),!0===i.binary){const e=new FileReader;e.readAsArrayBuffer(l),e.onloadend=function(){const i=Ds(e.result),r=new DataView(new ArrayBuffer(8));r.setUint32(0,i.byteLength,!0),r.setUint32(4,5130562,!0);const a=Ds((n=JSON.stringify(s),(new TextEncoder).encode(n).buffer),32);var n;const o=new DataView(new ArrayBuffer(8));o.setUint32(0,a.byteLength,!0),o.setUint32(4,1313821514,!0);const l=new ArrayBuffer(12),c=new DataView(l);c.setUint32(0,1179937895,!0),c.setUint32(4,2,!0);const h=12+o.byteLength+a.byteLength+r.byteLength+i.byteLength;c.setUint32(8,h,!0);const d=new Blob([l,o,a,r,i],{type:"application/octet-stream"}),u=new FileReader;u.readAsArrayBuffer(d),u.onloadend=function(){t(u.result)}}}else if(s.buffers&&s.buffers.length>0){const e=new FileReader;e.readAsDataURL(l),e.onloadend=function(){const i=e.result;s.buffers[0].uri=i,t(s)}}else t(s)}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;const i=this.options,r=this.extensionsUsed;try{const a=JSON.parse(JSON.stringify(e.userData));if(i.includeCustomExtensions&&a.gltfExtensions){void 0===t.extensions&&(t.extensions={});for(const e in a.gltfExtensions)t.extensions[e]=a.gltfExtensions[e],r[e]=!0;delete a.gltfExtensions}Object.keys(a).length>0&&(t.extras=a)}catch(a){}}getUID(e,t=!1){if(!1===this.uids.has(e)){const t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const t=new l.Vector3;for(let i=0,r=e.count;i<r;i++)if(Math.abs(t.fromBufferAttribute(e,i).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);const i=e.clone(),r=new l.Vector3;for(let a=0,s=i.count;a<s;a++)r.fromBufferAttribute(i,a),0===r.x&&0===r.y&&0===r.z?r.setX(1):r.normalize(),i.setXYZ(a,r.x,r.y,r.z);return t.attributesNormalized.set(e,i),i}applyTextureTransform(e,t){let i=!1;const r={};0===t.offset.x&&0===t.offset.y||(r.offset=t.offset.toArray(),i=!0),0!==t.rotation&&(r.rotation=t.rotation,i=!0),1===t.repeat.x&&1===t.repeat.y||(r.scale=t.repeat.toArray(),i=!0),i&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=r,this.extensionsUsed.KHR_texture_transform=!0)}async buildMetalRoughTextureAsync(e,t){if(e===t)return e;function i(e){return e.colorSpace===l.SRGBColorSpace?function(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}:function(e){return e}}e instanceof l.CompressedTexture&&(e=await this.decompressTextureAsync(e)),t instanceof l.CompressedTexture&&(t=await this.decompressTextureAsync(t));const r=e?e.image:null,a=t?t.image:null,s=Math.max(r?r.width:0,a?a.width:0),n=Math.max(r?r.height:0,a?a.height:0),o=Us();o.width=s,o.height=n;const c=o.getContext("2d",{willReadFrequently:!0});c.fillStyle="#00ffff",c.fillRect(0,0,s,n);const h=c.getImageData(0,0,s,n);if(r){c.drawImage(r,0,0,s,n);const t=i(e),a=c.getImageData(0,0,s,n).data;for(let e=2;e<a.length;e+=4)h.data[e]=256*t(a[e]/256)}if(a){c.drawImage(a,0,0,s,n);const e=i(t),r=c.getImageData(0,0,s,n).data;for(let t=1;t<r.length;t+=4)h.data[t]=256*e(r[t]/256)}c.putImageData(h,0,0);const d=(e||t).clone();return d.source=new l.TextureSource(o),d.colorSpace=l.NoColorSpace,d.channel=(e||t).channel,e&&t&&(e.channel,t.channel),d}async buildNormalMapTextureAsync(e,t,i){e instanceof l.CompressedTexture&&(e=await this.decompressTextureAsync(e));const r=e.image,a=Us();a.width=r.width,a.height=r.height;const s=a.getContext("2d",{willReadFrequently:!0});s.drawImage(r,0,0,a.width,a.height);const n=s.getImageData(0,0,a.width,a.height),o=n.data;for(let l=0;l<o.length;l+=4)t&&(o[l+0]=255-o[l+0]),i&&(o[l+1]=255-o[l+1]);s.putImageData(n,0,0);const c=e.clone();return c.source=new l.TextureSource(a),c}async decompressTextureAsync(e,t=1/0){if(null===this.textureUtils)throw new Error("THREE.GLTFExporter: setTextureUtils() must be called to process compressed textures.");return await this.textureUtils.decompress(e,t)}processBuffer(e){const t=this.json,i=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),i.push(e),0}processBufferView(e,t,i,r,a){const s=this.json;let n;switch(s.bufferViews||(s.bufferViews=[]),t){case hs:case ds:n=1;break;case us:case ps:n=2;break;default:n=4}let o=e.itemSize*n;a===bs&&(o=4*Math.ceil(o/4));const c=Ls(r*o),h=new DataView(new ArrayBuffer(c));let d=0;for(let p=i;p<i+r;p++){for(let i=0;i<e.itemSize;i++){let r;e.itemSize>4?r=e.array[p*e.itemSize+i]:(0===i?r=e.getX(p):1===i?r=e.getY(p):2===i?r=e.getZ(p):3===i&&(r=e.getW(p)),!0===e.normalized&&(r=l.MathUtils.normalize(r,e.array))),t===gs?h.setFloat32(d,r,!0):t===ms?h.setInt32(d,r,!0):t===fs?h.setUint32(d,r,!0):t===us?h.setInt16(d,r,!0):t===ps?h.setUint16(d,r,!0):t===hs?h.setInt8(d,r):t===ds&&h.setUint8(d,r),d+=n}d%o!=0&&(d+=o-d%o)}const u={buffer:this.processBuffer(h.buffer),byteOffset:this.byteOffset,byteLength:c};void 0!==a&&(u.target=a),a===bs&&(u.byteStride=o),this.byteOffset+=c,s.bufferViews.push(u);return{id:s.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,i=t.json;return i.bufferViews||(i.bufferViews=[]),new Promise((function(r){const a=new FileReader;a.readAsArrayBuffer(e),a.onloadend=function(){const e=Ds(a.result),s={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,r(i.bufferViews.push(s)-1)}}))}processAccessor(e,t,i,r){const a=this.json;let s;if(e.array.constructor===Float32Array)s=gs;else if(e.array.constructor===Int32Array)s=ms;else if(e.array.constructor===Uint32Array)s=fs;else if(e.array.constructor===Int16Array)s=us;else if(e.array.constructor===Uint16Array)s=ps;else if(e.array.constructor===Int8Array)s=hs;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);s=ds}if(void 0===i&&(i=0),void 0!==r&&r!==1/0||(r=e.count),0===r)return null;const n=function(e,t,i){const r={min:new Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let a=t;a<t+i;a++)for(let t=0;t<e.itemSize;t++){let i;e.itemSize>4?i=e.array[a*e.itemSize+t]:(0===t?i=e.getX(a):1===t?i=e.getY(a):2===t?i=e.getZ(a):3===t&&(i=e.getW(a)),!0===e.normalized&&(i=l.MathUtils.normalize(i,e.array))),r.min[t]=Math.min(r.min[t],i),r.max[t]=Math.max(r.max[t],i)}return r}(e,i,r);let o;void 0!==t&&(o=e===t.index?ys:bs);const c=this.processBufferView(e,s,i,r,o),h={bufferView:c.id,byteOffset:c.byteOffset,componentType:s,count:r,max:n.max,min:n.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(h.normalized=!0),a.accessors||(a.accessors=[]),a.accessors.push(h)-1}processImage(e,t,i,r="image/png"){if(null!==e){const t=this,a=t.cache,s=t.json,n=t.options,o=t.pending;a.images.has(e)||a.images.set(e,{});const c=a.images.get(e),h=r+":flipY/"+i.toString();if(void 0!==c[h])return c[h];s.images||(s.images=[]);const d={mimeType:r},u=Us();u.width=Math.min(e.width,n.maxTextureSize),u.height=Math.min(e.height,n.maxTextureSize);const p=u.getContext("2d",{willReadFrequently:!0});if(!0===i&&(p.translate(0,u.height),p.scale(1,-1)),void 0!==e.data){l.RGBAFormat,e.width>n.maxTextureSize||(e.height,n.maxTextureSize);const t=new Uint8ClampedArray(e.height*e.width*4);for(let i=0;i<t.length;i+=4)t[i+0]=e.data[i+0],t[i+1]=e.data[i+1],t[i+2]=e.data[i+2],t[i+3]=e.data[i+3];p.putImageData(new ImageData(t,e.width,e.height),0,0)}else{if(!("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas))throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");p.drawImage(e,0,0,u.width,u.height)}!0===n.binary?o.push(function(e,t){if("undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas){let i;return"image/jpeg"===t?i=.92:"image/webp"===t&&(i=.8),e.convertToBlob({type:t,quality:i})}return new Promise((i=>e.toBlob(i,t)))}(u,r).then((e=>t.processBufferViewImage(e))).then((e=>{d.bufferView=e}))):d.uri=l.ImageUtils.getDataURL(u,r);const m=s.images.push(d)-1;return c[h]=m,m}throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){const t=this.json;t.samplers||(t.samplers=[]);const i={magFilter:Rs[e.magFilter],minFilter:Rs[e.minFilter],wrapS:Rs[e.wrapS],wrapT:Rs[e.wrapT]};return t.samplers.push(i)-1}async processTextureAsync(e){const t=this.options,i=this.cache,r=this.json;if(i.textures.has(e))return i.textures.get(e);r.textures||(r.textures=[]),e instanceof l.CompressedTexture&&(e=await this.decompressTextureAsync(e,t.maxTextureSize));const a=e.userData.mimeType,s=this.processImage(e.image,e.format,e.flipY,a),n={sampler:this.processSampler(e)};"image/webp"===a?(n.extensions=n.extensions||{},n.extensions.EXT_texture_webp={source:s},this.extensionsUsed.EXT_texture_webp=!0,this.extensionsRequired.EXT_texture_webp=!0):n.source=s,e.name&&(n.name=e.name),await this._invokeAllAsync((async function(t){t.writeTexture&&await t.writeTexture(e,n)}));const o=r.textures.push(n)-1;return i.textures.set(e,o),o}async processMaterialAsync(e,t){const i=this.cache,r=this.json,a=void 0!==t&&t.hasAttribute("tangent"),s=e.normalMap?e.uuid+":"+a:e.uuid;if(i.materials.has(s))return i.materials.get(s);if(e.isShaderMaterial)return null;r.materials||(r.materials=[]);const n={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&e.isMeshBasicMaterial;const o=e.color.toArray().concat([e.opacity]);if(Fs(o,[1,1,1,1])||(n.pbrMetallicRoughness.baseColorFactor=o),e.isMeshStandardMaterial?(n.pbrMetallicRoughness.metallicFactor=e.metalness,n.pbrMetallicRoughness.roughnessFactor=e.roughness):(n.pbrMetallicRoughness.metallicFactor=0,n.pbrMetallicRoughness.roughnessFactor=1),e.metalnessMap||e.roughnessMap){const t=await this.buildMetalRoughTextureAsync(e.metalnessMap,e.roughnessMap),i={index:await this.processTextureAsync(t),texCoord:t.channel};this.applyTextureTransform(i,t),n.pbrMetallicRoughness.metallicRoughnessTexture=i}if(e.map){const t={index:await this.processTextureAsync(e.map),texCoord:e.map.channel};this.applyTextureTransform(t,e.map),n.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){const t=e.emissive;if(Math.max(t.r,t.g,t.b)>0&&(n.emissiveFactor=e.emissive.toArray()),e.emissiveMap){const t={index:await this.processTextureAsync(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(t,e.emissiveMap),n.emissiveTexture=t}}if(e.normalMap){const t=e.normalScale,r=t.x<0,s=a?t.y<0:t.y>0;let o=e.normalMap;if(r||s){!1===i.normalMaps.has(e.normalMap)&&i.normalMaps.set(e.normalMap,{});const t=i.normalMaps.get(e.normalMap),a=`${r}:${s}`;void 0===t[a]&&(t[a]=await this.buildNormalMapTextureAsync(e.normalMap,r,s)),o=t[a]}const l={index:await this.processTextureAsync(o),texCoord:e.normalMap.channel};1!==Math.abs(t.x)&&(l.scale=Math.abs(t.x)),this.applyTextureTransform(l,e.normalMap),n.normalTexture=l}if(e.aoMap){const t={index:await this.processTextureAsync(e.aoMap),texCoord:e.aoMap.channel};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),n.occlusionTexture=t}e.transparent?n.alphaMode="BLEND":e.alphaTest>0&&(n.alphaMode="MASK",n.alphaCutoff=e.alphaTest),e.side===l.DoubleSide&&(n.doubleSided=!0),""!==e.name&&(n.name=e.name),this.serializeUserData(e,n),await this._invokeAllAsync((async function(t){t.writeMaterialAsync&&await t.writeMaterialAsync(e,n)}));const c=r.materials.push(n)-1;return i.materials.set(s,c),c}async processMeshAsync(e){const t=this.cache,i=this.json,r=[e.geometry.uuid];if(Array.isArray(e.material))for(let v=0,x=e.material.length;v<x;v++)r.push(e.material[v].uuid);else r.push(e.material.uuid);const a=r.join(":");if(t.meshes.has(a))return t.meshes.get(a);const s=e.geometry;let n;n=e.isLineSegments?ns:e.isLineLoop?os:e.isLine?ls:e.isPoints?ss:e.material.wireframe?ns:cs;const o={},l={},c=[],h=[],d={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},u=s.getAttribute("normal");void 0===u||this.isNormalizedNormalAttribute(u)||s.setAttribute("normal",this.createNormalizedNormalAttribute(u));let p=null;for(let v in s.attributes){if("morph"===v.slice(0,5))continue;const e=s.attributes[v];v=d[v]||v.toUpperCase();if(/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(v)||v.startsWith("_")||(v="_"+v),t.attributes.has(this.getUID(e))){l[v]=t.attributes.get(this.getUID(e));continue}p=null;const i=e.array;"JOINTS_0"!==v||i instanceof Uint16Array||i instanceof Uint8Array?(i instanceof Uint32Array||i instanceof Int32Array)&&!v.startsWith("_")&&(p=as.Utils.toTypedBufferAttribute(e,Float32Array)):p=as.Utils.toTypedBufferAttribute(e,Uint16Array);const r=this.processAccessor(p||e,s);null!==r&&(v.startsWith("_")||this.detectMeshQuantization(v,e),l[v]=r,t.attributes.set(this.getUID(e),r))}if(void 0!==u&&s.setAttribute("normal",u),0===Object.keys(l).length)return null;if(void 0!==e.morphTargetInfluences&&e.morphTargetInfluences.length>0){const i=[],r=[],a={};if(void 0!==e.morphTargetDictionary)for(const t in e.morphTargetDictionary)a[e.morphTargetDictionary[t]]=t;for(let n=0;n<e.morphTargetInfluences.length;++n){const o={};let l=!1;for(const e in s.morphAttributes){if("position"!==e&&"normal"!==e){l||(l=!0);continue}const i=s.morphAttributes[e][n],r=e.toUpperCase(),a=s.attributes[e];if(t.attributes.has(this.getUID(i,!0))){o[r]=t.attributes.get(this.getUID(i,!0));continue}const c=i.clone();if(!s.morphTargetsRelative)for(let e=0,t=i.count;e<t;e++)for(let r=0;r<i.itemSize;r++)0===r&&c.setX(e,i.getX(e)-a.getX(e)),1===r&&c.setY(e,i.getY(e)-a.getY(e)),2===r&&c.setZ(e,i.getZ(e)-a.getZ(e)),3===r&&c.setW(e,i.getW(e)-a.getW(e));o[r]=this.processAccessor(c,s),t.attributes.set(this.getUID(a,!0),o[r])}h.push(o),i.push(e.morphTargetInfluences[n]),void 0!==e.morphTargetDictionary&&r.push(a[n])}o.weights=i,r.length>0&&(o.extras={},o.extras.targetNames=r)}const m=Array.isArray(e.material);if(m&&0===s.groups.length)return null;let f=!1;if(m&&null===s.index){const e=[];for(let t=0,i=s.attributes.position.count;t<i;t++)e[t]=t;s.setIndex(e),f=!0}const g=m?e.material:[e.material],b=m?s.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let v=0,x=b.length;v<x;v++){const e={mode:n,attributes:l};if(this.serializeUserData(s,e),h.length>0&&(e.targets=h),null!==s.index){let i=this.getUID(s.index);void 0===b[v].start&&void 0===b[v].count||(i+=":"+b[v].start+":"+b[v].count),t.attributes.has(i)?e.indices=t.attributes.get(i):(e.indices=this.processAccessor(s.index,s,b[v].start,b[v].count),t.attributes.set(i,e.indices)),null===e.indices&&delete e.indices}const i=await this.processMaterialAsync(g[b[v].materialIndex],s);null!==i&&(e.material=i),c.push(e)}!0===f&&s.setIndex(null),o.primitives=c,i.meshes||(i.meshes=[]),await this._invokeAllAsync((function(t){t.writeMesh&&t.writeMesh(e,o)}));const y=i.meshes.push(o)-1;return t.meshes.set(a,y),y}detectMeshQuantization(e,t){if(this.extensionsUsed[Es])return;let i;switch(t.array.constructor){case Int8Array:i="byte";break;case Uint8Array:i="unsigned byte";break;case Int16Array:i="short";break;case Uint16Array:i="unsigned short";break;default:return}t.normalized&&(i+=" normalized");const r=e.split("_",1)[0];rs[r]&&rs[r].includes(i)&&(this.extensionsUsed[Es]=!0,this.extensionsRequired[Es]=!0)}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const i=e.isOrthographicCamera,r={type:i?"orthographic":"perspective"};return i?r.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:r.perspective={aspectRatio:e.aspect,yfov:l.MathUtils.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(r.name=e.type),t.cameras.push(r)-1}processAnimation(e,t){const i=this.json,r=this.nodeMap;i.animations||(i.animations=[]);const a=(e=as.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks,s=[],n=[];for(let c=0;c<a.length;++c){const e=a[c],i=l.PropertyBinding.parseTrackName(e.name);let o=l.PropertyBinding.findNode(t,i.nodeName);const h=ks[i.propertyName];if("bones"===i.objectName&&(o=!0===o.isSkinnedMesh?o.skeleton.getBoneByName(i.objectIndex):void 0),!o||!h)continue;const d=1;let u,p=e.values.length/e.times.length;h===ks.morphTargetInfluences&&(p/=o.morphTargetInfluences.length),!0===e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(u="CUBICSPLINE",p/=3):u=e.getInterpolation()===l.InterpolateDiscrete?"STEP":"LINEAR",n.push({input:this.processAccessor(new l.BufferAttribute(e.times,d)),output:this.processAccessor(new l.BufferAttribute(e.values,p)),interpolation:u}),s.push({sampler:n.length-1,target:{node:r.get(o),path:h}})}const o={name:e.name||"clip_"+i.animations.length,samplers:n,channels:s};return this.serializeUserData(e,o),i.animations.push(o),i.animations.length-1}processSkin(e){const t=this.json,i=this.nodeMap,r=t.nodes[i.get(e)],a=e.skeleton;if(void 0===a)return null;const s=e.skeleton.bones[0];if(void 0===s)return null;const n=[],o=new Float32Array(16*a.bones.length),c=new l.Matrix4;for(let l=0;l<a.bones.length;++l)n.push(i.get(a.bones[l])),c.copy(a.boneInverses[l]),c.multiply(e.bindMatrix).toArray(o,16*l);void 0===t.skins&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new l.BufferAttribute(o,16)),joints:n,skeleton:i.get(s)});return r.skin=t.skins.length-1}async processNodeAsync(e){const t=this.json,i=this.options,r=this.nodeMap;if(t.nodes||(t.nodes=[]),null!==e.pivot)return await this._processNodeWithPivotAsync(e);const a={};if(i.trs){const t=e.quaternion.toArray(),i=e.position.toArray(),r=e.scale.toArray();Fs(t,[0,0,0,1])||(a.rotation=t),Fs(i,[0,0,0])||(a.translation=i),Fs(r,[1,1,1])||(a.scale=r)}else e.matrixAutoUpdate&&e.updateMatrix(),!1===Fs(e.matrix.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])&&(a.matrix=e.matrix.elements);if(""!==e.name&&(a.name=String(e.name)),this.serializeUserData(e,a),e.isMesh||e.isLine||e.isPoints){const t=await this.processMeshAsync(e);null!==t&&(a.mesh=t)}else e.isCamera&&(a.camera=this.processCamera(e));e.isSkinnedMesh&&this.skins.push(e);const s=t.nodes.push(a)-1;if(r.set(e,s),e.children.length>0){const t=[];for(let r=0,a=e.children.length;r<a;r++){const a=e.children[r];if(a.visible||!1===i.onlyVisible){const e=await this.processNodeAsync(a);null!==e&&t.push(e)}}t.length>0&&(a.children=t)}return await this._invokeAllAsync((function(t){t.writeNode&&t.writeNode(e,a)})),s}async _processNodeWithPivotAsync(e){const t=this.json,i=this.options,r=this.nodeMap,a=e.pivot,s={},n=e.quaternion.toArray(),o=[e.position.x+a.x,e.position.y+a.y,e.position.z+a.z],l=e.scale.toArray();Fs(n,[0,0,0,1])||(s.rotation=n),Fs(o,[0,0,0])||(s.translation=o),Fs(l,[1,1,1])||(s.scale=l),s.extras={pivot:a.toArray()},""!==e.name&&(s.name=String(e.name)),this.serializeUserData(e,s);const c=t.nodes.push(s)-1;r.set(e,c);const h={},d=[-a.x,-a.y,-a.z];if(Fs(d,[0,0,0])||(h.translation=d),e.isMesh||e.isLine||e.isPoints){const t=await this.processMeshAsync(e);null!==t&&(h.mesh=t)}else e.isCamera&&(h.camera=this.processCamera(e));e.isSkinnedMesh&&this.skins.push(e);const u=[t.nodes.push(h)-1];if(e.children.length>0){const t=[];for(let r=0,a=e.children.length;r<a;r++){const a=e.children[r];if(a.visible||!1===i.onlyVisible){const e=await this.processNodeAsync(a);null!==e&&t.push(e)}}t.length>0&&(h.children=t)}return s.children=u,await this._invokeAllAsync((function(t){t.writeNode&&t.writeNode(e,s)})),c}async processSceneAsync(e){const t=this.json,i=this.options;t.scenes||(t.scenes=[],t.scene=0);const r={};""!==e.name&&(r.name=e.name),t.scenes.push(r);const a=[];for(let s=0,n=e.children.length;s<n;s++){const t=e.children[s];if(t.visible||!1===i.onlyVisible){const e=await this.processNodeAsync(t);null!==e&&a.push(e)}}a.length>0&&(r.nodes=a),this.serializeUserData(e,r)}async processObjectsAsync(e){const t=new l.Scene;t.name="AuxScene";for(let i=0;i<e.length;i++)t.children.push(e[i]);await this.processSceneAsync(t)}async processInputAsync(e){const t=this.options;e=e instanceof Array?e:[e],await this._invokeAllAsync((function(t){t.beforeParse&&t.beforeParse(e)}));const i=[];for(let r=0;r<e.length;r++)e[r]instanceof l.Scene?await this.processSceneAsync(e[r]):i.push(e[r]);i.length>0&&await this.processObjectsAsync(i);for(let r=0;r<this.skins.length;++r)this.processSkin(this.skins[r]);if(1===e.length)for(let r=0;r<t.animations.length;++r)this.processAnimation(t.animations[r],e[0]);else for(let r=0;r<e.length;r++){const i=t.animations[r]||[];for(let t=0;t<i.length;++t)this.processAnimation(i[t],e[r])}await this._invokeAllAsync((function(t){t.afterParse&&t.afterParse(e)}))}async _invokeAllAsync(e){for(let t=0,i=this.plugins.length;t<i;t++)await e(this.plugins[t])}}class Os{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight)return;const i=this.writer,r=i.json,a=i.extensionsUsed,s={};e.name&&(s.name=e.name),s.color=e.color.toArray(),s.intensity=e.intensity,e.isDirectionalLight?s.type="directional":e.isPointLight?(s.type="point",e.distance>0&&(s.range=e.distance)):e.isSpotLight&&(s.type="spot",e.distance>0&&(s.range=e.distance),s.spot={},s.spot.innerConeAngle=(1-e.penumbra)*e.angle,s.spot.outerConeAngle=e.angle),void 0!==e.decay&&e.decay,e.target&&(e.target.parent!==e||0!==e.target.position.x||0!==e.target.position.y||e.target.position.z),a[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},a[this.name]=!0);const n=r.extensions[this.name].lights;n.push(s),t.extensions=t.extensions||{},t.extensions[this.name]={light:n.length-1}}}class Bs{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}async writeMaterialAsync(e,t){if(!e.isMeshBasicMaterial)return;const i=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},i[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}class Vs{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0===e.clearcoat)return;const i=this.writer,r=i.extensionsUsed,a={};if(a.clearcoatFactor=e.clearcoat,e.clearcoatMap){const t={index:await i.processTextureAsync(e.clearcoatMap),texCoord:e.clearcoatMap.channel};i.applyTextureTransform(t,e.clearcoatMap),a.clearcoatTexture=t}if(a.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const t={index:await i.processTextureAsync(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};i.applyTextureTransform(t,e.clearcoatRoughnessMap),a.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){const t={index:await i.processTextureAsync(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};1!==e.clearcoatNormalScale.x&&(t.scale=e.clearcoatNormalScale.x),i.applyTextureTransform(t,e.clearcoatNormalMap),a.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=a,r[this.name]=!0}}class Ns{constructor(e){this.writer=e,this.name="KHR_materials_dispersion"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0===e.dispersion)return;const i=this.writer.extensionsUsed,r={};r.dispersion=e.dispersion,t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}}class js{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0===e.iridescence)return;const i=this.writer,r=i.extensionsUsed,a={};if(a.iridescenceFactor=e.iridescence,e.iridescenceMap){const t={index:await i.processTextureAsync(e.iridescenceMap),texCoord:e.iridescenceMap.channel};i.applyTextureTransform(t,e.iridescenceMap),a.iridescenceTexture=t}if(a.iridescenceIor=e.iridescenceIOR,a.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],a.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const t={index:await i.processTextureAsync(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};i.applyTextureTransform(t,e.iridescenceThicknessMap),a.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=a,r[this.name]=!0}}class zs{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;const i=this.writer,r=i.extensionsUsed,a={};if(a.transmissionFactor=e.transmission,e.transmissionMap){const t={index:await i.processTextureAsync(e.transmissionMap),texCoord:e.transmissionMap.channel};i.applyTextureTransform(t,e.transmissionMap),a.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=a,r[this.name]=!0}}class Gs{constructor(e){this.writer=e,this.name="KHR_materials_volume"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;const i=this.writer,r=i.extensionsUsed,a={};if(a.thicknessFactor=e.thickness,e.thicknessMap){const t={index:await i.processTextureAsync(e.thicknessMap),texCoord:e.thicknessMap.channel};i.applyTextureTransform(t,e.thicknessMap),a.thicknessTexture=t}e.attenuationDistance!==1/0&&(a.attenuationDistance=e.attenuationDistance),a.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=a,r[this.name]=!0}}class Hs{constructor(e){this.writer=e,this.name="KHR_materials_ior"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||1.5===e.ior)return;const i=this.writer.extensionsUsed,r={};r.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}}class qs{constructor(e){this.writer=e,this.name="KHR_materials_specular"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(Ps)&&!e.specularIntensityMap&&!e.specularColorMap)return;const i=this.writer,r=i.extensionsUsed,a={};if(e.specularIntensityMap){const t={index:await i.processTextureAsync(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};i.applyTextureTransform(t,e.specularIntensityMap),a.specularTexture=t}if(e.specularColorMap){const t={index:await i.processTextureAsync(e.specularColorMap),texCoord:e.specularColorMap.channel};i.applyTextureTransform(t,e.specularColorMap),a.specularColorTexture=t}a.specularFactor=e.specularIntensity,a.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=a,r[this.name]=!0}}class Ws{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0==e.sheen)return;const i=this.writer,r=i.extensionsUsed,a={};if(e.sheenRoughnessMap){const t={index:await i.processTextureAsync(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};i.applyTextureTransform(t,e.sheenRoughnessMap),a.sheenRoughnessTexture=t}if(e.sheenColorMap){const t={index:await i.processTextureAsync(e.sheenColorMap),texCoord:e.sheenColorMap.channel};i.applyTextureTransform(t,e.sheenColorMap),a.sheenColorTexture=t}a.sheenRoughnessFactor=e.sheenRoughness,a.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=a,r[this.name]=!0}}class Ks{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0==e.anisotropy)return;const i=this.writer,r=i.extensionsUsed,a={};if(e.anisotropyMap){const t={index:await i.processTextureAsync(e.anisotropyMap)};i.applyTextureTransform(t,e.anisotropyMap),a.anisotropyTexture=t}a.anisotropyStrength=e.anisotropy,a.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=a,r[this.name]=!0}}class Js{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}async writeMaterialAsync(e,t){if(!e.isMeshStandardMaterial||1===e.emissiveIntensity)return;const i=this.writer.extensionsUsed,r={};r.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}}class Xs{constructor(e){this.writer=e,this.name="EXT_materials_bump"}async writeMaterialAsync(e,t){if(!e.isMeshStandardMaterial||1===e.bumpScale&&!e.bumpMap)return;const i=this.writer,r=i.extensionsUsed,a={};if(e.bumpMap){const t={index:await i.processTextureAsync(e.bumpMap),texCoord:e.bumpMap.channel};i.applyTextureTransform(t,e.bumpMap),a.bumpTexture=t}a.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=a,r[this.name]=!0}}class Qs{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,t){if(!e.isInstancedMesh)return;const i=this.writer,r=e,a=new Float32Array(3*r.count),s=new Float32Array(4*r.count),n=new Float32Array(3*r.count),o=new l.Matrix4,c=new l.Vector3,h=new l.Quaternion,d=new l.Vector3;for(let l=0;l<r.count;l++)r.getMatrixAt(l,o),o.decompose(c,h,d),c.toArray(a,3*l),h.toArray(s,4*l),d.toArray(n,3*l);const u={TRANSLATION:i.processAccessor(new l.BufferAttribute(a,3)),ROTATION:i.processAccessor(new l.BufferAttribute(s,4)),SCALE:i.processAccessor(new l.BufferAttribute(n,3))};r.instanceColor&&(u._COLOR_0=i.processAccessor(r.instanceColor)),t.extensions=t.extensions||{},t.extensions[this.name]={attributes:u},i.extensionsUsed[this.name]=!0,i.extensionsRequired[this.name]=!0}}function Ys(e,t,i,r){const{lon:a,lat:s,alt:n}=l.ecefToGeodeticPosition(e,t,i),{east:o,north:c,up:h}=l.getEnuBasis(a,s),d=(new l.Matrix4).makeBasis((new l.Vector3).fromArray(o),(new l.Vector3).fromArray(c),(new l.Vector3).fromArray(h)),u=(new l.Quaternion).setFromRotationMatrix(d).clone().invert().multiply(r),p=(new l.Euler).setFromQuaternion(u,"ZYX");return{lon:a,lat:s,alt:n,pitch:l.MathUtils.radToDeg(p.x)-90,yaw:l.MathUtils.radToDeg(p.z),roll:l.MathUtils.radToDeg(p.y)}}function Zs(e,t){return(new l.Vector3).fromArray(l.getEnuBasis(e,t).up)}function $s(e,t,i,r,a){const s=l.getEnuBasis(e,t);i+=90;const n=(new l.Matrix4).makeBasis((new l.Vector3).fromArray(s.east),(new l.Vector3).fromArray(s.north),(new l.Vector3).fromArray(s.up)),o=new l.Euler(l.MathUtils.degToRad(i),l.MathUtils.degToRad(a),l.MathUtils.degToRad(r),"ZYX"),c=(new l.Quaternion).setFromEuler(o);return(new l.Quaternion).setFromRotationMatrix(n).multiply(c)}as.Utils={insertKeyframe:function(e,t){const i=.001,r=e.getValueSize(),a=new e.TimeBufferType(e.times.length+1),s=new e.ValueBufferType(e.values.length+r),n=e.createInterpolant(new e.ValueBufferType(r));let o;if(0===e.times.length){a[0]=t;for(let e=0;e<r;e++)s[e]=0;o=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<i)return 0;a[0]=t,a.set(e.times,1),s.set(n.evaluate(t),0),s.set(e.values,r),o=0}else if(t>e.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<i)return e.times.length-1;a[a.length-1]=t,a.set(e.times,0),s.set(e.values,0),s.set(n.evaluate(t),e.values.length),o=a.length-1}else for(let l=0;l<e.times.length;l++){if(Math.abs(e.times[l]-t)<i)return l;if(e.times[l]<t&&e.times[l+1]>t){a.set(e.times.slice(0,l+1),0),a[l+1]=t,a.set(e.times.slice(l+1),l+2),s.set(e.values.slice(0,(l+1)*r),0),s.set(n.evaluate(t),(l+1)*r),s.set(e.values.slice((l+1)*r),(l+2)*r),o=l+1;break}}return e.times=a,e.values=s,o},mergeMorphTargetTracks:function(e,t){const i=[],r={},a=e.tracks;for(let s=0;s<a.length;++s){let e=a[s];const n=l.PropertyBinding.parseTrackName(e.name),o=l.PropertyBinding.findNode(t,n.nodeName);if("morphTargetInfluences"!==n.propertyName||void 0===n.propertyIndex){i.push(e);continue}if(e.createInterpolant!==e.InterpolantFactoryMethodDiscrete&&e.createInterpolant!==e.InterpolantFactoryMethodLinear){if(e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");e=e.clone(),e.setInterpolation(l.InterpolateLinear)}const c=o.morphTargetInfluences.length,h=o.morphTargetDictionary[n.propertyIndex];if(void 0===h)throw new Error("THREE.GLTFExporter: Morph target name not found: "+n.propertyIndex);let d;if(void 0===r[o.uuid]){d=e.clone();const t=new d.ValueBufferType(c*d.times.length);for(let e=0;e<d.times.length;e++)t[e*c+h]=d.values[e];d.name=(n.nodeName||"")+".morphTargetInfluences",d.values=t,r[o.uuid]=d,i.push(d);continue}const u=e.createInterpolant(new e.ValueBufferType(1));d=r[o.uuid];for(let t=0;t<d.times.length;t++)d.values[t*c+h]=u.evaluate(d.times[t]);for(let t=0;t<e.times.length;t++){const i=this.insertKeyframe(d,e.times[t]);d.values[i*c+h]=e.values[t]}}return e.tracks=i,e},toTypedBufferAttribute:function(e,t){const i=new l.BufferAttribute(new t(e.count*e.itemSize),e.itemSize,!1);if(!e.normalized&&!e.isInterleavedBufferAttribute)return i.array.set(e.array),i;for(let r=0,a=e.count;r<a;r++)for(let t=0;t<e.itemSize;t++)i.setComponent(r,t,e.getComponent(r,t));return i}};var en=class{constructor(e={}){let{apiToken:t,autoRefreshToken:i=!1}=e;this.apiToken=t,this.autoRefreshToken=i,this.authURL=null,this._tokenRefreshPromise=null,this._bearerToken=null,this._bearerHostname=null}async fetch(e,t){await this._tokenRefreshPromise;let i={...t},r=null!==this._bearerHostname&&new URL(e).host===this._bearerHostname;r&&(i.headers={...i.headers,Authorization:this._bearerToken});let a=await fetch(e,i);return r&&a.status>=400&&a.status<=499&&this.autoRefreshToken?(await this.refreshToken(t),i.headers.Authorization=this._bearerToken,fetch(e,i)):a}refreshToken(e){if(null===this._tokenRefreshPromise){let t=new URL(this.authURL);t.searchParams.set("access_token",this.apiToken),this._tokenRefreshPromise=fetch(t,e).then((e=>{if(!e.ok)throw Error(`CesiumIonAuthPlugin: Failed to load data with error code ${e.status}`);return e.json()})).then((e=>(e.accessToken&&e.url&&(this._bearerToken=`Bearer ${e.accessToken}`,this._bearerHostname=new URL(e.url).host),this._tokenRefreshPromise=null,e)))}return this._tokenRefreshPromise}},tn="https://tile.googleapis.com/v1/createSession",rn=class{get isMapTilesSession(){return this.authURL===tn}constructor(e={}){let{apiToken:t,sessionOptions:i=null,autoRefreshToken:r=!1}=e;this.apiToken=t,this.autoRefreshToken=r,this.authURL=tn,this.sessionToken=null,this.sessionOptions=i,this._tokenRefreshPromise=null,this._authHostname=null}async fetch(e,t){null===this.sessionToken&&this.isMapTilesSession&&this.refreshToken(t),await this._tokenRefreshPromise,null===this._authHostname&&(this._authHostname=new URL(this.authURL).host);let i=new URL(e),r=i.host===this._authHostname;r&&(i.searchParams.set("key",this.apiToken),this.sessionToken&&i.searchParams.set("session",this.sessionToken));let a=await fetch(i,t);return r&&a.status>=400&&a.status<=499&&this.autoRefreshToken&&(await this.refreshToken(t),this.sessionToken&&i.searchParams.set("session",this.sessionToken),a=await fetch(i,t)),null!==this.sessionToken||this.isMapTilesSession?a:a.json().then((e=>(this.sessionToken=an(e),e)))}refreshToken(e){if(null===this._tokenRefreshPromise){let t=new URL(this.authURL);t.searchParams.set("key",this.apiToken);let i={...e};this.isMapTilesSession&&(i.method="POST",i.body=JSON.stringify(this.sessionOptions),i.headers=i.headers||{},i.headers={...i.headers,"Content-Type":"application/json"}),this._tokenRefreshPromise=fetch(t,i).then((e=>{if(!e.ok)throw Error(`GoogleCloudAuth: Failed to load data with error code ${e.status}`);return e.json()})).then((e=>(this.sessionToken=an(e),this._tokenRefreshPromise=null,e)))}return this._tokenRefreshPromise}};function an(e){if("session"in e)return e.session;{let t=null;return Le(e.root,(e=>{if(e.content&&e.content.uri){let[,i]=e.content.uri.split("?");return t=new URLSearchParams(i).get("session"),!0}return!1})),t}}var sn=class{constructor(){this.creditsCount={}}_adjustAttributions(e,t){let i=this.creditsCount,r=e.split(/;/g);for(let a=0,s=r.length;a<s;a++){let e=r[a];e in i||(i[e]=0),i[e]+=t?1:-1,i[e]<=0&&delete i[e]}}addAttributions(e){this._adjustAttributions(e,!0)}removeAttributions(e){this._adjustAttributions(e,!1)}toString(){return Object.entries(this.creditsCount).sort(((e,t)=>{let i=e[1];return t[1]-i})).map((e=>e[0])).join("; ")}},nn=class{constructor({apiToken:e,sessionOptions:t=null,autoRefreshToken:i=!1,logoUrl:r=null,useRecommendedSettings:a=!0}){this.name="GOOGLE_CLOUD_AUTH_PLUGIN",this.apiToken=e,this.useRecommendedSettings=a,this.logoUrl=r,this.auth=new rn({apiToken:e,autoRefreshToken:i,sessionOptions:t}),this.tiles=null,this._visibilityChangeCallback=null,this._attributionsManager=new sn,this._logoAttribution={value:"",type:"image",collapsible:!1},this._attribution={value:"",type:"string",collapsible:!0}}init(e){let{useRecommendedSettings:t,auth:i}=this;e.resetFailedTiles(),e.rootURL??(e.rootURL="https://tile.googleapis.com/v1/3dtiles/root.json"),i.sessionOptions||(i.authURL=e.rootURL),t&&!i.isMapTilesSession&&(e.errorTarget=20),this.tiles=e,this._visibilityChangeCallback=({tile:e,visible:t})=>{var i,r;let a=(null==(r=null==(i=e.engineData.metadata)?void 0:i.asset)?void 0:r.copyright)||"";t?this._attributionsManager.addAttributions(a):this._attributionsManager.removeAttributions(a)},e.addEventListener("tile-visibility-change",this._visibilityChangeCallback)}getAttributions(e){this.tiles.visibleTiles.size>0&&(this.logoUrl&&(this._logoAttribution.value=this.logoUrl,e.push(this._logoAttribution)),this._attribution.value=this._attributionsManager.toString(),e.push(this._attribution))}dispose(){this.tiles.removeEventListener("tile-visibility-change",this._visibilityChangeCallback)}async fetchData(e,t){return this.auth.fetch(e,t)}},on=class{get apiToken(){return this.auth.apiToken}set apiToken(e){this.auth.apiToken=e}get autoRefreshToken(){return this.auth.autoRefreshToken}set autoRefreshToken(e){this.auth.autoRefreshToken=e}constructor(e={}){let{apiToken:t,assetId:i=null,autoRefreshToken:r=!1,useRecommendedSettings:a=!0,assetTypeHandler:s=(e,t,i)=>{}}=e;this.name="CESIUM_ION_AUTH_PLUGIN",this.auth=new en({apiToken:t,autoRefreshToken:r}),this.assetId=i,this.autoRefreshToken=r,this.useRecommendedSettings=a,this.assetTypeHandler=s,this.tiles=null,this._tileSetVersion=-1,this._attributions=[]}init(e){null!==this.assetId&&(e.rootURL=`https://api.cesium.com/v1/assets/${this.assetId}/endpoint`),this.tiles=e,this.auth.authURL=e.rootURL,e.resetFailedTiles()}loadRootTileset(){return this.auth.refreshToken().then((e=>(this._initializeFromAsset(e),this.tiles.invokeOnePlugin((e=>e!==this&&e.loadRootTileset&&e.loadRootTileset()))))).catch((e=>{this.tiles.dispatchEvent({type:"load-error",tile:null,error:e,url:this.auth.authURL})}))}preprocessURL(e){return e=new URL(e),/^http/.test(e.protocol)&&-1!=this._tileSetVersion&&e.searchParams.set("v",this._tileSetVersion),e.toString()}fetchData(e,t){return null===this.tiles.getPluginByName("GOOGLE_CLOUD_AUTH_PLUGIN")?this.auth.fetch(e,t):null}getAttributions(e){this.tiles.visibleTiles.size>0&&e.push(...this._attributions)}_initializeFromAsset(e){let t=this.tiles;if("externalType"in e){let i=new URL(e.options.url);t.rootURL=e.options.url,t.registerPlugin(new nn({apiToken:i.searchParams.get("key"),autoRefreshToken:this.autoRefreshToken,useRecommendedSettings:this.useRecommendedSettings}))}else{"3DTILES"!==e.type&&this.assetTypeHandler(e.type,t,e),t.rootURL=e.url;let i=new URL(e.url);i.searchParams.has("v")&&-1===this._tileSetVersion&&(this._tileSetVersion=i.searchParams.get("v")),e.attributions&&(this._attributions=e.attributions.map((e=>({value:e.html,type:"html",collapsible:e.collapsible}))))}}};function ln(e){return"OCTREE"===e.implicitTilingData.root.implicitTiling.subdivisionScheme}function cn(e){return ln(e)?8:4}var hn=class{constructor(e,t){this.parent=e,this.children=[],this.geometricError=0,this.boundingVolume=null;let[i,r,a]=function(e,t){if(!e)return[0,0,0];let i=e.implicitTilingData.x,r=e.implicitTilingData.y,a=e.implicitTilingData.z;return[2*i+t%2,2*r+Math.floor(t/2)%2,ln(e)?2*a+Math.floor(t/4)%2:0]}(e,t);this.implicitTilingData={level:e.implicitTilingData.level+1,root:e.implicitTilingData.root,subtreeIdx:t,x:i,y:r,z:a}}static clone(e){return{parent:e.parent,children:[],geometricError:e.geometricError,boundingVolume:e.boundingVolume,implicitTilingData:{...e.implicitTilingData}}}},dn=class extends We{constructor(e){super(),this.tile=e,this.rootTile=e.implicitTilingData.root,this.workingPath=null}parseBuffer(e){let t=new DataView(e),i=0;ze(t);i+=4;let r=t.getUint32(i,!0);i+=4;let a=t.getUint32(i,!0);i+=8;let s=t.getUint32(i,!0);i+=8;let n=JSON.parse(He(new Uint8Array(e,i,a)));return i+=a,{version:r,subtreeJson:n,subtreeByte:e.slice(i,i+s)}}async parse(e){let t=this.parseBuffer(e),i=t.subtreeJson;i.contentAvailabilityHeaders=[].concat(i.contentAvailability);let r=this.preprocessBuffers(i.buffers),a=this.preprocessBufferViews(i.bufferViews,r);this.markActiveBufferViews(i,a);let s=await this.requestActiveBuffers(r,t.subtreeByte),n=this.parseActiveBufferViews(a,s);this.parseAvailability(t,i,n),this.expandSubtree(this.tile,t)}markActiveBufferViews(e,t){let i,r=e.tileAvailability;isNaN(r.bitstream)?isNaN(r.bufferView)||(i=t[r.bufferView]):i=t[r.bitstream],i&&(i.isActive=!0,i.bufferHeader.isActive=!0);let a=e.contentAvailabilityHeaders;for(let n=0;n<a.length;n++)i=void 0,isNaN(a[n].bitstream)?isNaN(a[n].bufferView)||(i=t[a[n].bufferView]):i=t[a[n].bitstream],i&&(i.isActive=!0,i.bufferHeader.isActive=!0);i=void 0;let s=e.childSubtreeAvailability;isNaN(s.bitstream)?isNaN(s.bufferView)||(i=t[s.bufferView]):i=t[s.bitstream],i&&(i.isActive=!0,i.bufferHeader.isActive=!0)}async requestActiveBuffers(e,t){let i=[];for(let s=0;s<e.length;s++){let r=e[s];if(r.isActive)if(r.isExternal){let e=this.parseImplicitURIBuffer(this.tile,this.rootTile.implicitTiling.subtrees.uri,r.uri),t=fetch(e,this.fetchOptions).then((e=>{if(!e.ok)throw Error(`SUBTREELoader: Failed to load external buffer from ${r.uri} with error code ${e.status}.`);return e.arrayBuffer()})).then((e=>new Uint8Array(e)));i.push(t)}else i.push(Promise.resolve(new Uint8Array(t)));else i.push(Promise.resolve())}let r=await Promise.all(i),a={};for(let s=0;s<r.length;s++){let e=r[s];e&&(a[s]=e)}return a}parseActiveBufferViews(e,t){let i={};for(let r=0;r<e.length;r++){let a=e[r];if(!a.isActive)continue;let s=a.byteOffset,n=s+a.byteLength;i[r]=t[a.buffer].slice(s,n)}return i}preprocessBuffers(e=[]){for(let t=0;t<e.length;t++){let i=e[t];i.isActive=!1,i.isExternal=!!i.uri}return e}preprocessBufferViews(e=[],t){for(let i=0;i<e.length;i++){let r=e[i];r.bufferHeader=t[r.buffer],r.isActive=!1,r.isExternal=r.bufferHeader.isExternal}return e}parseAvailability(e,t,i){let r=cn(this.rootTile),a=this.rootTile.implicitTiling.subtreeLevels,s=(r**+a-1)/(r-1),n=r**+a;e._tileAvailability=this.parseAvailabilityBitstream(t.tileAvailability,i,s),e._contentAvailabilityBitstreams=[];for(let o=0;o<t.contentAvailabilityHeaders.length;o++){let r=this.parseAvailabilityBitstream(t.contentAvailabilityHeaders[o],i,s);e._contentAvailabilityBitstreams.push(r)}e._childSubtreeAvailability=this.parseAvailabilityBitstream(t.childSubtreeAvailability,i,n)}parseAvailabilityBitstream(e,t,i){if(!isNaN(e.constant))return{constant:!!e.constant,lengthBits:i};let r;return isNaN(e.bitstream)?isNaN(e.bufferView)||(r=t[e.bufferView]):r=t[e.bitstream],{bitstream:r,lengthBits:i}}expandSubtree(e,t){let i=hn.clone(e);for(let s=0;t&&s<t._contentAvailabilityBitstreams.length;s++)if(t&&this.getBit(t._contentAvailabilityBitstreams[s],0)){i.content={uri:this.parseImplicitURI(e,this.rootTile.content.uri)};break}e.children.push(i);let r=this.transcodeSubtreeTiles(i,t),a=this.listChildSubtrees(t,r);for(let s=0;s<a.length;s++){let e=a[s],t=e.tile,i=this.deriveChildTile(null,t,null,e.childMortonIndex);i.content={uri:this.parseImplicitURI(i,this.rootTile.implicitTiling.subtrees.uri)},t.children.push(i)}}transcodeSubtreeTiles(e,t){let i=[e],r=[];for(let a=1;a<this.rootTile.implicitTiling.subtreeLevels;a++){let e=cn(this.rootTile),s=(e**+a-1)/(e-1),n=e*i.length;for(let a=0;a<n;a++){let n=s+a,o=i[a>>Math.log2(e)];if(!this.getBit(t._tileAvailability,n)){r.push(void 0);continue}let l=this.deriveChildTile(t,o,n,a);o.children.push(l),r.push(l)}i=r,r=[]}return i}deriveChildTile(e,t,i,r){let a=new hn(t,r);a.boundingVolume=this.getTileBoundingVolume(a),a.geometricError=this.getGeometricError(a);for(let s=0;e&&s<e._contentAvailabilityBitstreams.length;s++)if(e&&this.getBit(e._contentAvailabilityBitstreams[s],i)){a.content={uri:this.parseImplicitURI(a,this.rootTile.content.uri)};break}return a}getBit(e,t){if(t<0||t>=e.lengthBits)throw Error("Bit index out of bounds.");if(void 0!==e.constant)return e.constant;let i=t>>3,r=t%8;return 1==(new Uint8Array(e.bitstream)[i]>>r&1)}getTileBoundingVolume(e){let t={};if(this.rootTile.boundingVolume.region){let i=[...this.rootTile.boundingVolume.region],r=i[0],a=i[2],s=i[1],n=i[3],o=(a-r)/2**e.implicitTilingData.level,l=(n-s)/2**e.implicitTilingData.level;i[0]=r+o*e.implicitTilingData.x,i[2]=r+o*(e.implicitTilingData.x+1),i[1]=s+l*e.implicitTilingData.y,i[3]=s+l*(e.implicitTilingData.y+1);for(let e=0;e<4;e++){let t=i[e];t<-Math.PI?i[e]+=2*Math.PI:t>Math.PI&&(i[e]-=2*Math.PI)}if(ln(e)){let t=i[4],r=(i[5]-t)/2**e.implicitTilingData.level;i[4]=t+r*e.implicitTilingData.z,i[5]=t+r*(e.implicitTilingData.z+1)}t.region=i}if(this.rootTile.boundingVolume.box){let i=[...this.rootTile.boundingVolume.box],r=2**e.implicitTilingData.level-1,a=2**-e.implicitTilingData.level,s=ln(e)?3:2;for(let t=0;t<s;t++){i[3+3*t+0]*=a,i[3+3*t+1]*=a,i[3+3*t+2]*=a;let s=i[3+3*t+0],n=i[3+3*t+1],o=i[3+3*t+2],l=0===t?e.implicitTilingData.x:1===t?e.implicitTilingData.y:e.implicitTilingData.z;i[0]+=2*s*(-.5*r+l),i[1]+=2*n*(-.5*r+l),i[2]+=2*o*(-.5*r+l)}t.box=i}return t}getGeometricError(e){return this.rootTile.geometricError/2**e.implicitTilingData.level}listChildSubtrees(e,t){let i=[],r=cn(this.rootTile);for(let a=0;a<t.length;a++){let s=t[a];if(void 0!==s)for(let t=0;t<r;t++){let n=a*r+t;this.getBit(e._childSubtreeAvailability,n)&&i.push({tile:s,childMortonIndex:n})}}return i}parseImplicitURI(e,t){return t=(t=(t=(t=t.replace("{level}",e.implicitTilingData.level)).replace("{x}",e.implicitTilingData.x)).replace("{y}",e.implicitTilingData.y)).replace("{z}",e.implicitTilingData.z)}parseImplicitURIBuffer(e,t,i){let r=this.parseImplicitURI(e,t),a=new URL(r,this.workingPath+"/");return a.pathname=a.pathname.substring(0,a.pathname.lastIndexOf("/")),new URL(a.pathname+"/"+i,this.workingPath+"/").toString()}},un=class{constructor(){this.name="IMPLICIT_TILING_PLUGIN"}init(e){this.tiles=e}preprocessNode(e,t,i){var r;e.implicitTiling?(e.internal.hasUnrenderableContent=!0,e.internal.hasRenderableContent=!1,e.implicitTilingData={root:e,subtreeIdx:0,x:0,y:0,z:0,level:0}):/.subtree$/i.test(null==(r=e.content)?void 0:r.uri)&&(e.internal.hasUnrenderableContent=!0,e.internal.hasRenderableContent=!1)}parseTile(e,t,i){if(/^subtree$/i.test(i)){let i=new dn(t);return i.workingPath=t.internal.basePath,i.fetchOptions=this.tiles.fetchOptions,i.parse(e)}}preprocessURL(e,t){if(t&&t.implicitTiling){let e=t.implicitTiling.subtrees.uri.replace("{level}",t.implicitTilingData.level).replace("{x}",t.implicitTilingData.x).replace("{y}",t.implicitTilingData.y).replace("{z}",t.implicitTilingData.z);return new URL(e,t.internal.basePath+"/").toString()}return e}disposeTile(e){var t;/.subtree$/i.test(null==(t=e.content)?void 0:t.uri)&&(e.children.forEach((e=>{this.tiles.processNodeQueue.remove(e)})),e.children.length=0)}};function pn(e){return e>>1^-(1&e)}var mn=class extends We{constructor(...e){super(...e),this.fetchOptions.header={Accept:"application/vnd.quantized-mesh,application/octet-stream;q=0.9"}}loadAsync(...e){let{fetchOptions:t}=this;return t.header=t.header||{},t.header.Accept="application/vnd.quantized-mesh,application/octet-stream;q=0.9",t.header.Accept+=";extensions=octvertexnormals-watermask-metadata",super.loadAsync(...e)}parse(e){let t=0,i=new DataView(e),r=()=>{let e=i.getFloat64(t,!0);return t+=8,e},a=()=>{let e=i.getFloat32(t,!0);return t+=4,e},s=()=>{let e=i.getUint32(t,!0);return t+=4,e},n=()=>{let e=i.getUint8(t);return t+=1,e},o=(i,r)=>{let a=new r(e,t,i);return t+=i*r.BYTES_PER_ELEMENT,a},l={center:[r(),r(),r()],minHeight:a(),maxHeight:a(),sphereCenter:[r(),r(),r()],sphereRadius:r(),horizonOcclusionPoint:[r(),r(),r()]},c=s(),h=o(c,Uint16Array),d=o(c,Uint16Array),u=o(c,Uint16Array),p=new Float32Array(c),m=new Float32Array(c),f=new Float32Array(c),g=0,b=0,y=0,v=32767;for(let L=0;L<c;++L)g+=pn(h[L]),b+=pn(d[L]),y+=pn(u[L]),p[L]=g/v,m[L]=b/v,f[L]=y/v;let x=c>65536,w=x?Uint32Array:Uint16Array;t=x?4*Math.ceil(t/4):2*Math.ceil(t/2);let T=o(3*s(),w),_=0;for(var A=0;A<T.length;++A){let e=T[A];T[A]=_-e,0===e&&++_}let S=(e,t)=>m[t]-m[e],M=(e,t)=>p[e]-p[t],C=o(s(),w);C.sort(S);let E=o(s(),w);E.sort(M);let R=o(s(),w);R.sort(((e,t)=>-S(e,t)));let k=o(s(),w);k.sort(((e,t)=>-M(e,t)));let P={westIndices:C,southIndices:E,eastIndices:R,northIndices:k},F={};for(;t<i.byteLength;){let e=n(),t=s();if(1===e){let t=o(2*c,Uint8Array),i=new Float32Array(3*c);for(let e=0;e<c;e++){let r=t[2*e+0]/255*2-1,a=t[2*e+1]/255*2-1,s=1-(Math.abs(r)+Math.abs(a));if(s<0){let e=r;r=(1-Math.abs(a))*fn(e),a=(1-Math.abs(e))*fn(a)}let n=Math.sqrt(r*r+a*a+s*s);i[3*e+0]=r/n,i[3*e+1]=a/n,i[3*e+2]=s/n}F.octvertexnormals={extensionId:e,normals:i}}else if(2===e){let i=1===t?1:256;F.watermask={extensionId:e,mask:o(i*i,Uint8Array),size:i}}else if(4===e){let t=o(s(),Uint8Array),i=(new TextDecoder).decode(t);F.metadata={extensionId:e,json:JSON.parse(i)}}}return{header:l,indices:T,vertexData:{u:p,v:m,height:f},edgeIndices:P,extensions:F}}};function fn(e){return e<0?-1:1}const gn=new l.OrthographicCamera(-1,1,1,-1,0,1);class bn extends l.BufferGeometry{constructor(){super(),this.setAttribute("position",new l.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new l.Float32BufferAttribute([0,2,0,0,2,0],2))}}const yn=new bn;class vn{constructor(e){this._mesh=new l.Mesh(yn,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,gn)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}var xn=new l.Vector3,wn=new l.Vector3;var Tn=class{get isMercator(){return"EPSG:3857"===this.scheme}get isCartographic(){return"none"!==this.scheme}constructor(e="EPSG:4326"){this.scheme=e,this.tileCountX=1,this.tileCountY=1,this.setScheme(e)}setScheme(e){switch(this.scheme=e,e){case"CRS:84":case"EPSG:4326":this.tileCountX=2,this.tileCountY=1;break;case"EPSG:3857":case"none":this.tileCountX=1,this.tileCountY=1;break;default:throw Error(`ProjectionScheme: Unknown projection scheme "${e}"`)}}convertNormalizedToLatitude(e){if("none"===this.scheme)return e;if(this.isMercator){let t=l.MathUtils.mapLinear(e,0,1,-1,1);return 2*Math.atan(Math.exp(t*Math.PI))-Math.PI/2}return l.MathUtils.mapLinear(e,0,1,-Math.PI/2,Math.PI/2)}convertNormalizedToLongitude(e){return"none"===this.scheme?e:l.MathUtils.mapLinear(e,0,1,-Math.PI,Math.PI)}convertLatitudeToNormalized(e){return"none"===this.scheme?e:this.isMercator?.5+1*Math.log(Math.tan(Math.PI/4+e/2))/(2*Math.PI):l.MathUtils.mapLinear(e,-Math.PI/2,Math.PI/2,0,1)}convertLongitudeToNormalized(e){return"none"===this.scheme?e:(e+Math.PI)/(2*Math.PI)}getLongitudeDerivativeAtNormalized(e){return"none"===this.scheme?1:2*Math.PI}getLatitudeDerivativeAtNormalized(e){if("none"===this.scheme)return 1;{let t=1e-5,i=e-t;return i<0&&(i=e+t),this.isMercator?Math.abs(this.convertNormalizedToLatitude(e)-this.convertNormalizedToLatitude(i))/t:Math.PI}}getBounds(){return"none"===this.scheme?[0,0,1,1]:[this.convertNormalizedToLongitude(0),this.convertNormalizedToLatitude(0),this.convertNormalizedToLongitude(1),this.convertNormalizedToLatitude(1)]}toNormalizedPoint(e,t){let i=[e,t];return i[0]=this.convertLongitudeToNormalized(i[0]),i[1]=this.convertLatitudeToNormalized(i[1]),i}toNormalizedRange(e){return[...this.toNormalizedPoint(e[0],e[1]),...this.toNormalizedPoint(e[2],e[3])]}toCartographicPoint(e,t){let i=[e,t];return i[0]=this.convertNormalizedToLongitude(i[0]),i[1]=this.convertNormalizedToLatitude(i[1]),i}toCartographicRange(e){return[...this.toCartographicPoint(e[0],e[1]),...this.toCartographicPoint(e[2],e[3])]}clampToBounds(e,t=!1){let i,r=[...e];i=t?[0,0,1,1]:this.getBounds();let[a,s,n,o]=i;return r[0]=l.MathUtils.clamp(r[0],a,n),r[2]=l.MathUtils.clamp(r[2],a,n),r[1]=l.MathUtils.clamp(r[1],s,o),r[3]=l.MathUtils.clamp(r[3],s,o),r}};function _n(e,t){let[i,r,a,s]=e,[n,o,l,c]=t;return!(i>=l||a<=n||r>=c||s<=o)}var An=class{get levelCount(){return this._levels.length}get maxLevel(){return this.levelCount-1}get minLevel(){let e=this._levels;for(let t=0;t<e.length;t++)if(null!==e[t])return t;return-1}get contentBounds(){return this._contentBounds??this.projection.getBounds()}get aspectRatio(){let{pixelWidth:e,pixelHeight:t}=this.getLevel(this.maxLevel);return e/t}constructor(){this.flipY=!1,this.pixelOverlap=0,this._contentBounds=null,this.projection=new Tn("none"),this._levels=[]}setLevel(e,t={}){let i=this._levels;for(;i.length<e;)i.push(null);let{tileSplitX:r=2,tileSplitY:a=2}=t,{tilePixelWidth:s=256,tilePixelHeight:n=256,tileCountX:o=r**e,tileCountY:l=a**e,tileBounds:c=null}=t,{pixelWidth:h=s*o,pixelHeight:d=n*l}=t;i[e]={tilePixelWidth:s,tilePixelHeight:n,pixelWidth:h,pixelHeight:d,tileCountX:o,tileCountY:l,tileSplitX:r,tileSplitY:a,tileBounds:c}}generateLevels(e,t,i,r={}){let{minLevel:a=0,tilePixelWidth:s=256,tilePixelHeight:n=256}=r,o=e-1,{pixelWidth:l=s*t*2**o,pixelHeight:c=n*i*2**o}=r;for(let h=a;h<e;h++){let t=e-h-1,i=Math.ceil(l*2**-t),r=Math.ceil(c*2**-t),a=Math.ceil(i/s),o=Math.ceil(r/n);this.setLevel(h,{tilePixelWidth:s,tilePixelHeight:n,pixelWidth:i,pixelHeight:r,tileCountX:a,tileCountY:o})}}getLevel(e){return this._levels[e]}setContentBounds(e,t,i,r){this._contentBounds=[e,t,i,r]}setProjection(e){this.projection=e}getTileAtPoint(e,t,i,r=!1){let{flipY:a}=this,{tileCountY:s,tileBounds:n,pixelHeight:o,pixelWidth:c,tilePixelHeight:h,tilePixelWidth:d}=this.getLevel(i),u=d/c,p=h/o;if(r||([e,t]=this.toNormalizedPoint(e,t)),n){let i=this.toNormalizedRange(n);e=l.MathUtils.mapLinear(e,i[0],i[2],0,1),t=l.MathUtils.mapLinear(t,i[1],i[3],0,1)}let m=Math.floor(e/u),f=Math.floor(t/p);return a&&(f=s-1-f),[m,f]}getTilesInRange(e,t,i,r,a,s=!1){let n=[e,t,i,r],o=this.getContentBounds(s),c=this.getLevel(a).tileBounds;if(!_n(n,o)||c&&(s&&(c=this.toNormalizedRange(c)),!_n(n,o)))return[0,0,-1,-1];let[h,d,u,p]=this.clampToContentBounds(n,s),m=this.getTileAtPoint(h,d,a,s),f=this.getTileAtPoint(u,p,a,s);this.flipY&&([m[1],f[1]]=[f[1],m[1]]);let{tileCountX:g,tileCountY:b}=this.getLevel(a),[y,v]=m,[x,w]=f;return x<0||w<0||y>=g||v>=b?[0,0,-1,-1]:[l.MathUtils.clamp(y,0,g-1),l.MathUtils.clamp(v,0,b-1),l.MathUtils.clamp(x,0,g-1),l.MathUtils.clamp(w,0,b-1)]}getTileExists(e,t,i){let[r,a,s,n]=this.contentBounds,[o,l,c,h]=this.getTileBounds(e,t,i);return!(o>=c||l>=h)&&o<=s&&l<=n&&c>=r&&h>=a}getContentBounds(e=!1){let{projection:t}=this,i=[...this.contentBounds];return e&&(i[0]=t.convertLongitudeToNormalized(i[0]),i[1]=t.convertLatitudeToNormalized(i[1]),i[2]=t.convertLongitudeToNormalized(i[2]),i[3]=t.convertLatitudeToNormalized(i[3])),i}getTileContentUVBounds(e,t,i){let[r,a,s,n]=this.getTileBounds(e,t,i,!0,!0),[o,c,h,d]=this.getTileBounds(e,t,i,!0,!1);return[l.MathUtils.mapLinear(r,o,h,0,1),l.MathUtils.mapLinear(a,c,d,0,1),l.MathUtils.mapLinear(s,o,h,0,1),l.MathUtils.mapLinear(n,c,d,0,1)]}getTileBounds(e,t,i,r=!1,a=!0){let{flipY:s,pixelOverlap:n,projection:o}=this,{tilePixelWidth:c,tilePixelHeight:h,pixelWidth:d,pixelHeight:u,tileBounds:p}=this.getLevel(i),m=c*e-n,f=h*t-n,g=m+c+2*n,b=f+h+2*n;if(m=Math.max(m,0),f=Math.max(f,0),g=Math.min(g,d),b=Math.min(b,u),m/=d,g/=d,f/=u,b/=u,s){let e=(b-f)/2,t=1-(f+b)/2;f=t-e,b=t+e}let y=[m,f,g,b];if(p){let e=this.toNormalizedRange(p);y[0]=l.MathUtils.mapLinear(y[0],0,1,e[0],e[2]),y[2]=l.MathUtils.mapLinear(y[2],0,1,e[0],e[2]),y[1]=l.MathUtils.mapLinear(y[1],0,1,e[1],e[3]),y[3]=l.MathUtils.mapLinear(y[3],0,1,e[1],e[3])}return a&&(y=this.clampToBounds(y,!0)),r||(y[0]=o.convertNormalizedToLongitude(y[0]),y[1]=o.convertNormalizedToLatitude(y[1]),y[2]=o.convertNormalizedToLongitude(y[2]),y[3]=o.convertNormalizedToLatitude(y[3])),y}toNormalizedPoint(e,t){return this.projection.toNormalizedPoint(e,t)}toNormalizedRange(e){return this.projection.toNormalizedRange(e)}toCartographicPoint(e,t){return this.projection.toCartographicPoint(e,t)}toCartographicRange(e){return this.projection.toCartographicRange(e)}clampToContentBounds(e,t=!1){let i=[...e],[r,a,s,n]=this.getContentBounds(t);return i[0]=l.MathUtils.clamp(i[0],r,s),i[1]=l.MathUtils.clamp(i[1],a,n),i[2]=l.MathUtils.clamp(i[2],r,s),i[3]=l.MathUtils.clamp(i[3],a,n),i}clampToBounds(e,t=!1){return this.projection.clampToBounds(e,t)}},Sn=Symbol("TILE_X"),Mn=Symbol("TILE_Y"),Cn=Symbol("TILE_LEVEL"),En=Symbol("OVERLAY_RANGE"),Rn=Symbol("OVERLAY_LEVEL"),kn=new l.Vector3,Pn=new l.Vector3,Fn=new l.Sphere,Ln=class{constructor(e={}){let{overlay:t=null,shape:i="ellipsoid",endCaps:r=!0,center:a=!0,useRecommendedSettings:s=!0,applyOverlayTexture:n=!1}=e;this.priority=-10,this.tiles=null,this.overlay=t,this.shape=i,this.endCaps=r,this.center=a,this.useRecommendedSettings=s,this.applyOverlayTexture=n,this._tiling=null}init(e){this.useRecommendedSettings&&(e.errorTarget=1),this.tiles=e}async loadRootTileset(){let{overlay:e}=this;return e?(await e.init(),this._tiling=e.tiling||this._createDefaultTiling()):this._tiling=this._createDefaultTiling(),this.getTileset()}async parseToMesh(e,t,i,r,a){if("generated_surface"!==i)return null;let s;s=this._useEllipsoid()?this._createEllipsoidMesh(t):this._createPlanarMesh(t);let{overlay:n,applyOverlayTexture:o}=this;if(n&&o){let e=t[Sn],i=t[Mn],r=t[Cn],o=this._tiling.getTileBounds(e,i,r,!0,!1);if(n.hasContent(o,r)){try{await n.lockTexture(o,r)}catch(l){if("AbortError"!==l.name)throw l;return null}let e=n.getTexture(o,r);if(t[En]=o,t[Rn]=r,a.aborted)return n.releaseTexture(o,r),delete t[En],delete t[Rn],null;s.material.map=e,s.material.needsUpdate=!0}}return s}preprocessNode(e){let t=this._tiling.maxLevel;e[Cn]<t&&null!==e.parent&&this.expandChildren(e)}disposeTile(e){let t=e[En];this.overlay&&t&&(this.overlay.releaseTexture(t,e[Rn]),delete e[En],delete e[Rn])}dispose(){this.tiles.forEachLoadedModel(((e,t)=>{this.disposeTile(t)}))}getCartographicFromPosition(e,t={}){let{_tiling:i}=this,{projection:r}=i;if(!r.isCartographic)throw Error("GeneratedSurfacePlugin: getCartographicFromPosition requires a cartographic projection.");if(this._useEllipsoid())return this.tiles.ellipsoid.getPositionToCartographic(e,t);let{center:a}=this,s=e.x/i.aspectRatio+(a?.5:0),n=e.y+(a?.5:0);return t.lat=r.convertNormalizedToLatitude(n),t.lon=r.convertNormalizedToLongitude(s),t}getPositionFromCartographic(e,t,i=new l.Vector3){let{_tiling:r}=this,{projection:a}=r;if(!a.isCartographic)throw Error("GeneratedSurfacePlugin: getPositionFromCartographic requires a cartographic projection.");if(this._useEllipsoid())return this.tiles.ellipsoid.getCartographicToPosition(e,t,0,i);let{center:s}=this,n=a.convertLongitudeToNormalized(t),o=a.convertLatitudeToNormalized(e);return i.x=(n-(s?.5:0))*r.aspectRatio,i.y=o-(s?.5:0),i.z=0,i}_useEllipsoid(){return this._tiling.projection.isCartographic&&"ellipsoid"===this.shape}_createPlanarMesh(e){let t=e[Sn],i=e[Mn],r=e[Cn],a=e.boundingVolume.box,s=1,n=1,o=0,c=0,h=0;a&&([o,c,h]=a,s=a[3],n=a[7]);let d=new l.PlaneGeometry(2*s,2*n),u=new l.Mesh(d,new l.MeshBasicMaterial);u.position.set(o,c,h);let p=this._tiling.getTileContentUVBounds(t,i,r),{uv:m}=d.attributes;for(let f=0;f<m.count;f++)m.setXY(f,l.MathUtils.mapLinear(m.getX(f),0,1,p[0],p[2]),l.MathUtils.mapLinear(m.getY(f),0,1,p[1],p[3]));return u}_createEllipsoidMesh(e){let{tiles:t,endCaps:i,_tiling:r}=this,{projection:a}=r,s=e[Cn],n=e[Sn],o=e[Mn],[c,h,d,u]=e.boundingVolume.region,p=Math.max(15,Math.ceil((u-h)*l.MathUtils.RAD2DEG*.25)),m=Math.max(30,Math.ceil((d-c)*l.MathUtils.RAD2DEG*.25)),f=m+3,g=p+3,b=new l.PlaneGeometry(1,1,m+2,p+2),[y,v,x,w]=r.getTileBounds(n,o,s,!0,!0),T=r.getTileContentUVBounds(n,o,s),{position:_,normal:A,uv:S}=b.attributes,M=_.count;e.engineData.boundingVolume.getSphere(Fn);for(let E=0;E<M;E++){let r=E%f,s=Math.floor(E/f),n=0===r||r===f-1||0===s||s===g-1,o=(Math.max(1,Math.min(f-2,r))-1)/m,c=1-(Math.max(1,Math.min(g-2,s))-1)/p,d=a.convertNormalizedToLongitude(l.MathUtils.mapLinear(o,0,1,y,x)),b=a.convertNormalizedToLatitude(l.MathUtils.mapLinear(c,0,1,v,w));if(a.isMercator&&i&&(1===w&&1===c&&(b=Math.PI/2),0===v&&0===c&&(b=-Math.PI/2)),a.isMercator&&0!==c&&1!==c){let e=a.convertNormalizedToLatitude(1),t=1/p,i=l.MathUtils.mapLinear(c-t,0,1,h,u),r=l.MathUtils.mapLinear(c+t,0,1,h,u);b>e&&i<e&&(b=e),b<-e&&r>-e&&(b=-e)}t.ellipsoid.getCartographicToPosition(b,d,0,kn).sub(Fn.center),t.ellipsoid.getCartographicToNormal(b,d,Pn),n&&kn.addScaledVector(Pn,-e.geometricError);let M=l.MathUtils.mapLinear(a.convertLongitudeToNormalized(d),y,x,T[0],T[2]),C=l.MathUtils.mapLinear(a.convertLatitudeToNormalized(b),v,w,T[1],T[3]);_.setXYZ(E,kn.x,kn.y,kn.z),A.setXYZ(E,Pn.x,Pn.y,Pn.z),S.setXY(E,M,C)}let C=new l.Mesh(b,new l.MeshBasicMaterial);return C.position.copy(Fn.center),C}getTileset(){let{tiles:e,_tiling:t}=this,i=t.minLevel,{tileCountX:r,tileCountY:a}=t.getLevel(i),s=[];for(let o=0;o<r;o++)for(let e=0;e<a;e++){let t=this.createChild(o,e,i);null!==t&&s.push(t)}let n={asset:{version:"1.1"},geometricError:1/0,root:{refine:"REPLACE",geometricError:1/0,boundingVolume:this.createBoundingVolume(0,0,-1),children:s,[Cn]:-1,[Sn]:0,[Mn]:0}};return e.preprocessTileset(n,""),n}getUrl(){return"tile.generated_surface"}fetchData(e){if(/generated_surface/.test(e))return new ArrayBuffer}createBoundingVolume(e,t,i,r=0){let{_tiling:a}=this,s=-1===i;if(this._useEllipsoid()){let n,o,{endCaps:l}=this;return s?(n=a.getContentBounds(!0),o=a.getContentBounds()):(n=a.getTileBounds(e,t,i,!0,!0),o=a.getTileBounds(e,t,i,!1,!0)),l&&(1===n[3]&&(o[3]=Math.PI/2),0===n[1]&&(o[1]=-Math.PI/2)),{region:[...o,-r,1]}}{let r,{center:n}=this;r=s?a.getContentBounds(!0):a.getTileBounds(e,t,i,!0);let[o,l,c,h]=r,d=(c-o)/2,u=(h-l)/2,p=o+d,m=l+u;return n&&(p-=.5,m-=.5),p*=a.aspectRatio,d*=a.aspectRatio,{box:[p,m,0,d,0,0,0,u,0,0,0,0]}}}createChild(e,t,i){let{_tiling:r}=this,{projection:a}=r;if(!r.getTileExists(e,t,i))return null;let s,n=this._useEllipsoid();if(n){let[n,o,l,c]=r.getTileBounds(e,t,i,!0),{tilePixelWidth:h,tilePixelHeight:d}=r.getLevel(i),u=(l-n)/h,p=(c-o)/d,[,m,f,g]=r.getTileBounds(e,t,i),b=m>0==g>0?Math.min(Math.abs(m),Math.abs(g)):0,y=a.convertLatitudeToNormalized(b),v=a.getLongitudeDerivativeAtNormalized(n),x=a.getLatitudeDerivativeAtNormalized(y),[w,T]=function(e,t,i){let r=1e-5,a=i+r,s=t+r;Math.abs(s)>Math.PI/2&&(s-=r),e.getCartographicToPosition(t,i,0,xn),e.getCartographicToPosition(s,i,0,wn);let n=xn.distanceTo(wn)/r;return e.getCartographicToPosition(t,a,0,wn),[xn.distanceTo(wn)/r,n]}(this.tiles.ellipsoid,b,f);s=Math.max(u*v*w,p*x*T)}else{let{pixelWidth:e,pixelHeight:t}=r.getLevel(i);s=Math.max(r.aspectRatio/e,1/t)}return{refine:"REPLACE",geometricError:s,boundingVolume:this.createBoundingVolume(e,t,i,n?s:0),content:{uri:this.getUrl(e,t,i)},children:[],[Sn]:e,[Mn]:t,[Cn]:i}}expandChildren(e){let t=e[Cn],i=e[Sn],r=e[Mn],{tileSplitX:a,tileSplitY:s}=this._tiling.getLevel(t);for(let n=0;n<a;n++)for(let o=0;o<s;o++){let l=this.createChild(a*i+n,s*r+o,t+1);l&&e.children.push(l)}}_createDefaultTiling(){let e=new An;if("ellipsoid"===this.shape){let t=new Tn("EPSG:3857");e.setProjection(t),e.generateLevels(20,t.tileCountX,t.tileCountY)}else{let t=new Tn("none");e.setProjection(t),e.generateLevels(20,1,1)}return e}},Dn=class extends DOMException{constructor(){super("DataCache: Item removed","AbortError")}};function Un(...e){return e.join("_")}var In=class{constructor(){this.cache={},this.count=0,this.cachedBytes=0,this.active=0}fetchItem(e,t){}disposeItem(e,t){}getMemoryUsage(e){return 0}setData(...e){let{cache:t}=this,i=e.pop(),r=Un(...e);if(r in t)throw Error(`DataCache: "${r}" is already present.`);return this.cache[r]={abortController:new AbortController,result:i,count:1,bytes:this.getMemoryUsage(i)},this.count++,this.cachedBytes+=this.cache[r].bytes,i}lock(...e){let{cache:t}=this,i=Un(...e);if(i in t)t[i].count++;else{let t=new AbortController,r={abortController:t,result:null,count:1,bytes:0,args:e};this.active++,r.result=this.fetchItem(e,t.signal),r.result instanceof Promise?r.result=r.result.then((e=>(t.signal.throwIfAborted(),r.result=e,r.bytes=this.getMemoryUsage(e),this.cachedBytes+=r.bytes,e))).finally((()=>{this.active--})):(this.active--,r.bytes=this.getMemoryUsage(r.result),this.cachedBytes+=r.bytes),this.cache[i]=r,this.count++}return t[i].result}release(...e){let t=Un(...e);this.releaseViaFullKey(t)}get(...e){let{cache:t}=this,i=Un(...e);return i in t&&t[i].count>0?t[i].result:null}has(...e){let{cache:t}=this;return Un(...e)in t}forEachItem(e){let{cache:t}=this;for(let i in t){let r=t[i];r.result instanceof Promise||e(r.result,r.args)}}dispose(){let{cache:e}=this;for(let t in e){let{abortController:i}=e[t];i.abort(new Dn),this.releaseViaFullKey(t,!0)}this.cache={}}releaseViaFullKey(e,t=!1){let{cache:i}=this;if(e in i&&i[e].count>0){let r=i[e];if(r.count--,0===r.count||t){let a=()=>{if(i[e]!==r)return;let{result:t,abortController:a}=r;a.abort(new Dn),t instanceof Promise?t.then((e=>{this.disposeItem(e,r.args)})).catch((()=>{this.disposeItem(null,r.args)})).finally((()=>{this.count--,this.cachedBytes-=r.bytes})):(this.disposeItem(t,r.args),this.count--,this.cachedBytes-=r.bytes),delete i[e]};t?a():queueMicrotask((()=>{0===r.count&&a()}))}return!0}throw Error("DataCache: Attempting to release key that does not exist")}},On=class extends In{constructor(e={}){super();let{fetchOptions:t={}}=e;this.tiling=new An,this.fetchOptions=t,this.fetchData=(...e)=>fetch(...e)}init(){}async processBufferToTexture(e){let t=new Blob([e]),i=new l.Texture(await createImageBitmap(t,{premultiplyAlpha:"none",colorSpaceConversion:"none",imageOrientation:"flipY"}));return i.generateMipmaps=!1,i.colorSpace=l.SRGBColorSpace,i.needsUpdate=!0,i}getMemoryUsage(e){let{format:t,type:i,image:r,generateMipmaps:a}=e,{width:s,height:n}=r,o=l.TextureUtils.getByteLength(s,n,t,i);return a?4*o/3:o}fetchItem(e,t){let i={...this.fetchOptions,signal:t},r=this.getUrl(...e);return this.fetchData(r,i).then((e=>e.arrayBuffer())).then((e=>this.processBufferToTexture(e)))}disposeItem(e){e&&(e.dispose(),e.image instanceof ImageBitmap&&e.image.close())}getUrl(...e){}},Bn=class extends On{constructor(e={}){let{url:t=null,...i}=e;super(i),this.tileSets=null,this.extension=null,this.url=t}getUrl(e,t,i){let{url:r,extension:a,tileSets:s,tiling:n}=this;return new URL(`${parseInt(s[i-n.minLevel].href)}/${e}/${t}.${a}`,r).toString()}init(){let{url:e}=this;return this.fetchData(new URL("tilemapresource.xml",e),this.fetchOptions).then((e=>e.text())).then((t=>{let{tiling:i}=this,r=(new DOMParser).parseFromString(t,"text/xml"),a=r.querySelector("BoundingBox"),s=r.querySelector("TileFormat"),n=[...r.querySelector("TileSets").querySelectorAll("TileSet")].map((e=>({href:parseInt(e.getAttribute("href")),unitsPerPixel:parseFloat(e.getAttribute("units-per-pixel")),order:parseInt(e.getAttribute("order"))}))).sort(((e,t)=>e.order-t.order)),o=parseFloat(a.getAttribute("minx"))*l.MathUtils.DEG2RAD,c=parseFloat(a.getAttribute("maxx"))*l.MathUtils.DEG2RAD,h=parseFloat(a.getAttribute("miny"))*l.MathUtils.DEG2RAD,d=parseFloat(a.getAttribute("maxy"))*l.MathUtils.DEG2RAD,u=parseInt(s.getAttribute("width")),p=parseInt(s.getAttribute("height")),m=s.getAttribute("extension"),f=r.querySelector("SRS").textContent;this.extension=m,this.url=e,this.tileSets=n,i.setProjection(new Tn(f)),i.setContentBounds(o,h,c,d),n.forEach((({order:e})=>{i.setLevel(e,{tileCountX:i.projection.tileCountX*2**e,tilePixelWidth:u,tilePixelHeight:p})}))}))}};function Vn(e,t,i,r){let[a,s,n,o]=e;s+=1e-8,a+=1e-8,o-=1e-8,n-=1e-8;let l=Math.max(Math.min(t,i.maxLevel),i.minLevel),[c,h,d,u]=i.getTilesInRange(a,s,n,o,l,!0);for(let p=c;p<=d;p++)for(let e=h;e<=u;e++)r(p,e,l)}var Nn=["a","b","c"],jn=new l.Vector4,zn=new l.Vector4,Gn=new l.Vector4,Hn=new l.Vector4,qn=class{constructor(){this.attributeList=null,this.splitOperations=[],this.trianglePool=new Wn}forEachSplitPermutation(e){let{splitOperations:t}=this,i=(r=0)=>{r>=t.length?e():(t[r].keepPositive=!0,i(r+1),t[r].keepPositive=!1,i(r+1))};i()}addSplitOperation(e,t=!0){this.splitOperations.push({callback:e,keepPositive:t})}clearSplitOperations(){this.splitOperations.length=0}clipObject(e){let t=e.clone(),i=[];return t.traverse((e=>{e.isMesh&&(e.geometry=this.clip(e).geometry,0==(e.geometry.index?e.geometry.index.count/3:e.attributes.position.count/3)&&i.push(e))})),i.forEach((e=>{e.removeFromParent()})),t}clip(e,t=null){let i=this.getClippedData(e,t);return this.constructMesh(i.attributes,i.index,e)}getClippedData(e,t=null,i={}){let{trianglePool:r,splitOperations:a,attributeList:s}=this,n=e.geometry,o=n.attributes.position,l=n.index,c=0,h={};i.index=i.index||[],i.vertexIsClipped=i.vertexIsClipped||[],i.attributes=i.attributes||{};for(let m in n.attributes)null!==s&&(s instanceof Function&&!s(m)||Array.isArray(s)&&!s.includes(m))||(i.attributes[m]=[]);let d=0,u=l?l.count:o.count;null!==t&&(d=t.start,u=t.count);for(let m=d,f=d+u;m<f;m+=3){let t=m+0,i=m+1,s=m+2;l&&(t=l.getX(t),i=l.getX(i),s=l.getX(s));let o=r.get();o.initFromIndices(t,i,s);let c=[o];for(let r=0;r<a.length;r++){let{keepPositive:t,callback:i}=a[r],s=[];for(let r=0;r<c.length;r++){let a=c[r],{indices:o,barycoord:l}=a;a.clipValues.a=i(n,o.a,o.b,o.c,l.a,e.matrixWorld),a.clipValues.b=i(n,o.a,o.b,o.c,l.b,e.matrixWorld),a.clipValues.c=i(n,o.a,o.b,o.c,l.c,e.matrixWorld),this.splitTriangle(a,!t,s)}c=s}for(let e=0,r=c.length;e<r;e++){p(c[e],n)}r.reset()}return i;function p(e,t){for(let r=0;r<3;r++){let a=e.getVertexHash(r,t);a in h||(h[a]=c,c++,e.getVertexData(r,t,i.attributes),i.vertexIsClipped.push(0===e.clipValues[Nn[r]]));let s=h[a];i.index.push(s)}}}constructMesh(e,t,i){let r=i.geometry,a=new l.BufferGeometry,s=e.position.length/3>65535?new Uint32Array(t):new Uint16Array(t);a.setIndex(new l.BufferAttribute(s,1,!1));for(let o in e){let t=r.getAttribute(o),i=new l.BufferAttribute(new t.array.constructor(e[o]),t.itemSize,t.normalized);i.gpuType=t.gpuType,a.setAttribute(o,i)}let n=new l.Mesh(a,i.material.clone());return n.position.copy(i.position),n.quaternion.copy(i.quaternion),n.scale.copy(i.scale),n}splitTriangle(e,t,i){let{trianglePool:r}=this,a=[],s=[],n=[];for(let o=0;o<3;o++){let t=Nn[o],i=Nn[(o+1)%3],r=e.clipValues[t],c=e.clipValues[i];(r<0!=c<0||0===r)&&(a.push(o),s.push([t,i]),r===c?n.push(0):n.push(l.MathUtils.mapLinear(0,r,c,0,1)))}if(2!==a.length)Math.min(e.clipValues.a,e.clipValues.b,e.clipValues.c)<0===t&&i.push(e);else if(2===a.length){let o,l,c=r.get().initFromTriangle(e),h=r.get().initFromTriangle(e),d=r.get().initFromTriangle(e);(a[0]+1)%3===a[1]?(c.lerpVertexFromEdge(e,s[0][0],s[0][1],n[0],"a"),c.copyVertex(e,s[0][1],"b"),c.lerpVertexFromEdge(e,s[1][0],s[1][1],n[1],"c"),c.clipValues.a=0,c.clipValues.c=0,h.lerpVertexFromEdge(e,s[0][0],s[0][1],n[0],"a"),h.copyVertex(e,s[1][1],"b"),h.copyVertex(e,s[0][0],"c"),h.clipValues.a=0,d.lerpVertexFromEdge(e,s[0][0],s[0][1],n[0],"a"),d.lerpVertexFromEdge(e,s[1][0],s[1][1],n[1],"b"),d.copyVertex(e,s[1][1],"c"),d.clipValues.a=0,d.clipValues.b=0):(c.lerpVertexFromEdge(e,s[0][0],s[0][1],n[0],"a"),c.lerpVertexFromEdge(e,s[1][0],s[1][1],n[1],"b"),c.copyVertex(e,s[0][0],"c"),c.clipValues.a=0,c.clipValues.b=0,h.lerpVertexFromEdge(e,s[0][0],s[0][1],n[0],"a"),h.copyVertex(e,s[0][1],"b"),h.lerpVertexFromEdge(e,s[1][0],s[1][1],n[1],"c"),h.clipValues.a=0,h.clipValues.c=0,d.copyVertex(e,s[0][1],"a"),d.copyVertex(e,s[1][0],"b"),d.lerpVertexFromEdge(e,s[1][0],s[1][1],n[1],"c"),d.clipValues.c=0),o=Math.min(c.clipValues.a,c.clipValues.b,c.clipValues.c),l=o<0,l===t&&i.push(c),o=Math.min(h.clipValues.a,h.clipValues.b,h.clipValues.c),l=o<0,l===t&&i.push(h),o=Math.min(d.clipValues.a,d.clipValues.b,d.clipValues.c),l=o<0,l===t&&i.push(d)}}},Wn=class{constructor(){this.pool=[],this.index=0}get(){if(this.index>=this.pool.length){let e=new Kn;this.pool.push(e)}let e=this.pool[this.index];return this.index++,e}reset(){this.index=0}},Kn=class{constructor(){this.indices={a:-1,b:-1,c:-1},this.clipValues={a:-1,b:-1,c:-1},this.barycoord=new l.Triangle}getVertexHash(e,t){let{barycoord:i,indices:r}=this,a=i[Nn[e]];if(1===a.x)return r[Nn[0]];if(1===a.y)return r[Nn[1]];if(1===a.z)return r[Nn[2]];{let{attributes:e}=t,i="";for(let t in e){let s=e[t];switch(Jn(s,r.a,r.b,r.c,a,jn),("normal"===t||"tangent"===t||"bitangent"===t)&&jn.normalize(),s.itemSize){case 4:i+=Xn(jn.x,jn.y,jn.z,jn.w);break;case 3:i+=Xn(jn.x,jn.y,jn.z);break;case 2:i+=Xn(jn.x,jn.y);break;case 1:i+=Xn(jn.x)}i+="|"}return i}}getVertexData(e,t,i){let{barycoord:r,indices:a}=this,s=r[Nn[e]],{attributes:n}=t;for(let o in n){if(!i[o])continue;let e=n[o],t=i[o];switch(Jn(e,a.a,a.b,a.c,s,jn),("normal"===o||"tangent"===o||"bitangent"===o)&&jn.normalize(),e.itemSize){case 4:t.push(jn.x,jn.y,jn.z,jn.w);break;case 3:t.push(jn.x,jn.y,jn.z);break;case 2:t.push(jn.x,jn.y);break;case 1:t.push(jn.x)}}}initFromTriangle(e){return this.initFromIndices(e.indices.a,e.indices.b,e.indices.c)}initFromIndices(e,t,i){return this.indices.a=e,this.indices.b=t,this.indices.c=i,this.clipValues.a=-1,this.clipValues.b=-1,this.clipValues.c=-1,this.barycoord.a.set(1,0,0),this.barycoord.b.set(0,1,0),this.barycoord.c.set(0,0,1),this}lerpVertexFromEdge(e,t,i,r,a){this.clipValues[a]=l.MathUtils.lerp(e.clipValues[t],e.clipValues[i],r),this.barycoord[a].lerpVectors(e.barycoord[t],e.barycoord[i],r)}copyVertex(e,t,i){this.clipValues[i]=e.clipValues[t],this.barycoord[i].copy(e.barycoord[t])}};function Jn(e,t,i,r,a,s){switch(zn.fromBufferAttribute(e,t),Gn.fromBufferAttribute(e,i),Hn.fromBufferAttribute(e,r),s.set(0,0,0,0).addScaledVector(zn,a.x).addScaledVector(Gn,a.y).addScaledVector(Hn,a.z),e.itemSize){case 3:jn.w=0;break;case 2:jn.w=0,jn.z=0;break;case 1:jn.w=0,jn.z=0,jn.y=0}return s}function Xn(...e){let t="";for(let i=0,r=e.length;i<r;i++)t+=~~(1e5*e[i]+.5),i!==r-1&&(t+="_");return t}var Qn=class{constructor(){this.canvas=null,this.context=null,this.range=[0,0,1,1]}setTarget(e,t){this.canvas=e.image,this.context=e.image.getContext("2d"),this.range=[...t]}draw(e,t){let{canvas:i,range:r,context:a}=this,{width:s,height:n}=i,{image:o}=e,c=Math.round(l.MathUtils.mapLinear(t[0],r[0],r[2],0,s)),h=Math.round(l.MathUtils.mapLinear(t[1],r[1],r[3],0,n)),d=Math.round(l.MathUtils.mapLinear(t[2],r[0],r[2],0,s))-c,u=Math.round(l.MathUtils.mapLinear(t[3],r[1],r[3],0,n))-h;o instanceof ImageBitmap?(a.save(),a.translate(c,n-h),a.scale(1,-1),a.drawImage(o,0,0,d,u),a.restore()):a.drawImage(o,c,n-h,d,-u)}clear(){let{context:e,canvas:t}=this;e.clearRect(0,0,t.width,t.height)}};var Yn=class extends In{hasContent(...e){return!0}},Zn=class extends Yn{constructor(e){super(),this.tiledImageSource=e,this.tileComposer=new Qn,this.resolution=256}hasContent(e,t,i,r,a){let s=this.tiledImageSource.tiling,n=0;return Vn([e,t,i,r],a,s,(()=>{n++})),0!==n}async fetchItem([e,t,i,r,a],s){let{tiledImageSource:n,tileComposer:o}=this,c=[e,t,i,r],h=n.tiling;await this._markImages(c,a,!1),null==s||s.throwIfAborted();let d=null;if(Vn(c,a,h,((e,t,i)=>{(function(e,t,i=0){if(e.length!==t.length)return!1;for(let r=0,a=e.length;r<a;r++)if(Math.abs(e[r]-t[r])>i)return!1;return!0})(h.getTileBounds(e,t,i,!0,!1),c,1e-10)&&(d=[e,t,i])})),null!==d){let[e,t,i]=d;return n.get(e,t,i).clone()}let u=document.createElement("canvas");u.width=this.resolution,u.height=this.resolution;let p=new l.CanvasTexture(u);return p.colorSpace=l.SRGBColorSpace,p.generateMipmaps=!1,o.setTarget(p,c),o.clear(16777215,0),Vn(c,a,h,((e,t,i)=>{let r=h.getTileBounds(e,t,i,!0,!1),a=n.get(e,t,i);o.draw(a,r)})),p}disposeItem(e,[t,i,r,a,s]){e&&e.dispose(),this._markImages([t,i,r,a],s,!0)}dispose(){super.dispose(),this.tiledImageSource.dispose()}_markImages(e,t,i=!1){let r=this.tiledImageSource,a=r.tiling,s=[];Vn(e,t,a,((e,t,a)=>{i?r.release(e,t,a):s.push(r.lock(e,t,a))}));let n=s.filter((e=>e instanceof Promise));return 0===n.length?null:Promise.all(n)}},$n=new me;$n.maxJobs=10,$n.priorityCallback=(e,t)=>{let i=e.tile,r=t.tile,a=i.internal.renderer,s=r.internal.renderer,n=a.visibleTiles.has(i);return n===s.visibleTiles.has(r)?Ie(i,r):n?1:-1};var eo=class{get isPlanarProjection(){return!!this.frame}get downloadQueue(){return this._downloadQueue}set downloadQueue(e){e instanceof me||(this._downloadQueue=e)}constructor(e={}){let{opacity:t=1,color:i=16777215,frame:r=null,preprocessURL:a=null,alphaMask:s=!1,alphaInvert:n=!1}=e;this.preprocessURL=a,this.opacity=t,this.color=new l.Color(i),this.frame=null===r?null:r.clone(),this.alphaMask=s,this.alphaInvert=n,this.downloadQueue=Be,this._whenReady=null,this.isReady=!1,this.isInitialized=!1,this._visibleRegionCounts=new Map}init(){return this.isInitialized||(this.isInitialized=!0,this._whenReady=this._init().then((()=>this.isReady=!0))),this._whenReady}whenReady(){return this._whenReady}_init(){return Promise.resolve()}fetch(e,t={}){this.preprocessURL&&(e=this.preprocessURL(e));let i={priority:-performance.now()};return this.downloadQueue.add(e,i,(()=>fetch(e,t)),t.signal)}getAttributions(e){}hasContent(e,t=null){return!1}async getTexture(e,t=null){return null}async lockTexture(e,t=null){return null}lockTextureSafe(e){let t=this.lockTexture(e);return t instanceof Promise&&t.catch((e=>{if("AbortError"!==e.name)throw e})),t}releaseTexture(e,t=null){}shouldSplit(e,t=null){return!1}setResolution(e){}setRegionVisible(e,t){let{_visibleRegionCounts:i}=this,r=e.join("_"),a=i.get(r);if(a||(a={range:[...e],count:0},i.set(r,a)),a.count+=t?1:-1,a.count<0)throw Error();0===a.count&&i.delete(r)}},to=class extends eo{get tiling(){return this.imageSource.tiling}get projection(){return this.tiling.projection}get aspectRatio(){return this.tiling&&this.isReady?this.tiling.aspectRatio:1}get fetchOptions(){return this.imageSource.fetchOptions}set fetchOptions(e){this.imageSource.fetchOptions=e}constructor(e={}){let{imageSource:t=null,...i}=e;super(i),this.imageSource=t,this.regionImageSource=null}_init(){return this._initImageSource().then((()=>{this.imageSource.fetchData=(...e)=>this.fetch(...e),this.regionImageSource=new Zn(this.imageSource)}))}_initImageSource(){return this.imageSource.init()}calculateLevel(e,t=null){let[i,r,a,s]=e,n=a-i,o=s-r;null===t&&(t=this.regionImageSource.resolution);let l=0,c=this.tiling.maxLevel;for(;l<c;l++){let e=t/n,i=t/o,r=this.tiling.getLevel(l);if(null==r)continue;let{pixelWidth:a,pixelHeight:s}=r;if(a>=e||s>=i)break}return l}hasContent(e,t=this.calculateLevel(e)){return this.regionImageSource.hasContent(...e,t)}getTexture(e,t=this.calculateLevel(e)){return this.regionImageSource.get(...e,t)}lockTexture(e,t=this.calculateLevel(e)){return this.regionImageSource.lock(...e,t)}releaseTexture(e,t=this.calculateLevel(e)){this.regionImageSource.release(...e,t)}shouldSplit(e,t=this.calculateLevel(e)){return this.tiling.maxLevel>t}setResolution(e){this.regionImageSource.resolution=e}},io=class extends to{constructor(e={}){super(e),this.imageSource=new Bn(e)}},ro=new l.Vector3,ao=new l.Triangle,so=new l.Vector3,no=new l.Vector3,oo=class extends mn{constructor(e=l.DefaultLoadingManager){super(),this.manager=e,this.ellipsoid=new wi,this.skirtLength=1e3,this.smoothSkirtNormals=!0,this.generateNormals=!0,this.solid=!1,this.minLat=-Math.PI/2,this.maxLat=Math.PI/2,this.minLon=-Math.PI,this.maxLon=Math.PI}parse(e){let{ellipsoid:t,solid:i,skirtLength:r,smoothSkirtNormals:a,generateNormals:s,minLat:n,maxLat:o,minLon:c,maxLon:h}=this,{header:d,indices:u,vertexData:p,edgeIndices:m,extensions:f}=super.parse(e),g=new l.BufferGeometry,b=new l.MeshStandardMaterial,y=new l.Mesh(g,b);y.position.set(...d.center);let v="octvertexnormals"in f,x=v||s,w=p.u.length,T=[],_=[],A=[],S=[],M=0,C=0;for(let l=0;l<w;l++)R(l,so),k(so.x,so.y,so.z,no),_.push(so.x,so.y),T.push(...no);for(let l=0,F=u.length;l<F;l++)A.push(u[l]);if(x)if(v){let e=f.octvertexnormals.normals;for(let t=0,i=e.length;t<i;t++)S.push(e[t])}else{let e=new l.BufferGeometry,t=u.length>21845?new Uint32Array(u):new Uint16Array(u);e.setIndex(new l.BufferAttribute(t,1,!1)),e.setAttribute("position",new l.BufferAttribute(new Float32Array(T),3,!1)),e.computeVertexNormals();let i=e.getAttribute("normal").array;f.octvertexnormals={normals:i};for(let r=0,a=i.length;r<a;r++)S.push(i[r])}if(g.addGroup(M,u.length,C),M+=u.length,C++,i){let e=T.length/3;for(let t=0;t<w;t++)R(t,so),k(so.x,so.y,so.z,no,-r),_.push(so.x,so.y),T.push(...no);for(let t=u.length-1;t>=0;t--)A.push(u[t]+e);if(x){let e=f.octvertexnormals.normals;for(let t=0,i=e.length;t<i;t++)S.push(-e[t])}g.addGroup(M,u.length,C),M+=u.length,C++}if(r>0){let e,{westIndices:t,eastIndices:i,southIndices:r,northIndices:a}=m,s=P(t);e=T.length/3,_.push(...s.uv),T.push(...s.positions);for(let c=0,h=s.indices.length;c<h;c++)A.push(s.indices[c]+e);let n=P(i);e=T.length/3,_.push(...n.uv),T.push(...n.positions);for(let c=0,h=n.indices.length;c<h;c++)A.push(n.indices[c]+e);let o=P(r);e=T.length/3,_.push(...o.uv),T.push(...o.positions);for(let c=0,h=o.indices.length;c<h;c++)A.push(o.indices[c]+e);let l=P(a);e=T.length/3,_.push(...l.uv),T.push(...l.positions);for(let c=0,h=l.indices.length;c<h;c++)A.push(l.indices[c]+e);x&&(S.push(...s.normals),S.push(...n.normals),S.push(...o.normals),S.push(...l.normals)),g.addGroup(M,u.length,C),M+=u.length,C++}for(let l=0,F=T.length;l<F;l+=3)T[l+0]-=d.center[0],T[l+1]-=d.center[1],T[l+2]-=d.center[2];let E=T.length/3>65535?new Uint32Array(A):new Uint16Array(A);if(g.setIndex(new l.BufferAttribute(E,1,!1)),g.setAttribute("position",new l.BufferAttribute(new Float32Array(T),3,!1)),g.setAttribute("uv",new l.BufferAttribute(new Float32Array(_),2,!1)),x&&g.setAttribute("normal",new l.BufferAttribute(new Float32Array(S),3,!1)),"watermask"in f){let{mask:e,size:t}=f.watermask,i=new Uint8Array(2*t*t);for(let a=0,s=e.length;a<s;a++){let t=255===e[a]?0:255;i[2*a+0]=t,i[2*a+1]=t}let r=new l.DataTexture(i,t,t,l.RGFormat,l.UnsignedByteType);r.flipY=!0,r.minFilter=l.LinearMipMapLinearFilter,r.magFilter=l.LinearFilter,r.needsUpdate=!0,b.roughnessMap=r}return y.userData.minHeight=d.minHeight,y.userData.maxHeight=d.maxHeight,"metadata"in f&&(y.userData.metadata=f.metadata.json),y;function R(e,t){return t.x=p.u[e],t.y=p.v[e],t.z=p.height[e],t}function k(e,i,r,a,s=0){let u=l.MathUtils.lerp(d.minHeight,d.maxHeight,r),p=l.MathUtils.lerp(c,h,e),m=l.MathUtils.lerp(n,o,i);return t.getCartographicToPosition(m,p,u+s,a),a}function P(e){let t=[],i=[],s=[],n=[],o=[];for(let a=0,h=e.length;a<h;a++)R(e[a],so),t.push(so.x,so.y),s.push(so.x,so.y),k(so.x,so.y,so.z,no),i.push(...no),k(so.x,so.y,so.z,no,-r),n.push(...no);let l=e.length-1;for(let r=0;r<l;r++){let t=r,i=r+1,a=r+e.length,s=r+e.length+1;o.push(t,a,i),o.push(i,a,s)}let c=null;if(x){let t=(i.length+n.length)/3;if(a){c=Array(3*t);let i=f.octvertexnormals.normals,r=c.length/2;for(let a=0,s=t/2;a<s;a++){let t=e[a],s=3*a,n=i[3*t+0],o=i[3*t+1],l=i[3*t+2];c[s+0]=n,c[s+1]=o,c[s+2]=l,c[r+s+0]=n,c[r+s+1]=o,c[r+s+2]=l}}else{c=[],ao.a.fromArray(i,0),ao.b.fromArray(n,0),ao.c.fromArray(i,3),ao.getNormal(ro);for(let e=0;e<t;e++)c.push(...ro)}}return{uv:[...t,...s],positions:[...i,...n],indices:o,normals:c}}}},lo={},co=new l.Vector3,ho=new l.Vector3,uo=new l.Vector3,po=new l.Vector3,mo=new l.Vector3,fo=new l.Vector3,go=new l.Vector3,bo=new l.Vector2,yo=new l.Vector2,vo=new l.Vector2,xo=class extends qn{constructor(){super(),this.ellipsoid=new wi,this.skirtLength=1e3,this.smoothSkirtNormals=!0,this.solid=!1,this.minLat=-Math.PI/2,this.maxLat=Math.PI/2,this.minLon=-Math.PI,this.maxLon=Math.PI,this.attributeList=["position","normal","uv"]}clipToQuadrant(e,t,i){let{solid:r,skirtLength:a,ellipsoid:s,smoothSkirtNormals:n}=this;this.clearSplitOperations(),this.addSplitOperation(wo("x"),!t),this.addSplitOperation(wo("y"),!i);let o,l,c=e.geometry.groups[0],h=this.getClippedData(e,c);if(this.adjustVertices(h,e.position,0),r){o={index:h.index.slice().reverse(),attributes:{}};for(let e in h.attributes)o.attributes[e]=h.attributes[e].slice();let t=o.attributes.normal;if(t)for(let e=0;e<t.length;e+=3)t[e+0]*=-1,t[e+1]*=-1,t[e+2]*=-1;this.adjustVertices(o,e.position,-a)}if(a>0){l={index:[],attributes:{position:[],normal:[],uv:[]}};let t=0,i={},r=(e,r,a)=>{let s=Xn(...e,...a,...r);s in i||(i[s]=t,t++,l.attributes.position.push(...e),l.attributes.normal.push(...a),l.attributes.uv.push(...r)),l.index.push(i[s])},o=h.index,c=h.attributes.uv,d=h.attributes.position,u=h.attributes.normal,p=h.index.length/3;for(let l=0;l<p;l++){let t=3*l;for(let i=0;i<3;i++){let l=(i+1)%3,h=o[t+i],p=o[t+l];if(bo.fromArray(c,2*h),yo.fromArray(c,2*p),bo.x===yo.x&&(0===bo.x||.5===bo.x||1===bo.x)||bo.y===yo.y&&(0===bo.y||.5===bo.y||1===bo.y)){ho.fromArray(d,3*h),uo.fromArray(d,3*p);let t=ho,i=uo,o=po.copy(ho),l=mo.copy(uo);fo.copy(o).add(e.position),s.getPositionToNormal(fo,fo),o.addScaledVector(fo,-a),fo.copy(l).add(e.position),s.getPositionToNormal(fo,fo),l.addScaledVector(fo,-a),n&&u?(fo.fromArray(u,3*h),go.fromArray(u,3*p)):(fo.subVectors(t,i),go.subVectors(t,o).cross(fo).normalize(),fo.copy(go)),r(i,yo,go),r(t,bo,fo),r(o,bo,fo),r(i,yo,go),r(o,bo,fo),r(l,yo,go)}}}}let d=h.index.length,u=h;if(o){let{index:e,attributes:t}=o,i=u.attributes.position.length/3;for(let r=0,a=e.length;r<a;r++)u.index.push(e[r]+i);for(let r in h.attributes)u.attributes[r].push(...t[r])}if(l){let{index:e,attributes:t}=l,i=u.attributes.position.length/3;for(let r=0,a=e.length;r<a;r++)u.index.push(e[r]+i);for(let r in h.attributes)u.attributes[r].push(...t[r])}let p=t?0:-.5,m=i?0:-.5,f=u.attributes.uv;for(let v=0,x=f.length;v<x;v+=2)f[v]=2*(f[v]+p),f[v+1]=2*(f[v+1]+m);let g=this.constructMesh(u.attributes,u.index,e);g.userData.minHeight=e.userData.minHeight,g.userData.maxHeight=e.userData.maxHeight;let b=0,y=0;return g.geometry.addGroup(y,d,b),y+=d,b++,o&&(g.geometry.addGroup(y,o.index.length,b),y+=o.index.length,b++),l&&(g.geometry.addGroup(y,l.index.length,b),y+=l.index.length,b++),g}adjustVertices(e,t,i){let{ellipsoid:r,minLat:a,maxLat:s,minLon:n,maxLon:o}=this,{attributes:c,vertexIsClipped:h}=e,d=c.position,u=c.uv,p=d.length/3;for(let m=0;m<p;m++){let e=bo.fromArray(u,2*m);h&&h[m]&&(Math.abs(e.x-.5)<1e-10&&(e.x=.5),Math.abs(e.y-.5)<1e-10&&(e.y=.5),bo.toArray(u,2*m));let c=l.MathUtils.lerp(a,s,e.y),p=l.MathUtils.lerp(n,o,e.x),f=co.fromArray(d,3*m).add(t);r.getPositionToCartographic(f,lo),r.getCartographicToPosition(c,p,lo.height+i,f),f.sub(t),f.toArray(d,3*m)}}};function wo(e){return(t,i,r,a,s)=>{let n=t.attributes.uv;return bo.fromBufferAttribute(n,i),yo.fromBufferAttribute(n,r),vo.fromBufferAttribute(n,a),bo[e]*s.x+yo[e]*s.y+vo[e]*s.z-.5}}var To=Symbol("TILE_X"),_o=Symbol("TILE_Y"),Ao=Symbol("TILE_LEVEL"),So=Symbol("TILE_AVAILABLE"),Mo=Symbol("TILE_SPLIT_SOURCE_SCENE"),Co=new l.Vector3;function Eo(e){let{available:t=null,maxzoom:i=null}=e;return null===i?t.length-1:i}function Ro(e,t){let i=e[Ao],r=function(e){let{metadataAvailability:t=-1}=e;return t}(t);return i<Eo(t)&&-1!==r&&i%r==0}var ko=class{constructor(e={}){let{useRecommendedSettings:t=!0,skirtLength:i=null,smoothSkirtNormals:r=!0,generateNormals:a=!0,solid:s=!1}=e;this.name="QUANTIZED_MESH_PLUGIN",this.priority=-1e3,this.tiles=null,this.layer=null,this.useRecommendedSettings=t,this.skirtLength=i,this.smoothSkirtNormals=r,this.solid=s,this.generateNormals=a,this.attribution=null,this.tiling=new An,this.projection=new Tn}init(e){e.fetchOptions.headers=e.fetchOptions.headers||{},e.fetchOptions.headers.Accept="application/vnd.quantized-mesh,application/octet-stream;q=0.9",this.useRecommendedSettings&&(e.errorTarget=2),this.tiles=e}loadRootTileset(){let{tiles:e}=this,t=new URL("layer.json",new URL(e.rootURL,location.href));return e.invokeAllPlugins((e=>t=e.preprocessURL?e.preprocessURL(t,null):t)),e.invokeOnePlugin((e=>e.fetchData&&e.fetchData(t,this.tiles.fetchOptions))).then((e=>e.json())).then((e=>{this.layer=e;let{projection:t="EPSG:4326",extensions:i=[],attribution:r="",available:a=null}=e,{tiling:s,tiles:n,projection:o}=this;r&&(this.attribution={value:r,type:"string",collapsible:!0}),i.length>0&&(n.fetchOptions.headers.Accept+=`;extensions=${i.join("-")}`),o.setScheme(t);let{tileCountX:l,tileCountY:c}=o;s.setProjection(o),s.generateLevels(Eo(e)+1,l,c);let h=[];for(let p=0;p<l;p++){let e=this.createChild(0,p,0,a);e&&h.push(e)}let d={asset:{version:"1.1"},geometricError:1/0,root:{refine:"REPLACE",geometricError:1/0,boundingVolume:{region:[...this.tiling.getContentBounds(),-1e4,1e4]},children:h,[So]:a,[Ao]:-1}},u=n.rootURL;return n.invokeAllPlugins((e=>u=e.preprocessURL?e.preprocessURL(u,null):u)),n.preprocessTileset(d,u),d}))}parseToMesh(e,t,i,r){let a,{skirtLength:s,solid:n,smoothSkirtNormals:o,generateNormals:l,tiles:c}=this,h=c.ellipsoid;if("quantized_tile_split"===i){let e=new URL(r).searchParams,i="true"===e.get("left"),l="true"===e.get("bottom"),c=new xo;c.ellipsoid.copy(h),c.solid=n,c.smoothSkirtNormals=o,c.skirtLength=null===s?t.geometricError:s;let[d,u,p,m]=t.parent.boundingVolume.region;c.minLat=u,c.maxLat=m,c.minLon=d,c.maxLon=p;let f=t.parent.engineData.scene||t.parent[Mo];a=c.clipToQuadrant(f,i,l)}else{if("terrain"!==i)return;{let i=new oo(c.manager);i.ellipsoid.copy(h),i.solid=n,i.smoothSkirtNormals=o,i.generateNormals=l,i.skirtLength=null===s?t.geometricError:s;let[r,d,u,p]=t.boundingVolume.region;i.minLat=d,i.maxLat=p,i.minLon=r,i.maxLon=u,a=i.parse(e)}}let{minHeight:d,maxHeight:u,metadata:p}=a.userData;return t.boundingVolume.region[4]=d,t.boundingVolume.region[5]=u,t.engineData.boundingVolume.setRegionData(h,...t.boundingVolume.region),p&&("geometricerror"in p&&(t.geometricError=p.geometricerror),Ro(t,this.layer)&&"available"in p&&0===t.children.length&&(t[So]=[...Array(t[Ao]+1).fill(null),...p.available])),t[Mo]=a,this.expandChildren(t),a}getAttributions(e){this.attribution&&e.push(this.attribution)}createChild(e,t,i,r){let{tiles:a,layer:s,tiling:n,projection:o}=this,l=a.ellipsoid,c=null===r&&0===e||function(e,t,i,r){if(e&&t<e.length){let a=e[t];for(let e=0,t=a.length;e<t;e++){let{startX:t,startY:s,endX:n,endY:o}=a[e];if(i>=t&&i<=n&&r>=s&&r<=o)return!0}}return!1}(r,e,t,i),h=function(e,t,i,r,a){return a.tiles[0].replace(/{\s*z\s*}/g,i).replace(/{\s*x\s*}/g,e).replace(/{\s*y\s*}/g,t).replace(/{\s*version\s*}/g,r)}(t,i,e,1,s),d=[...n.getTileBounds(t,i,e),-1e4,1e4],[,u,,p,,m]=d,f=u>0==p>0?Math.min(Math.abs(u),Math.abs(p)):0;l.getCartographicToPosition(f,0,m,Co),Co.z=0;let g=o.tileCountX,b=2*Math.max(...l.radius)*Math.PI*.25/(65*g)/2**e,y={[So]:null,[Ao]:e,[To]:t,[_o]:i,refine:"REPLACE",geometricError:b,boundingVolume:{region:d},content:c?{uri:h}:null,children:[]};return Ro(y,s)||(y[So]=r),y}expandChildren(e){let t=e[Ao],i=e[To],r=e[_o],a=e[So];if(t>=this.tiling.maxLevel)return;let s=!1;for(let n=0;n<2;n++)for(let o=0;o<2;o++){let l=this.createChild(t+1,2*i+n,2*r+o,a);null===l.content?(l.content={uri:`tile.quantized_tile_split?bottom=${0===o}&left=${0===n}`},l.internal={isVirtual:!0},e.internal.virtualChildCount++,e.children.push(l)):(e.children.push(l),s=!0)}s||(e.children.length-=e.internal.virtualChildCount,e.internal.virtualChildCount=0)}fetchData(e,t){if(/quantized_tile_split/.test(e))return new ArrayBuffer}disposeTile(e){let{tiles:t,layer:i}=this;if(delete e[Mo],Ro(e,i)&&(e[So]=null),So in e){let{virtualChildCount:i}=e.internal,r=e.children.length;for(let a=r-i;a<r;a++)t.processNodeQueue.remove(e.children[a]);e.children.length=0,e.internal.virtualChildCount=0}}},Po=class extends on{constructor(e={}){super({assetTypeHandler:(e,t,i)=>{if("TERRAIN"===e&&null===t.getPluginByName("QUANTIZED_MESH_PLUGIN"))t.registerPlugin(new ko({useRecommendedSettings:this.useRecommendedSettings}));else if("IMAGERY"===e&&null===t.getPluginByName("GENERATED_SURFACE_PLUGIN")){let e=new io({url:t.rootURL});t.registerPlugin(new Ln({shape:"ellipsoid",overlay:e}))}},...e})}},Fo=new l.Matrix4,Lo=class{constructor(){this.name="UPDATE_ON_CHANGE_PLUGIN",this.tiles=null,this.needsUpdate=!1,this.cameraMatrices=new Map}init(e){this.tiles=e,this._needsUpdateCallback=()=>{this.needsUpdate=!0},this._onCameraAdd=({camera:e})=>{this.needsUpdate=!0,this.cameraMatrices.set(e,new l.Matrix4)},this._onCameraDelete=({camera:e})=>{this.needsUpdate=!0,this.cameraMatrices.delete(e)},e.addEventListener("needs-update",this._needsUpdateCallback),e.addEventListener("add-camera",this._onCameraAdd),e.addEventListener("delete-camera",this._onCameraDelete),e.addEventListener("camera-resolution-change",this._needsUpdateCallback),e.cameras.forEach((e=>{this._onCameraAdd({camera:e})}))}doTilesNeedUpdate(){let e=this.tiles,t=!1;this.cameraMatrices.forEach(((i,r)=>{Fo.copy(e.group.matrixWorld).premultiply(r.matrixWorldInverse).premultiply(r.projectionMatrixInverse),t||(t=!Fo.equals(i)),i.copy(Fo)}));let i=this.needsUpdate;return this.needsUpdate=!1,i||t}preprocessNode(){this.needsUpdate=!0}dispose(){let e=this.tiles;e.removeEventListener("camera-resolution-change",this._needsUpdateCallback),e.removeEventListener("needs-update",this._needsUpdateCallback),e.removeEventListener("add-camera",this._onCameraAdd),e.removeEventListener("delete-camera",this._onCameraDelete)}},Do=new l.Vector3;function Uo(e,t){if(e.isInterleavedBufferAttribute||e.array instanceof t)return e;let i=t===Int8Array||t===Int16Array||t===Int32Array?-1:0,r=new l.BufferAttribute(new t(e.count*e.itemSize),e.itemSize,!0),a=e.itemSize,s=e.count;for(let n=0;n<s;n++)for(let t=0;t<a;t++){let a=l.MathUtils.clamp(e.getComponent(n,t),i,1);r.setComponent(n,t,a)}return r}var Io=class{constructor(e){this._options={generateNormals:!1,disableMipmaps:!0,compressIndex:!0,compressNormals:!1,compressUvs:!1,compressPosition:!1,uvType:Int8Array,normalType:Int8Array,positionType:Int16Array,...e},this.name="TILES_COMPRESSION_PLUGIN",this.priority=-100}processTileModel(e,t){let{generateNormals:i,disableMipmaps:r,compressIndex:a,compressUvs:s,compressNormals:n,compressPosition:o,uvType:c,normalType:h,positionType:d}=this._options;e.traverse((e=>{if(e.material&&r){let t=e.material;for(let e in t){let i=t[e];i&&i.isTexture&&i.generateMipmaps&&(i.generateMipmaps=!1,i.minFilter=l.LinearFilter)}}if(e.geometry){let t=e.geometry,r=t.attributes;if(s){let{uv:e,uv1:t,uv2:i,uv3:a}=r;e&&(r.uv=Uo(e,c)),t&&(r.uv1=Uo(t,c)),i&&(r.uv2=Uo(i,c)),a&&(r.uv3=Uo(a,c))}if(i&&!r.normals&&t.computeVertexNormals(),n&&r.normals&&(r.normals=Uo(r.normals,h)),o&&function(e,t=Int16Array){let i=e.geometry,r=i.attributes,a=r.position;if(a.isInterleavedBufferAttribute||a.array instanceof t)return a;let s=new l.BufferAttribute(new t(a.count*a.itemSize),a.itemSize,!1),n=a.itemSize,o=a.count;i.computeBoundingBox();let c=i.boundingBox,{min:h,max:d}=c,u=2**(8*t.BYTES_PER_ELEMENT-1)-1,p=-u;for(let m=0;m<o;m++)for(let e=0;e<n;e++){let t=0===e?"x":1===e?"y":"z",i=h[t],r=d[t],n=l.MathUtils.mapLinear(a.getComponent(m,e),i,r,p,u);s.setComponent(m,e,n)}c.getCenter(Do).multiply(e.scale).applyQuaternion(e.quaternion),e.position.add(Do),e.scale.x*=.5*(d.x-h.x)/u,e.scale.y*=.5*(d.y-h.y)/u,e.scale.z*=.5*(d.z-h.z)/u,r.position=s,e.geometry.boundingBox=null,e.geometry.boundingSphere=null,e.updateMatrixWorld()}(e,d),a&&t.index){let e=r.position.count,i=t.index,a=e>65535?Uint32Array:e>255?Uint16Array:Uint8Array;if(!(i.array instanceof a)){let e=new a(t.index.count);e.set(i.array);let r=new l.BufferAttribute(e,1);t.setIndex(r)}}}}))}};function Oo(e,t,i){return e&&t in e?e[t]:i}function Bo(e){return"BOOLEAN"!==e&&"STRING"!==e&&"ENUM"!==e}function Vo(e){return/^VEC/.test(e)}function No(e){return/^MAT/.test(e)}function jo(e,t,i,r=null){return No(i)||Vo(i)?r.fromArray(e,t):e[t]}function zo(e){let{type:t,componentType:i}=e;switch(t){case"SCALAR":return"INT64"===i?0n:0;case"VEC2":return new l.Vector2;case"VEC3":return new l.Vector3;case"VEC4":return new l.Vector4;case"MAT2":return new l.Matrix2;case"MAT3":return new l.Matrix3;case"MAT4":return new l.Matrix4;case"BOOLEAN":return!1;case"STRING":return"";case"ENUM":return 0}}function Go(e,t){if(null==t)return!1;switch(e){case"SCALAR":case"ENUM":return"number"==typeof t||"bigint"==typeof t;case"VEC2":return t.isVector2;case"VEC3":return t.isVector3;case"VEC4":return t.isVector4;case"MAT2":return t.isMatrix2;case"MAT3":return t.isMatrix3;case"MAT4":return t.isMatrix4;case"BOOLEAN":return"boolean"==typeof t;case"STRING":return"string"==typeof t}throw Error("ClassProperty: invalid type.")}function Ho(e,t=null){switch(e){case"INT8":return Int8Array;case"INT16":return Int16Array;case"INT32":return Int32Array;case"INT64":return BigInt64Array;case"UINT8":return Uint8Array;case"UINT16":return Uint16Array;case"UINT32":return Uint32Array;case"UINT64":return BigUint64Array;case"FLOAT32":return Float32Array;case"FLOAT64":return Float64Array}switch(t){case"BOOLEAN":case"STRING":return Uint8Array}throw Error("ClassProperty: invalid type.")}function qo(e,t=null){let i=e.default,r=e.type;if(t||(t=zo(e)),null===i){switch(r){case"SCALAR":return 0;case"VEC2":return t.set(0,0);case"VEC3":return t.set(0,0,0);case"VEC4":return t.set(0,0,0,0);case"MAT2":case"MAT3":case"MAT4":return t.identity();case"BOOLEAN":return!1;case"STRING":case"ENUM":return""}throw Error("ClassProperty: invalid type.")}if(No(r))t.fromArray(i);else{if(!Vo(r))return i;t.fromArray(i)}}function Wo(e,t){if(null===e.noData)return t;let i=e.noData,r=e.type;if(Array.isArray(t))for(let s=0,n=t.length;s<n;s++)t[s]=a(t[s]);else t=a(t);return t;function a(t){return function(e){if(No(r)){let t=e.elements;for(let e=0,r=i.length;e<r;e++)if(i[e]!==t[e])return!1;return!0}if(Vo(r)){for(let t=0,r=i.length;t<r;t++)if(i[t]!==e.getComponent(t))return!1;return!0}return i===e}(t)&&(t=qo(e,t)),t}}function Ko(e,t){let{type:i,componentType:r,scale:a,offset:s,normalized:n}=e;if(Array.isArray(t))for(let c=0,h=t.length;c<h;c++)t[c]=o(t[c]);else t=o(t);return t;function o(e){return e=No(i)?function(e){let t=e.elements;for(let i=0,r=t.length;i<r;i++)t[i]=l(t[i]);return e}(e):Vo(i)?function(e){return e.x=l(e.x),e.y=l(e.y),"z"in e&&(e.z=l(e.z)),"w"in e&&(e.w=l(e.w)),e}(e):l(e)}function l(e){return n&&(e=function(e,t){switch(e){case"INT8":return Math.max(t/127,-1);case"INT16":return Math.max(t,32767,-1);case"INT32":return Math.max(t/2147483647,-1);case"INT64":return Math.max(Number(t)/0x8000000000000000,-1);case"UINT8":return t/255;case"UINT16":return t/65535;case"UINT32":return t/4294967295;case"UINT64":return Number(t)/0x10000000000000000}}(r,e)),(n||function(e){return/^FLOAT/.test(e)}(r))&&(e=e*a+s),e}}function Jo(e,t,i=null){if(e.array){Array.isArray(t)||(t=Array(e.count||0)),t.length=null===i?e.count:i;for(let i=0,r=t.length;i<r;i++)Go(e.type,t[i])||(t[i]=zo(e))}else Go(e.type,t)||(t=zo(e));return t}function Xo(e,t){for(let i in t)i in e||delete t[i];for(let i in e){let r=e[i];t[i]=Jo(r,t[i])}}var Qo=class{constructor(e,t,i=null){this.name=t.name||null,this.description=t.description||null,this.type=t.type,this.componentType=t.componentType||null,this.enumType=t.enumType||null,this.array=t.array||!1,this.count=t.count||0,this.normalized=t.normalized||!1,this.offset=t.offset||0,this.scale=Oo(t,"scale",1),this.max=Oo(t,"max",1/0),this.min=Oo(t,"min",-1/0),this.required=t.required||!1,this.noData=Oo(t,"noData",null),this.default=Oo(t,"default",null),this.semantic=Oo(t,"semantic",null),this.enumSet=null,this.accessorProperty=i,i&&(this.offset=Oo(i,"offset",this.offset),this.scale=Oo(i,"scale",this.scale),this.max=Oo(i,"max",this.max),this.min=Oo(i,"min",this.min)),"ENUM"===t.type&&(this.enumSet=e[this.enumType],null===this.componentType&&(this.componentType=Oo(this.enumSet,"valueType","UINT16")))}shapeToProperty(e,t=null){return Jo(this,e,t)}resolveDefaultElement(e){return qo(this,e)}resolveDefault(e){return function(e,t=null){if(e.array){(t=t&&Array.isArray(t)?t:[]).length=e.count;for(let i=0,r=t.length;i<r;i++)t[i]=qo(e,t[i])}else t=qo(e,t);return t}(this,e)}resolveNoData(e){return Wo(this,e)}resolveEnumsToStrings(e){let t=this.enumSet;if("ENUM"===this.type)if(Array.isArray(e))for(let r=0,a=e.length;r<a;r++)e[r]=i(e[r]);else e=i(e);return e;function i(e){let i=t.values.find((t=>t.value===e));return null===i?"":i.name}}adjustValueScaleOffset(e){return Bo(this.type)?Ko(this,e):e}},Yo=class{constructor(e,t={},i={},r=null){this.definition=e,this.class=t[e.class],this.className=e.class,this.enums=i,this.data=r,this.name="name"in e?e.name:null,this.properties=null}getPropertyNames(){return Object.keys(this.class.properties)}includesData(e){return!!this.definition.properties[e]}dispose(){}_initProperties(e=Qo){let t={};for(let i in this.class.properties)t[i]=new e(this.enums,this.class.properties[i],this.definition.properties[i]);this.properties=t}},Zo=class extends Qo{constructor(e,t,i=null){super(e,t,i),this.attribute=(null==i?void 0:i.attribute)??null}},$o=class extends Yo{constructor(...e){super(...e),this.isPropertyAttributeAccessor=!0,this._initProperties(Zo)}getData(e,t,i={}){let r=this.properties;Xo(r,i);for(let a in r)i[a]=this.getPropertyValue(a,e,t,i[a]);return i}getPropertyValue(e,t,i,r=null){if(t>=this.count)throw Error("PropertyAttributeAccessor: Requested index is outside the range of the buffer.");let a=this.properties[e],s=a.type;if(!a)throw Error("PropertyAttributeAccessor: Requested class property does not exist.");if(!this.definition.properties[e])return a.resolveDefault(r);r=a.shapeToProperty(r);let n=i.getAttribute(a.attribute.toLowerCase());if(No(s)){let e=r.elements;for(let i=e.length;0<i;)e[0]=n.getComponent(t,0)}else if(Vo(s))r.fromBufferAttribute(n,t);else{if("SCALAR"!==s&&"ENUM"!==s)throw Error("StructuredMetadata.PropertyAttributeAccessor: BOOLEAN and STRING types are not supported by property attributes.");r=n.getX(t)}return r=a.adjustValueScaleOffset(r),r=a.resolveEnumsToStrings(r),r=a.resolveNoData(r)}},el=class extends Qo{constructor(e,t,i=null){super(e,t,i),this.values=(null==i?void 0:i.values)??null,this.valueLength=function(e){switch(e){case"ENUM":case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;default:return-1}}(this.type),this.arrayOffsets=Oo(i,"arrayOffsets",null),this.stringOffsets=Oo(i,"stringOffsets",null),this.arrayOffsetType=Oo(i,"arrayOffsetType","UINT32"),this.stringOffsetType=Oo(i,"stringOffsetType","UINT32")}getArrayLengthFromId(e,t){let i=this.count;if(null!==this.arrayOffsets){let{arrayOffsets:r,arrayOffsetType:a}=this,s=new(Ho(a))(e[r]);i=s[t+1]-s[t]}return i}getIndexOffsetFromId(e,t){let i=t;if(this.arrayOffsets){let{arrayOffsets:t,arrayOffsetType:r}=this;i=new(Ho(r))(e[t])[i]}else this.array&&(i*=this.count);return i}},tl=class extends Yo{constructor(...e){super(...e),this.isPropertyTableAccessor=!0,this.count=this.definition.count,this._initProperties(el)}getData(e,t={}){let i=this.properties;Xo(i,t);for(let r in i)t[r]=this.getPropertyValue(r,e,t[r]);return t}_readValueAtIndex(e,t,i,r=null){let a=this.properties[e],{componentType:s,type:n}=a,o=this.data,l=o[a.values],c=new(Ho(s,n))(l),h=a.getIndexOffsetFromId(o,t);if(Bo(n)||"ENUM"===n)return jo(c,(h+i)*a.valueLength,n,r);if("STRING"===n){let e=h+i,t=0;if(null!==a.stringOffsets){let{stringOffsets:i,stringOffsetType:r}=a,s=new(Ho(r))(o[i]);t=s[e+1]-s[e],e=s[e]}let s=new Uint8Array(c.buffer,e,t);r=(new TextDecoder).decode(s)}else if("BOOLEAN"===n){let e=h+i,t=e%8;r=1==(c[Math.floor(e/8)]>>t&1)}return r}getPropertyValue(e,t,i=null){if(t>=this.count)throw Error("PropertyTableAccessor: Requested index is outside the range of the table.");let r=this.properties[e];if(!r)throw Error("PropertyTableAccessor: Requested property does not exist.");if(!this.definition.properties[e])return r.resolveDefault(i);let a=r.array,s=this.data,n=r.getArrayLengthFromId(s,t);if(i=r.shapeToProperty(i,n),a)for(let o=0,l=i.length;o<l;o++)i[o]=this._readValueAtIndex(e,t,o,i[o]);else i=this._readValueAtIndex(e,t,0,i);return i=r.adjustValueScaleOffset(i),i=r.resolveEnumsToStrings(i),i=r.resolveNoData(i)}},il=new l.Box2,rl=class{constructor(){this._renderer=new l.WebGLRenderer,this._target=new l.WebGLRenderTarget(1,1),this._texTarget=new l.WebGLRenderTarget,this._quad=new vn(new l.ShaderMaterial({blending:l.CustomBlending,blendDst:l.ZeroFactor,blendSrc:l.OneFactor,uniforms:{map:{value:null},pixel:{value:new l.Vector2}},vertexShader:"\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\t\t\t\tuniform sampler2D map;\n\t\t\t\tuniform ivec2 pixel;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tgl_FragColor = texelFetch( map, pixel, 0 );\n\n\t\t\t\t}\n\t\t\t"}))}increaseSizeTo(e){this._target.setSize(Math.max(this._target.width,e),1)}readDataAsync(e){let{_renderer:t,_target:i}=this;return t.readRenderTargetPixelsAsync(i,0,0,e.length/4,1,e)}readData(e){let{_renderer:t,_target:i}=this;t.readRenderTargetPixels(i,0,0,e.length/4,1,e)}renderPixelToTarget(e,t,i){let{_renderer:r,_target:a}=this;il.min.copy(t),il.max.copy(t),il.max.x+=1,il.max.y+=1,r.initRenderTarget(a),r.copyTextureToTexture(e,a.texture,il,i,0)}},al=new class{constructor(){let e=null;Object.getOwnPropertyNames(rl.prototype).forEach((t=>{"constructor"!==t&&(this[t]=(...i)=>(e||(e=new rl),e[t](...i)))}))}},sl=new l.Vector2,nl=new l.Vector2,ol=new l.Vector2;function ll(e,t,i=[,,,]){let r=3*t,a=3*t+1,s=3*t+2;return e.index&&(r=e.index.getX(r),a=e.index.getX(a),s=e.index.getX(s)),i[0]=r,i[1]=a,i[2]=s,i}function cl(e,t,i,r,a){let[s,n,o]=r,l=function(e,t){return 0===t?e.getAttribute("uv"):e.getAttribute(`uv${t}`)}(e,t);sl.fromBufferAttribute(l,s),nl.fromBufferAttribute(l,n),ol.fromBufferAttribute(l,o),a.set(0,0,0).addScaledVector(sl,i.x).addScaledVector(nl,i.y).addScaledVector(ol,i.z)}function hl(e,t,i,r){let a=e.x-Math.floor(e.x),s=e.y-Math.floor(e.y),n=Math.floor(a*t%t),o=Math.floor(s*i%i);return r.set(n,o),r}var dl=new l.Vector2,ul=new l.Vector2,pl=new l.Vector2,ml=class extends Qo{constructor(e,t,i=null){super(e,t,i),this.channels=Oo(i,"channels",[0]),this.index=Oo(i,"index",null),this.texCoord=Oo(i,"texCoord",null),this.valueLength=parseInt(this.type.replace(/[^0-9]/g,""))||1}readDataFromBuffer(e,t,i=null){let r=this.type;if("BOOLEAN"===r||"STRING"===r)throw Error("PropertyTextureAccessor: BOOLEAN and STRING types not supported.");return jo(e,t*this.valueLength,r,i)}},fl=class extends Yo{constructor(...e){super(...e),this.isPropertyTextureAccessor=!0,this._asyncRead=!1,this._initProperties(ml)}getData(e,t,i,r={}){let a=this.properties;Xo(a,r);let s=Object.keys(a),n=s.map((e=>r[e]));return this.getPropertyValuesAtTexel(s,e,t,i,n),s.forEach(((e,t)=>r[e]=n[t])),r}async getDataAsync(e,t,i,r={}){let a=this.properties;Xo(a,r);let s=Object.keys(a),n=s.map((e=>r[e]));return await this.getPropertyValuesAtTexelAsync(s,e,t,i,n),s.forEach(((e,t)=>r[e]=n[t])),r}getPropertyValuesAtTexelAsync(...e){this._asyncRead=!0;let t=this.getPropertyValuesAtTexel(...e);return this._asyncRead=!1,t}getPropertyValuesAtTexel(e,t,i,r,a=[]){for(;a.length<e.length;)a.push(null);a.length=e.length,al.increaseSizeTo(a.length);let s=this.data,n=this.definition.properties,o=this.properties,l=ll(r,t);for(let d=0,u=e.length;d<u;d++){let t=e[d];if(!n[t])continue;let a=o[t],c=s[a.index];cl(r,a.texCoord,i,l,dl),hl(dl,c.image.width,c.image.height,ul),pl.set(d,0),al.renderPixelToTarget(c,ul,pl)}let c=new Uint8Array(4*e.length);return this._asyncRead?al.readDataAsync(c).then((()=>(h.call(this),a))):(al.readData(c),h.call(this),a);function h(){for(let t=0,i=e.length;t<i;t++){let i=e[t],r=o[i],s=r.type;if(a[t]=Jo(r,a[t]),!r)throw Error("PropertyTextureAccessor: Requested property does not exist.");if(!n[i]){a[t]=r.resolveDefault(a);continue}let l=r.valueLength*(r.count||1),h=r.channels.map((e=>c[4*t+e])),d=new(Ho(r.componentType,s))(l);if(new Uint8Array(d.buffer).set(h),r.array){let e=a[t];for(let t=0,i=e.length;t<i;t++)e[t]=r.readDataFromBuffer(d,t,e[t])}else a[t]=r.readDataFromBuffer(d,0,a[t]);a[t]=r.adjustValueScaleOffset(a[t]),a[t]=r.resolveEnumsToStrings(a[t]),a[t]=r.resolveNoData(a[t])}}}dispose(){this.data.forEach((e=>{e&&(e.dispose(),e.image instanceof ImageBitmap&&e.image.close())}))}},gl=class{constructor(e,t,i,r=null,a=null){let{schema:s,propertyTables:n=[],propertyTextures:o=[],propertyAttributes:l=[]}=e,{enums:c,classes:h}=s,d=n.map((e=>new tl(e,h,c,i))),u=[],p=[];r&&(r.propertyTextures&&(u=r.propertyTextures.map((e=>new fl(o[e],h,c,t)))),r.propertyAttributes&&(p=r.propertyAttributes.map((e=>new $o(l[e],h,c))))),this.schema=s,this.tableAccessors=d,this.textureAccessors=u,this.attributeAccessors=p,this.object=a,this.textures=t,this.nodeMetadata=r}getPropertyTableData(e,t,i=null){if(Array.isArray(e)){i||(i=[]);let r=Math.min(e.length,t.length);i.length=r;for(let a=0;a<r;a++){let r=this.tableAccessors[e[a]];i[a]=r.getData(t[a],i[a])}}else i||(i={}),i=this.tableAccessors[e].getData(t,i);if(Array.isArray(e)!==Array.isArray(i)||Array.isArray(e)!==Array.isArray(t))throw Error("StructuralMetadata: Scalar and array inputs cannot be mixed.");return i}getPropertyTableInfo(e=null){if(null===e&&(e=this.tableAccessors.map(((e,t)=>t))),Array.isArray(e))return e.map((e=>{let t=this.tableAccessors[e];return{name:t.name,className:t.definition.class}}));{let t=this.tableAccessors[e];return{name:t.name,className:t.definition.class}}}getPropertyTextureData(e,t,i=[]){let r=this.textureAccessors;i.length=r.length;for(let a=0;a<r.length;a++)i[a]=r[a].getData(e,t,this.object.geometry,i[a]);return i}async getPropertyTextureDataAsync(e,t,i=[]){let r=this.textureAccessors;i.length=r.length;let a=[];for(let s=0;s<r.length;s++){let n=r[s].getDataAsync(e,t,this.object.geometry,i[s]).then((e=>{i[s]=e}));a.push(n)}return await Promise.all(a),i}getPropertyTextureInfo(){return this.textureAccessors}getPropertyAttributeData(e,t=[]){let i=this.attributeAccessors;t.length=i.length;for(let r=0;r<i.length;r++)t[r]=i[r].getData(e,this.object.geometry,t[r]);return t}getPropertyAttributeInfo(){return this.attributeAccessors.map((e=>({name:e.name,className:e.definition.class})))}dispose(){this.textureAccessors.forEach((e=>e.dispose())),this.tableAccessors.forEach((e=>e.dispose())),this.attributeAccessors.forEach((e=>e.dispose()))}},bl="EXT_structural_metadata";function yl(e,t=[]){var i;let r=(null==(i=e.json.textures)?void 0:i.length)||0,a=Array(r).fill(null);return t.forEach((({properties:t})=>{for(let i in t){let{index:r}=t[i];null===a[r]&&(a[r]=e.loadTexture(r))}})),Promise.all(a)}function vl(e,t=[]){var i;let r=(null==(i=e.json.bufferViews)?void 0:i.length)||0,a=Array(r).fill(null);return t.forEach((({properties:t})=>{for(let i in t){let{values:r,arrayOffsets:s,stringOffsets:n}=t[i];null===a[r]&&(a[r]=e.getDependency("bufferView",r)),null===a[s]&&(a[s]=e.getDependency("bufferView",s)),null===a[n]&&(a[n]=e.getDependency("bufferView",n))}})),Promise.all(a)}var xl=class{constructor(e){this.parser=e,this.name=bl}async afterRoot({scene:e,parser:t}){let i=t.json.extensionsUsed;if(!i||!i.includes(bl))return;let r=null,a=t.json.extensions[bl];if(a.schemaUri){let{manager:e,path:i,requestHeader:s,crossOrigin:n}=t.options,o=new URL(a.schemaUri,i).toString(),c=new l.FileLoader(e);c.setCrossOrigin(n),c.setResponseType("json"),c.setRequestHeader(s),r=c.loadAsync(o).then((e=>{a={...a,schema:e}}))}let[s,n]=await Promise.all([yl(t,a.propertyTextures),vl(t,a.propertyTables),r]),o=new gl(a,s,n);e.userData.structuralMetadata=o,e.traverse((e=>{var i;if(t.associations.has(e)){let{meshes:r,primitives:l}=t.associations.get(e),c=null==(i=t.json.meshes[r])?void 0:i.primitives[l];if(c&&c.extensions&&c.extensions[bl]){let t=c.extensions[bl];e.userData.structuralMetadata=new gl(a,s,n,t,e)}else e.userData.structuralMetadata=o}}))}},wl=new l.Vector2,Tl=new l.Vector2,_l=new l.Vector2;var Al=class{constructor(e,t,i){this.geometry=e,this.textures=t,this.data=i,this._asyncRead=!1,this.featureIds=i.featureIds.map((e=>{let{texture:t,...i}=e,r={label:null,propertyTable:null,nullFeatureId:null,...i};return t&&(r.texture={texCoord:0,channels:[0],...t}),r}))}getTextures(){return this.textures}getFeatureInfo(){return this.featureIds}getFeaturesAsync(...e){this._asyncRead=!0;let t=this.getFeatures(...e);return this._asyncRead=!1,t}getFeatures(e,t){let{geometry:i,textures:r,featureIds:a}=this,s=Array(a.length).fill(null),n=a.length;al.increaseSizeTo(n);let o=ll(i,e),l=o[function(e){return e.x>e.y&&e.x>e.z?0:e.y>e.z?1:2}(t)];for(let d=0,u=a.length;d<u;d++){let e=a[d],n="nullFeatureId"in e?e.nullFeatureId:null;if("texture"in e){let a=r[e.texture.index];cl(i,e.texture.texCoord,t,o,wl),hl(wl,a.image.width,a.image.height,Tl),_l.set(d,0),al.renderPixelToTarget(r[e.texture.index],Tl,_l)}else if("attribute"in e){let t=i.getAttribute(`_feature_id_${e.attribute}`).getX(l);t!==n&&(s[d]=t)}else{let e=l;e!==n&&(s[d]=e)}}let c=new Uint8Array(4*n);return this._asyncRead?al.readDataAsync(c).then((()=>(h(),s))):(al.readData(c),h(),s);function h(){let e=new Uint32Array(1);for(let t=0,i=a.length;t<i;t++){let i=a[t],r="nullFeatureId"in i?i.nullFeatureId:null;if("texture"in i){let{channels:a}=i.texture,n=a.map((e=>c[4*t+e]));new Uint8Array(e.buffer).set(n);let o=e[0];o!==r&&(s[t]=o)}}}}dispose(){this.textures.forEach((e=>{e&&(e.dispose(),e.image instanceof ImageBitmap&&e.image.close())}))}},Sl="EXT_mesh_features";function Ml(e,t,i){e.traverse((e=>{var r;if(t.associations.has(e)){let{meshes:a,primitives:s}=t.associations.get(e),n=null==(r=t.json.meshes[a])?void 0:r.primitives[s];n&&n.extensions&&n.extensions[Sl]&&i(e,n.extensions[Sl])}}))}var Cl=class{constructor(e){this.parser=e,this.name=Sl}async afterRoot({scene:e,parser:t}){var i;let r=t.json.extensionsUsed;if(!r||!r.includes(Sl))return;let a=(null==(i=t.json.textures)?void 0:i.length)||0,s=Array(a).fill(null);Ml(e,t,((e,{featureIds:i})=>{i.forEach((e=>{if(e.texture&&null===s[e.texture.index]){let i=e.texture.index;s[i]=t.loadTexture(i)}}))}));let n=await Promise.all(s);Ml(e,t,((e,t)=>{e.userData.meshFeatures=new Al(e.geometry,n,t)}))}},El=class{constructor(){this.name="CESIUM_RTC"}afterRoot(e){if(e.parser.json.extensions&&e.parser.json.extensions.CESIUM_RTC){let{center:t}=e.parser.json.extensions.CESIUM_RTC;t&&(e.scene.position.x+=t[0],e.scene.position.y+=t[1],e.scene.position.z+=t[2])}}},Rl=class{constructor(e){e={metadata:!0,rtc:!0,plugins:[],dracoLoader:null,ktxLoader:null,meshoptDecoder:null,autoDispose:!0,...e},this.tiles=null,this.metadata=e.metadata,this.rtc=e.rtc,this.plugins=e.plugins,this.dracoLoader=e.dracoLoader,this.ktxLoader=e.ktxLoader,this.meshoptDecoder=e.meshoptDecoder,this._gltfRegex=/\.(gltf|glb)$/g,this._dracoRegex=/\.drc$/g,this._loader=null}init(e){let t=new at(e.manager);this.dracoLoader&&(t.setDRACOLoader(this.dracoLoader),e.manager.addHandler(this._dracoRegex,this.dracoLoader)),this.ktxLoader&&t.setKTX2Loader(this.ktxLoader),this.meshoptDecoder&&t.setMeshoptDecoder(this.meshoptDecoder),this.rtc&&t.register((()=>new El)),this.metadata&&(t.register((()=>new xl)),t.register((()=>new Cl))),this.plugins.forEach((e=>t.register(e))),e.manager.addHandler(this._gltfRegex,t),this.tiles=e,this._loader=t}dispose(){this.tiles.manager.removeHandler(this._gltfRegex),this.tiles.manager.removeHandler(this._dracoRegex),this.autoDispose&&(this.ktxLoader.dispose(),this.dracoLoader.dispose())}},kl=class{set delay(e){this.deferCallbacks.delay=e}get delay(){return this.deferCallbacks.delay}set bytesTarget(e){this.lruCache.minBytesSize=e}get bytesTarget(){return this.lruCache.minBytesSize}get estimatedGpuBytes(){return this.lruCache.cachedBytes}constructor(e={}){let{delay:t=0,bytesTarget:i=0}=e;this.name="UNLOAD_TILES_PLUGIN",this.tiles=null,this.lruCache=new ue,this.deferCallbacks=new Pl,this.delay=t,this.bytesTarget=i}init(e){this.tiles=e;let{lruCache:t,deferCallbacks:i}=this,r=t=>{let i=t.engineData.scene;e.visibleTiles.has(t)||e.invokeOnePlugin((e=>e.unloadTileFromGPU&&e.unloadTileFromGPU(i,t)))};this._onUpdateBefore=()=>{t.unloadPriorityCallback=e.lruCache.unloadPriorityCallback,t.minSize=1/0,t.maxSize=1/0,t.maxBytesSize=1/0,t.unloadPercent=1,t.autoMarkUnused=!1},this._onVisibilityChangeCallback=({tile:a,scene:s,visible:n})=>{n?(t.add(a,r),t.setMemoryUsage(a,e.calculateBytesUsed(a,s)||1),e.markTileUsed(a),i.cancel(a)):i.run(a)},this._onDisposeModel=({tile:e})=>{t.remove(e),i.cancel(e)},i.callback=e=>{t.markUnused(e),t.scheduleUnload()},e.forEachLoadedModel(((t,i)=>{let r=e.visibleTiles.has(i);this._onVisibilityChangeCallback({tile:i,visible:r})})),e.addEventListener("tile-visibility-change",this._onVisibilityChangeCallback),e.addEventListener("update-before",this._onUpdateBefore),e.addEventListener("dispose-model",this._onDisposeModel)}unloadTileFromGPU(e,t){e&&e.traverse((e=>{if(e.material){let t=e.material;t.dispose();for(let e in t){let i=t[e];i&&i.isTexture&&i.dispose()}}e.geometry&&e.geometry.dispose()}))}dispose(){let{lruCache:e,tiles:t,deferCallbacks:i}=this;t.removeEventListener("tile-visibility-change",this._onVisibilityChangeCallback),t.removeEventListener("update-before",this._onUpdateBefore),t.removeEventListener("dispose-model",this._onDisposeModel),i.cancelAll(),e.minBytesSize=0,e.minSize=0,e.maxSize=0,e.markAllUnused(),e.scheduleUnload()}},Pl=class{constructor(e=()=>{}){this.map=new Map,this.callback=e,this.delay=0}run(e){let{map:t,delay:i}=this;if(t.has(e))throw Error("DeferCallbackManager: Callback already initialized.");0===i?this.callback(e):t.set(e,setTimeout((()=>{this.callback(e),t.delete(e)}),i))}cancel(e){let{map:t}=this;t.has(e)&&(clearTimeout(t.get(e)),t.delete(e))}cancelAll(){this.map.forEach(((e,t)=>{this.cancel(t)}))}},{clamp:Fl}=l.MathUtils,Ll=class{constructor(){this.duration=250,this.fadeCount=0,this._lastTick=-1,this._fadeState=new Map,this.onFadeComplete=null,this.onFadeStart=null,this.onFadeSetComplete=null,this.onFadeSetStart=null}deleteObject(e){e&&this.completeFade(e)}guaranteeState(e){let t=this._fadeState;return!t.has(e)&&(t.set(e,{fadeInTarget:0,fadeOutTarget:0,fadeIn:0,fadeOut:0}),!0)}completeFade(e){let t=this._fadeState;if(!t.has(e))return;let i=0===t.get(e).fadeOutTarget;t.delete(e),this.fadeCount--,this.onFadeComplete&&this.onFadeComplete(e,i),0===this.fadeCount&&this.onFadeSetComplete&&this.onFadeSetComplete()}completeAllFades(){this._fadeState.forEach(((e,t)=>{this.completeFade(t)}))}forEachObject(e){this._fadeState.forEach(((t,i)=>{e(i,t)}))}fadeIn(e){let t=this.guaranteeState(e),i=this._fadeState.get(e);i.fadeInTarget=1,i.fadeOutTarget=0,i.fadeOut=0,t&&(this.fadeCount++,1===this.fadeCount&&this.onFadeSetStart&&this.onFadeSetStart(),this.onFadeStart&&this.onFadeStart(e))}fadeOut(e){let t=this.guaranteeState(e),i=this._fadeState.get(e);i.fadeOutTarget=1,t&&(i.fadeInTarget=1,i.fadeIn=1,this.fadeCount++,1===this.fadeCount&&this.onFadeSetStart&&this.onFadeSetStart(),this.onFadeStart&&this.onFadeStart(e))}isFading(e){return this._fadeState.has(e)}isFadingOut(e){let t=this._fadeState.get(e);return t&&1===t.fadeOutTarget}update(){let e=window.performance.now();-1===this._lastTick&&(this._lastTick=e);let t=Fl((e-this._lastTick)/this.duration,0,1);this._lastTick=e,this._fadeState.forEach(((e,i)=>{let{fadeOutTarget:r,fadeInTarget:a}=e,{fadeOut:s,fadeIn:n}=e,o=Math.sign(a-n);n=Fl(n+o*t,0,1);let l=Math.sign(r-s);s=Fl(s+l*t,0,1),e.fadeIn=n,e.fadeOut=s,((1===s||0===s)&&(1===n||0===n)||s>=n)&&this.completeFade(i)}))}},Dl=Symbol("FADE_PARAMS");function Ul(e,t){if(e[Dl])return e[Dl];let i={fadeIn:{value:0},fadeOut:{value:0},fadeTexture:{value:null}};return e[Dl]=i,e.defines={...e.defines||{},FEATURE_FADE:0},e.onBeforeCompile=e=>{t&&t(e),e.uniforms={...e.uniforms,...i},e.vertexShader=e.vertexShader.replace(/void\s+main\(\)\s+{/,(e=>`\n\t\t\t\t\t#ifdef USE_BATCHING_FRAG\n\n\t\t\t\t\tvarying float vBatchId;\n\n\t\t\t\t\t#endif\n\n\t\t\t\t\t${e}\n\n\t\t\t\t\t\t#ifdef USE_BATCHING_FRAG\n\n\t\t\t\t\t\t// add 0.5 to the value to avoid floating error that may cause flickering\n\t\t\t\t\t\tvBatchId = getIndirectIndex( gl_DrawID ) + 0.5;\n\n\t\t\t\t\t\t#endif\n\t\t\t\t`)),e.fragmentShader=e.fragmentShader.replace(/void main\(/,(e=>`\n\t\t\t\t#if FEATURE_FADE\n\n\t\t\t\t// adapted from https://www.shadertoy.com/view/Mlt3z8\n\t\t\t\tfloat bayerDither2x2( vec2 v ) {\n\n\t\t\t\t\treturn mod( 3.0 * v.y + 2.0 * v.x, 4.0 );\n\n\t\t\t\t}\n\n\t\t\t\tfloat bayerDither4x4( vec2 v ) {\n\n\t\t\t\t\tvec2 P1 = mod( v, 2.0 );\n\t\t\t\t\tvec2 P2 = floor( 0.5 * mod( v, 4.0 ) );\n\t\t\t\t\treturn 4.0 * bayerDither2x2( P1 ) + bayerDither2x2( P2 );\n\n\t\t\t\t}\n\n\t\t\t\t// the USE_BATCHING define is not available in fragment shaders\n\t\t\t\t#ifdef USE_BATCHING_FRAG\n\n\t\t\t\t// functions for reading the fade state of a given batch id\n\t\t\t\tuniform sampler2D fadeTexture;\n\t\t\t\tvarying float vBatchId;\n\t\t\t\tvec2 getFadeValues( const in float i ) {\n\n\t\t\t\t\tint size = textureSize( fadeTexture, 0 ).x;\n\t\t\t\t\tint j = int( i );\n\t\t\t\t\tint x = j % size;\n\t\t\t\t\tint y = j / size;\n\t\t\t\t\treturn texelFetch( fadeTexture, ivec2( x, y ), 0 ).rg;\n\n\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\tuniform float fadeIn;\n\t\t\t\tuniform float fadeOut;\n\n\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t\t${e}\n\t\t\t`)).replace(/#include <dithering_fragment>/,(e=>`\n\n\t\t\t\t${e}\n\n\t\t\t\t#if FEATURE_FADE\n\n\t\t\t\t#ifdef USE_BATCHING_FRAG\n\n\t\t\t\tvec2 fadeValues = getFadeValues( vBatchId );\n\t\t\t\tfloat fadeIn = fadeValues.r;\n\t\t\t\tfloat fadeOut = fadeValues.g;\n\n\t\t\t\t#endif\n\n\t\t\t\tfloat bayerValue = bayerDither4x4( floor( mod( gl_FragCoord.xy, 4.0 ) ) );\n\t\t\t\tfloat bayerBins = 16.0;\n\t\t\t\tfloat dither = ( 0.5 + bayerValue ) / bayerBins;\n\t\t\t\tif ( dither >= fadeIn ) {\n\n\t\t\t\t\tdiscard;\n\n\t\t\t\t}\n\n\t\t\t\tif ( dither < fadeOut ) {\n\n\t\t\t\t\tdiscard;\n\n\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t`))},i}var Il=class{constructor(){this._fadeParams=new WeakMap,this.fading=0}setFade(e,t,i){if(!e)return;let r=this._fadeParams;e.traverse((e=>{let a=e.material;if(a&&r.has(a)){let e=r.get(a);e.fadeIn.value=t,e.fadeOut.value=i;let s=Number(!(0===t||1===t)||!(0===i||1===i));a.defines.FEATURE_FADE!==s&&(this.fading+=1===s?1:-1,a.defines.FEATURE_FADE=s,a.needsUpdate=!0)}}))}prepareScene(e){e.traverse((e=>{e.material&&this.prepareMaterial(e.material)}))}deleteScene(e){if(!e)return;this.setFade(e,1,0);let t=this._fadeParams;e.traverse((e=>{let i=e.material;i&&t.delete(i)}))}prepareMaterial(e){let t=this._fadeParams;t.has(e)||t.set(e,Ul(e,e.onBeforeCompile))}},Ol=class{constructor(e,t=new l.MeshBasicMaterial){this.other=e,this.material=t,this.visible=!0,this.parent=null,this._instanceInfo=[],this._visibilityChanged=!0;let i=new Proxy(this,{get(t,r){if(r in t)return t[r];{let a=e[r];return a instanceof Function?(...e)=>(t.syncInstances(),a.call(i,...e)):e[r]}},set:(t,i,r)=>(i in t?t[i]=r:e[i]=r,!0),deleteProperty:(t,i)=>i in t?delete t[i]:delete e[i]});return i}syncInstances(){let e=this._instanceInfo,t=this.other._instanceInfo;for(;t.length>e.length;){let i=e.length;e.push(new Proxy({visible:!1},{get:(e,r)=>r in e?e[r]:t[i][r],set:(e,r,a)=>(r in e?e[r]=a:t[i][r]=a,!0)}))}}},Bl=class extends Ol{constructor(...e){super(...e);let t=this.material,i=Ul(t,t.onBeforeCompile);t.defines.FEATURE_FADE=1,t.defines.USE_BATCHING_FRAG=1,t.needsUpdate=!0,this.fadeTexture=null,this._fadeParams=i}setFadeAt(e,t,i){this._initFadeTexture(),this.fadeTexture.setValueAt(e,255*t,255*i)}_initFadeTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);let t=e*e*2,i=this.fadeTexture;if(!i||i.image.data.length!==t){let r=new Vl(new Uint8Array(t),e,e,l.RGFormat,l.UnsignedByteType);if(i){i.dispose();let e=i.image.data,t=this.fadeTexture.image.data,r=Math.min(e.length,t.length);t.set(new e.constructor(e.buffer,0,r))}this.fadeTexture=r,this._fadeParams.fadeTexture.value=r,r.needsUpdate=!0}}dispose(){this.fadeTexture&&this.fadeTexture.dispose()}},Vl=class extends l.DataTexture{setValueAt(e,...t){let{data:i,width:r,height:a}=this.image,s=Math.floor(i.length/(r*a)),n=!1;for(let o=0;o<s;o++){let r=e*s+o,a=i[r],l=t[o]||0;a!==l&&(i[r]=l,n=!0)}n&&(this.needsUpdate=!0)}},Nl=Symbol("HAS_POPPED_IN");var jl=new l.Vector3,zl=new l.Vector3,Gl=new l.Quaternion,Hl=new l.Quaternion,ql=new l.Vector3;function Wl(){let e=this._fadeManager,t=this._fadeMaterialManager,i=this._fadingBefore,r=this._prevCameraTransforms,{tiles:a,maximumFadeOutTiles:s,batchedMesh:n}=this,{cameras:o}=a;e.update();let l=e.fadeCount;if(0!==i&&0!==l&&(a.dispatchEvent({type:"fade-change"}),a.dispatchEvent({type:"needs-render"})),s<this._fadingOutCount){let t=!0;o.forEach((e=>{if(!r.has(e))return;let i=e.matrixWorld,a=r.get(e);i.decompose(zl,Hl,ql),a.decompose(jl,Gl,ql);let s=Hl.angleTo(Gl),n=zl.distanceTo(jl);t&&(t=s>.25||n>.1)})),t&&e.completeAllFades()}if(o.forEach((e=>{r.get(e).copy(e.matrixWorld)})),e.forEachObject(((e,{fadeIn:i,fadeOut:r})=>{let s=e.engineData.scene;a.markTileUsed(e),s&&t.setFade(s,i,r),this.forEachBatchIds(e,((e,t,a)=>{t.setFadeAt(e,i,r),t.setVisibleAt(e,!0),a.batchedMesh.setVisibleAt(e,!1)}))})),n){let e=a.getPluginByName("BATCHED_TILES_PLUGIN").batchedMesh.material;n.material.map=e.map}}var Kl=class{get fadeDuration(){return this._fadeManager.duration}set fadeDuration(e){this._fadeManager.duration=Number(e)}get fadingTiles(){return this._fadeManager.fadeCount}constructor(e){e={maximumFadeOutTiles:50,fadeRootTiles:!1,fadeDuration:250,...e},this.name="FADE_TILES_PLUGIN",this.priority=-2,this.tiles=null,this.batchedMesh=null,this._quickFadeTiles=new Set,this._fadeManager=new Ll,this._fadeMaterialManager=new Il,this._prevCameraTransforms=null,this._fadingOutCount=0,this.maximumFadeOutTiles=e.maximumFadeOutTiles,this.fadeRootTiles=e.fadeRootTiles,this.fadeDuration=e.fadeDuration}init(e){this._onLoadModel=({scene:e})=>{this._fadeMaterialManager.prepareScene(e)},this._onDisposeModel=({tile:e,scene:t})=>{this.tiles.visibleTiles.has(e)&&this._quickFadeTiles.add(e.parent),this._fadeManager.deleteObject(e),this._fadeMaterialManager.deleteScene(t)},this._onAddCamera=({camera:e})=>{this._prevCameraTransforms.set(e,new l.Matrix4)},this._onDeleteCamera=({camera:e})=>{this._prevCameraTransforms.delete(e)},this._onTileVisibilityChange=({tile:e})=>{this.forEachBatchIds(e,((e,t,i)=>{t.setFadeAt(e,0,0),t.setVisibleAt(e,!1),i.batchedMesh.setVisibleAt(e,!1)}))},this._onUpdateBefore=()=>{this._fadingBefore=this._fadeManager.fadeCount},this._onUpdateAfter=()=>{Wl.call(this)},e.addEventListener("load-model",this._onLoadModel),e.addEventListener("dispose-model",this._onDisposeModel),e.addEventListener("add-camera",this._onAddCamera),e.addEventListener("delete-camera",this._onDeleteCamera),e.addEventListener("update-before",this._onUpdateBefore),e.addEventListener("update-after",this._onUpdateAfter),e.addEventListener("tile-visibility-change",this._onTileVisibilityChange);let t=this._fadeManager;t.onFadeSetStart=()=>{e.dispatchEvent({type:"fade-start"}),e.dispatchEvent({type:"needs-render"})},t.onFadeSetComplete=()=>{e.dispatchEvent({type:"fade-end"}),e.dispatchEvent({type:"needs-render"})},t.onFadeComplete=(t,i)=>{this._fadeMaterialManager.setFade(t.engineData.scene,0,0),this.forEachBatchIds(t,((e,t,r)=>{t.setFadeAt(e,0,0),t.setVisibleAt(e,!1),r.batchedMesh.setVisibleAt(e,i)})),i||(e.invokeOnePlugin((e=>e!==this&&e.setTileVisible&&e.setTileVisible(t,!1))),this._fadingOutCount--)};let i=new Map;e.cameras.forEach((e=>{i.set(e,new l.Matrix4)})),e.forEachLoadedModel(((e,t)=>{this._onLoadModel({scene:e})})),this.tiles=e,this._fadeManager=t,this._prevCameraTransforms=i}initBatchedMesh(){var e;let t=null==(e=this.tiles.getPluginByName("BATCHED_TILES_PLUGIN"))?void 0:e.batchedMesh;if(t){if(null===this.batchedMesh){this._onBatchedMeshDispose=()=>{this.batchedMesh.dispose(),this.batchedMesh.removeFromParent(),this.batchedMesh=null,t.removeEventListener("dispose",this._onBatchedMeshDispose)};let e=t.material.clone();e.onBeforeCompile=t.material.onBeforeCompile,this.batchedMesh=new Bl(t,e),this.tiles.group.add(this.batchedMesh)}}else null!==this.batchedMesh&&(this._onBatchedMeshDispose(),this._onBatchedMeshDispose=null)}setTileVisible(e,t){let i=this._fadeManager,r=i.isFading(e);if(!function(e){let t=e;for(;t;){if(t.traversal.wasSetActive)return t.traversal.wasInFrustum;t=t.parent}return!1}(e))return r&&i.completeFade(e),!1;if(i.isFadingOut(e)&&this._fadingOutCount--,t?1===e.internal.depthFromRenderedParent?((e[Nl]||this.fadeRootTiles)&&this._fadeManager.fadeIn(e),e[Nl]=!0):this._fadeManager.fadeIn(e):(this._fadingOutCount++,i.fadeOut(e)),this._quickFadeTiles.has(e)&&(this._fadeManager.completeFade(e),this._quickFadeTiles.delete(e)),r)return!0;let a=this._fadeManager.isFading(e);return!(t||!a)}dispose(){let e=this.tiles;this._fadeManager.completeAllFades(),null!==this.batchedMesh&&this._onBatchedMeshDispose(),e.removeEventListener("load-model",this._onLoadModel),e.removeEventListener("dispose-model",this._onDisposeModel),e.removeEventListener("add-camera",this._onAddCamera),e.removeEventListener("delete-camera",this._onDeleteCamera),e.removeEventListener("update-before",this._onUpdateBefore),e.removeEventListener("update-after",this._onUpdateAfter),e.removeEventListener("tile-visibility-change",this._onTileVisibilityChange),e.forEachLoadedModel(((e,t)=>{this._fadeManager.deleteObject(t)}))}forEachBatchIds(e,t){if(this.initBatchedMesh(),this.batchedMesh){let i=this.tiles.getPluginByName("BATCHED_TILES_PLUGIN"),r=i.getTileBatchIds(e);r&&r.forEach((e=>{t(e,this.batchedMesh,i)}))}}};new vn(new l.MeshBasicMaterial),new l.DataTexture(new Uint8Array([255,255,255,255]),1,1).needsUpdate=!0;const Jl="#include <opaque_fragment>",Xl=`\n float grayscale = dot(outgoingLight, vec3(0.299, 0.587, 0.114));\n outgoingLight = vec3(grayscale);\n ${Jl}\n`;function Ql(e){const t=e.onBeforeCompile;e.onBeforeCompile=i=>{t.call(e,i),i.fragmentShader=i.fragmentShader.replace(Jl,Xl)},e.needsUpdate=!0}class Yl extends y{constructor(e,i,a,s={}){var n,o,l;super(),n=this,l=null,(o=t).has(n)?r("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(n):o.set(n,l),this.scene=e,this.camera=i,this.renderer=a,this.tiles=null,this.destinationTileCamera=null,this.destinationTileResolution=0,this.previousAutoDisableRendererCulling=null,this.parseQueueTimer=null,this.dracoLoader=null,this.ownsDecoders=!s.decoders,this.decoders=s.decoders??new ts(a),this.apiToken=s.apiToken,this.googleMapsToken=s.googleMapsToken,this.googleMapsToken&&this.initTiles()}initTiles(){this.stopParseQueuePump(),this.tiles&&(this.setDestinationTilePrefetch(null),this.scene.remove(this.tiles.group),this.tiles.dispose(),this.tiles=null),this.dracoLoader=this.decoders.getDraco(),this.tiles=new _r,this.tiles.errorTarget=40,this.tiles.registerPlugin(new nn({apiToken:this.googleMapsToken,autoRefreshToken:!0})),this.tiles.registerPlugin(new Io),this.tiles.registerPlugin(new Lo),this.tiles.registerPlugin(new kl),this.tiles.registerPlugin(new Kl),this.tiles.registerPlugin(new Rl({dracoLoader:this.dracoLoader,autoDispose:!1})),this.scene.add(this.tiles.group),is(this.tiles,this.camera,this.renderer),this.attachTileLoadListener(),this.startParseQueuePump()}startParseQueuePump(){this.stopParseQueuePump(),this.parseQueueTimer=setInterval((()=>{var e;const t=null==(e=this.tiles)?void 0:e.parseQueue;(null==t?void 0:t.items.length)>0&&t.currJobs<t.maxJobs&&t.tryRunJobs()}),100)}stopParseQueuePump(){null!==this.parseQueueTimer&&clearInterval(this.parseQueueTimer),this.parseQueueTimer=null}attachTileLoadListener(){this.tiles.addEventListener("load-model",(({scene:e})=>{e.traverse((e=>{Array.isArray(e.material)?e.material.forEach(Ql):e.material&&Ql(e.material),e.layers.set(0)})),this.dispatchEvent({type:"globe-tile-loaded"})}))}setDestinationTilePrefetch(e){const i=(null==e?void 0:e.timeoutMs)??12e3;if(e&&(!Number.isFinite(i)||i<=0||i>3e4))return;if(this.clearDestinationTilePrefetch(),!e||!this.tiles)return;let r,a;try{r=l.validateGeodeticPosition(e.longitude,e.latitude,e.altitude,"Destination tile prefetch"),a=l.validateRotation(e.pitch,e.yaw,e.roll,"Destination tile prefetch rotation")}catch{return}if(128!==e.resolutionPixels&&256!==e.resolutionPixels)return;const s=(new l.Vector3).fromArray(l.geodeticToEcefPosition(r.longitude,r.latitude,r.altitude));if(s.distanceTo(this.camera.position)<.001)return;const n=new l.PerspectiveCamera(90,1,10,3e4);n.position.copy(s),n.quaternion.copy($s(r.longitude,r.latitude,a.pitch,a.yaw,a.roll)),n.updateMatrixWorld(!0),this.previousAutoDisableRendererCulling=this.tiles.autoDisableRendererCulling,this.tiles.autoDisableRendererCulling=!1,this.destinationTileCamera=n,this.destinationTileResolution=e.resolutionPixels,this.tiles.setCamera(n),this.updateDestinationTileResolution(),o(this,t,setTimeout((()=>this.clearDestinationTilePrefetch()),i))}updateDestinationTileResolution(){var e,t;if(!this.destinationTileCamera||!this.tiles)return;const i=(null==(e=this.renderer.xr)?void 0:e.isPresenting)?this.renderer.xr.getCamera().cameras[0]:null,r=(null==(t=null==i?void 0:i.viewport)?void 0:t.height)??this.renderer.getSize(new l.Vector2).height;if(!Number.isFinite(r)||r<=0)return;const a=Math.max(1,Math.min(this.destinationTileResolution,Math.floor(r)));this.tiles.setResolution(this.destinationTileCamera,a,a)}clearDestinationTilePrefetch(){null!==n(this,t)&&clearTimeout(n(this,t)),o(this,t,null),this.destinationTileCamera&&this.tiles&&(this.tiles.deleteCamera(this.destinationTileCamera),this.tiles.autoDisableRendererCulling=this.previousAutoDisableRendererCulling),this.destinationTileCamera=null,this.destinationTileResolution=0,this.previousAutoDisableRendererCulling=null}update(){if(!this.tiles)return;const e=this.tiles.parseQueue;(null==e?void 0:e.items.length)>0&&e.currJobs<e.maxJobs&&e.tryRunJobs(),is(this.tiles,this.camera,this.renderer),this.updateDestinationTileResolution(),this.tiles.errorTarget=20,this.tiles.update()}dispose(){this.stopParseQueuePump(),this.clearDestinationTilePrefetch(),this.tiles&&(this.scene.remove(this.tiles.group),this.tiles.dispose(),this.tiles=null),this.ownsDecoders&&this.decoders.dispose(),this.listeners={}}}t=new WeakMap;var Zl=Object.freeze({Linear:Object.freeze({None:function(e){return e},In:function(e){return e},Out:function(e){return e},InOut:function(e){return e}}),Quadratic:Object.freeze({In:function(e){return e*e},Out:function(e){return e*(2-e)},InOut:function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)}}),Cubic:Object.freeze({In:function(e){return e*e*e},Out:function(e){return--e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)}}),Quartic:Object.freeze({In:function(e){return e*e*e*e},Out:function(e){return 1- --e*e*e*e},InOut:function(e){return(e*=2)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2)}}),Quintic:Object.freeze({In:function(e){return e*e*e*e*e},Out:function(e){return--e*e*e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2)}}),Sinusoidal:Object.freeze({In:function(e){return 1-Math.sin((1-e)*Math.PI/2)},Out:function(e){return Math.sin(e*Math.PI/2)},InOut:function(e){return.5*(1-Math.sin(Math.PI*(.5-e)))}}),Exponential:Object.freeze({In:function(e){return 0===e?0:Math.pow(1024,e-1)},Out:function(e){return 1===e?1:1-Math.pow(2,-10*e)},InOut:function(e){return 0===e?0:1===e?1:(e*=2)<1?.5*Math.pow(1024,e-1):.5*(2-Math.pow(2,-10*(e-1)))}}),Circular:Object.freeze({In:function(e){return 1-Math.sqrt(1-e*e)},Out:function(e){return Math.sqrt(1- --e*e)},InOut:function(e){return(e*=2)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1)}}),Elastic:Object.freeze({In:function(e){return 0===e?0:1===e?1:-Math.pow(2,10*(e-1))*Math.sin(5*(e-1.1)*Math.PI)},Out:function(e){return 0===e?0:1===e?1:Math.pow(2,-10*e)*Math.sin(5*(e-.1)*Math.PI)+1},InOut:function(e){return 0===e?0:1===e?1:(e*=2)<1?-.5*Math.pow(2,10*(e-1))*Math.sin(5*(e-1.1)*Math.PI):.5*Math.pow(2,-10*(e-1))*Math.sin(5*(e-1.1)*Math.PI)+1}}),Back:Object.freeze({In:function(e){var t=1.70158;return 1===e?1:e*e*((t+1)*e-t)},Out:function(e){var t=1.70158;return 0===e?0:--e*e*((t+1)*e+t)+1},InOut:function(e){var t=2.5949095;return(e*=2)<1?e*e*((t+1)*e-t)*.5:.5*((e-=2)*e*((t+1)*e+t)+2)}}),Bounce:Object.freeze({In:function(e){return 1-Zl.Bounce.Out(1-e)},Out:function(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},InOut:function(e){return e<.5?.5*Zl.Bounce.In(2*e):.5*Zl.Bounce.Out(2*e-1)+.5}}),generatePow:function(e){return void 0===e&&(e=4),e=(e=e<Number.EPSILON?Number.EPSILON:e)>1e4?1e4:e,{In:function(t){return Math.pow(t,e)},Out:function(t){return 1-Math.pow(1-t,e)},InOut:function(t){return t<.5?Math.pow(2*t,e)/2:(1-Math.pow(2-2*t,e))/2+.5}}}}),$l=function(){return performance.now()},ec=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._tweens={},this._tweensAddedDuringUpdate={},this.add.apply(this,e)}return e.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map((function(t){return e._tweens[t]}))},e.prototype.removeAll=function(){this._tweens={}},e.prototype.add=function(){for(var e,t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];for(var r=0,a=t;r<a.length;r++){var s=a[r];null===(e=s._group)||void 0===e||e.remove(s),s._group=this,this._tweens[s.getId()]=s,this._tweensAddedDuringUpdate[s.getId()]=s}},e.prototype.remove=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var i=0,r=e;i<r.length;i++){var a=r[i];a._group=void 0,delete this._tweens[a.getId()],delete this._tweensAddedDuringUpdate[a.getId()]}},e.prototype.allStopped=function(){return this.getAll().every((function(e){return!e.isPlaying()}))},e.prototype.update=function(e,t){void 0===e&&(e=$l()),void 0===t&&(t=!0);var i=Object.keys(this._tweens);if(0!==i.length)for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var r=0;r<i.length;r++){var a=this._tweens[i[r]],s=!t;a&&!1===a.update(e,s)&&!t&&this.remove(a)}i=Object.keys(this._tweensAddedDuringUpdate)}},e}(),tc={Linear:function(e,t){var i=e.length-1,r=i*t,a=Math.floor(r),s=tc.Utils.Linear;return t<0?s(e[0],e[1],r):t>1?s(e[i],e[i-1],i-r):s(e[a],e[a+1>i?i:a+1],r-a)},Utils:{Linear:function(e,t,i){return(t-e)*i+e}}},ic=function(){function e(){}return e.nextId=function(){return e._nextId++},e._nextId=0,e}(),rc=new ec,ac=function(){function e(e,t){this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=Zl.Linear.None,this._interpolationFunction=tc.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=ic.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1,this._object=e,"object"==typeof t?(this._group=t,t.add(this)):!0===t&&(this._group=rc,rc.add(this))}return e.prototype.getId=function(){return this._id},e.prototype.isPlaying=function(){return this._isPlaying},e.prototype.isPaused=function(){return this._isPaused},e.prototype.getDuration=function(){return this._duration},e.prototype.to=function(e,t){if(void 0===t&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},e.prototype.duration=function(e){return void 0===e&&(e=1e3),this._duration=e<0?0:e,this},e.prototype.dynamic=function(e){return void 0===e&&(e=!1),this._isDynamic=e,this},e.prototype.start=function(e,t){if(void 0===e&&(e=$l()),void 0===t&&(t=!1),this._isPlaying)return this;if(this._repeat=this._initialRepeat,this._reversed)for(var i in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i];if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var r={};for(var a in this._valuesEnd)r[a]=this._valuesEnd[a];this._valuesEnd=r}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},e.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},e.prototype._setupProperties=function(e,t,i,r,a){for(var s in i){var n=e[s],o=Array.isArray(n),l=o?"array":typeof n,c=!o&&Array.isArray(i[s]);if("undefined"!==l&&"function"!==l){if(c){if(0===(g=i[s]).length)continue;for(var h=[n],d=0,u=g.length;d<u;d+=1){var p=this._handleRelativeValue(n,g[d]);if(isNaN(p)){c=!1;break}h.push(p)}c&&(i[s]=h)}if("object"!==l&&!o||!n||c)(void 0===t[s]||a)&&(t[s]=n),o||(t[s]*=1),r[s]=c?i[s].slice().reverse():t[s]||0;else{t[s]=o?[]:{};var m=n;for(var f in m)t[s][f]=m[f];r[s]=o?[]:{};var g=i[s];if(!this._isDynamic){var b={};for(var f in g)b[f]=g[f];i[s]=g=b}this._setupProperties(m,t[s],g,r[s],a)}}}},e.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},e.prototype.end=function(){return this._goToEnd=!0,this.update(this._startTime+this._duration),this},e.prototype.pause=function(e){return void 0===e&&(e=$l()),this._isPaused||!this._isPlaying||(this._isPaused=!0,this._pauseStart=e),this},e.prototype.resume=function(e){return void 0===e&&(e=$l()),this._isPaused&&this._isPlaying?(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this):this},e.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},e.prototype.group=function(e){return e?(e.add(this),this):this},e.prototype.remove=function(){var e;return null===(e=this._group)||void 0===e||e.remove(this),this},e.prototype.delay=function(e){return void 0===e&&(e=0),this._delayTime=e,this},e.prototype.repeat=function(e){return void 0===e&&(e=0),this._initialRepeat=e,this._repeat=e,this},e.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},e.prototype.yoyo=function(e){return void 0===e&&(e=!1),this._yoyo=e,this},e.prototype.easing=function(e){return void 0===e&&(e=Zl.Linear.None),this._easingFunction=e,this},e.prototype.interpolation=function(e){return void 0===e&&(e=tc.Linear),this._interpolationFunction=e,this},e.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},e.prototype.onStart=function(e){return this._onStartCallback=e,this},e.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},e.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},e.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},e.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},e.prototype.onStop=function(e){return this._onStopCallback=e,this},e.prototype.update=function(t,i){var r,a,s=this;if(void 0===t&&(t=$l()),void 0===i&&(i=e.autoStartOnUpdate),this._isPaused)return!0;if(!this._goToEnd&&!this._isPlaying){if(!i)return!1;this.start(t,!0)}if(this._goToEnd=!1,t<this._startTime)return!0;!1===this._onStartCallbackFired&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),!1===this._onEveryStartCallbackFired&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var n=t-this._startTime,o=this._duration+(null!==(r=this._repeatDelayTime)&&void 0!==r?r:this._delayTime),l=this._duration+this._repeat*o,c=function(){if(0===s._duration)return 1;if(n>l)return 1;var e=Math.trunc(n/o),t=n-e*o,i=Math.min(t/s._duration,1);return 0===i&&n===s._duration?1:i}(),h=this._easingFunction(c);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,h),this._onUpdateCallback&&this._onUpdateCallback(this._object,c),0===this._duration||n>=this._duration){if(this._repeat>0){var d=Math.min(Math.trunc((n-this._duration)/o)+1,this._repeat);for(a in isFinite(this._repeat)&&(this._repeat-=d),this._valuesStartRepeat)this._yoyo||"string"!=typeof this._valuesEnd[a]||(this._valuesStartRepeat[a]=this._valuesStartRepeat[a]+parseFloat(this._valuesEnd[a])),this._yoyo&&this._swapEndStartRepeatValues(a),this._valuesStart[a]=this._valuesStartRepeat[a];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=o*d,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var u=0,p=this._chainedTweens.length;u<p;u++)this._chainedTweens[u].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},e.prototype._updateProperties=function(e,t,i,r){for(var a in i)if(void 0!==t[a]){var s=t[a]||0,n=i[a],o=Array.isArray(e[a]),l=Array.isArray(n);!o&&l?e[a]=this._interpolationFunction(n,r):"object"==typeof n&&n?this._updateProperties(e[a],s,n,r):"number"==typeof(n=this._handleRelativeValue(s,n))&&(e[a]=s+(n-s)*r)}},e.prototype._handleRelativeValue=function(e,t){return"string"!=typeof t?t:"+"===t.charAt(0)||"-"===t.charAt(0)?e+parseFloat(t):parseFloat(t)},e.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],i=this._valuesEnd[e];this._valuesStartRepeat[e]="string"==typeof i?this._valuesStartRepeat[e]+parseFloat(i):this._valuesEnd[e],this._valuesEnd[e]=t},e.autoStartOnUpdate=!1,e}();ic.nextId;var sc=rc;sc.getAll.bind(sc),sc.removeAll.bind(sc),sc.add.bind(sc),sc.remove.bind(sc),sc.update.bind(sc);const nc={CESIUM:void 0,GOOGLEMAPS:void 0},oc=2e3;({Easing:Zl}).Easing.Quartic.InOut;class lc extends l.DataTextureLoader{constructor(e){super(e),this.type=l.HalfFloatType}parse(e){const t=function(e,t){switch(e){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(t||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(t||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(t||""));default:throw new Error("THREE.HDRLoader: Memory Error: "+(t||""))}},i=function(e,t,i){t=t||1024;let r=e.pos,a=-1,s=0,n="",o=String.fromCharCode.apply(null,new Uint16Array(e.subarray(r,r+128)));for(;0>(a=o.indexOf("\n"))&&s<t&&r<e.byteLength;)n+=o,s+=o.length,r+=128,o=String.fromCharCode.apply(null,new Uint16Array(e.subarray(r,r+128)));return-1<a&&(e.pos+=s+a+1,n+o.slice(0,a))},r=function(e,t,i,r){const a=e[t+3],s=Math.pow(2,a-128)/255;i[r+0]=e[t+0]*s,i[r+1]=e[t+1]*s,i[r+2]=e[t+2]*s,i[r+3]=1},a=function(e,t,i,r){const a=e[t+3],s=Math.pow(2,a-128)/255;i[r+0]=l.DataUtils.toHalfFloat(Math.min(e[t+0]*s,65504)),i[r+1]=l.DataUtils.toHalfFloat(Math.min(e[t+1]*s,65504)),i[r+2]=l.DataUtils.toHalfFloat(Math.min(e[t+2]*s,65504)),i[r+3]=l.DataUtils.toHalfFloat(1)},s=new Uint8Array(e);s.pos=0;const n=function(e){const r=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,a=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,s=/^\s*FORMAT=(\S+)\s*$/,n=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,o={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let l,c;for((e.pos>=e.byteLength||!(l=i(e)))&&t(1,"no header found"),(c=l.match(/^#\?(\S+)/))||t(3,"bad initial token"),o.valid|=1,o.programtype=c[1],o.string+=l+"\n";l=i(e),!1!==l;)if(o.string+=l+"\n","#"!==l.charAt(0)){if((c=l.match(r))&&(o.gamma=parseFloat(c[1])),(c=l.match(a))&&(o.exposure=parseFloat(c[1])),(c=l.match(s))&&(o.valid|=2,o.format=c[1]),(c=l.match(n))&&(o.valid|=4,o.height=parseInt(c[1],10),o.width=parseInt(c[2],10)),2&o.valid&&4&o.valid)break}else o.comments+=l+"\n";return 2&o.valid||t(3,"missing format specifier"),4&o.valid||t(3,"missing image size specifier"),o}(s),o=n.width,c=n.height,h=function(e,i,r){const a=i;if(a<8||a>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);a!==(e[2]<<8|e[3])&&t(3,"wrong scanline width");const s=new Uint8Array(4*i*r);s.length||t(4,"unable to allocate buffer space");let n=0,o=0;const l=4*a,c=new Uint8Array(4),h=new Uint8Array(l);let d=r;for(;d>0&&o<e.byteLength;){o+4>e.byteLength&&t(1),c[0]=e[o++],c[1]=e[o++],c[2]=e[o++],c[3]=e[o++],2==c[0]&&2==c[1]&&(c[2]<<8|c[3])==a||t(3,"bad rgbe scanline format");let i,r=0;for(;r<l&&o<e.byteLength;){i=e[o++];const a=i>128;if(a&&(i-=128),(0===i||r+i>l)&&t(3,"bad scanline data"),a){const t=e[o++];for(let e=0;e<i;e++)h[r++]=t}else h.set(e.subarray(o,o+i),r),r+=i,o+=i}const u=a;for(let e=0;e<u;e++){let t=0;s[n]=h[e+t],t+=a,s[n+1]=h[e+t],t+=a,s[n+2]=h[e+t],t+=a,s[n+3]=h[e+t],n+=4}d--}return s}(s.subarray(s.pos),o,c);let d,u,p;switch(this.type){case l.FloatType:p=h.length/4;const e=new Float32Array(4*p);for(let i=0;i<p;i++)r(h,4*i,e,4*i);d=e,u=l.FloatType;break;case l.HalfFloatType:p=h.length/4;const t=new Uint16Array(4*p);for(let i=0;i<p;i++)a(h,4*i,t,4*i);d=t,u=l.HalfFloatType;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:o,height:c,data:d,header:n.string,gamma:n.gamma,exposure:n.exposure,type:u,colorSpace:l.LinearSRGBColorSpace,minFilter:l.LinearFilter,magFilter:l.LinearFilter,generateMipmaps:!1,flipY:!0}}setDataType(e){return this.type=e,this}}class cc extends lc{constructor(e){super(e)}}function hc(e,t={}){return new Promise(((i,r)=>{const a=new cc;a.setDataType(t.floatType||l.HalfFloatType),a.load(e,(e=>{i(e)}),(e=>{}),(e=>{r(e)}))}))}const dc=e=>"number"==typeof e&&Number.isFinite(e)?e:null;function uc(e,t){const i=(new l.Vector3).subVectors(t,e).normalize(),r=e.clone().normalize();Math.abs(i.dot(r))>.99&&r.set(0,0,1);const a=(new l.Vector3).crossVectors(i,r).normalize();return(new l.Vector3).crossVectors(a,i).normalize()}class pc extends y{constructor(e){super(),this.camera=e,this.lookAt=new l.Vector3,this.cameraTween=null,this.lookAtTween=null,this.activeTransition=null,this.is2D=!1}animateTo(e,t,i=oc){return this.cancel(),new Promise((r=>{const a=this.camera.position.clone(),s=this.camera.quaternion.clone(),n=e.clone(),o=t.clone(),c={resolve:r,toPosition:n,toQuaternion:o};this.activeTransition=c;const h=n.clone().sub(a).length(),d=o.clone().multiply(s.clone().invert()),u=Math.acos(Math.min(1,d.w));if(i<=0||h<1&&u<1)this.camera.position.copy(n),this.camera.quaternion.copy(o),this.camera.updateMatrixWorld(!0),this.activeTransition=null,r(!0);else{const e=new l.Vector3(0,0,.25*-h).applyQuaternion(s).add(a),t=new l.Vector3(0,0,.25*-h).applyQuaternion(o).add(n),r=uc(a,e),d=uc(n,t);this.camera.up.copy(r),this.lookAt.copy(e),this.lookAtTween=new ac(this.lookAt).to(t,i).easing(Zl.Quartic.InOut).onComplete((()=>{this.lookAt.copy(t),this.lookAtTween=null,this.complete(c)})).start(),this.cameraTween=new ac(this.camera).to({position:n,up:d},i).easing(Zl.Quartic.InOut).onComplete((()=>{this.camera.position.copy(n),this.cameraTween=null,this.complete(c)})).start()}}))}complete(e){this.activeTransition!==e||this.cameraTween||this.lookAtTween||(this.camera.position.copy(e.toPosition),this.camera.quaternion.copy(e.toQuaternion),this.camera.updateMatrixWorld(!0),this.activeTransition=null,e.resolve(!0))}update(e){this.cameraUpTween&&this.cameraUpTween.update(e),this.cameraTween&&this.cameraTween.update(e),this.lookAtTween&&this.lookAtTween.update(e),(this.cameraTween||this.lookAtTween)&&this.camera.lookAt(this.lookAt)}cancel(){const e=this.activeTransition;this.activeTransition=null,this.cameraTween&&(this.cameraTween.stop(),this.cameraTween=null),this.lookAtTween&&(this.lookAtTween.stop(),this.lookAtTween=null),this.cameraUpTween&&(this.cameraUpTween.stop(),this.cameraUpTween=null),null==e||e.resolve(!1)}}class mc extends l.Mesh{constructor(){const e=new l.ShaderMaterial({name:"SkyMaterial",uniforms:{turbidity:{value:5},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.5},sunPosition:{value:new l.Vector3},up:{value:new l.Vector3(0,1,0)},surfaceUp:{value:new l.Vector3(0,1,0)}},vertexShader:"uniform vec3 sunPosition;uniform float rayleigh;uniform float turbidity;uniform float mieCoefficient;uniform vec3 up;varying vec3 vWorldPosition;varying vec3 vSunDirection;varying float vSunfade;varying vec3 vBetaR;varying vec3 vBetaM;varying float vSunE;const float e=2.71828182845904523536028747135266249775724709369995957;const float pi=3.141592653589793238462643383279502884197169;const vec3 lambda=vec3(680E-9,550E-9,450E-9);const vec3 totalRayleigh=vec3(5.804542996261093E-6,1.3562911419845635E-5,3.0265902468824876E-5);const float v=4.0;const vec3 K=vec3(0.686,0.678,0.666);const vec3 MieConst=vec3(1.8399918514433978E14,2.7798023919660528E14,4.0790479543861094E14);const float cutoffAngle=1.6110731556870734;const float steepness=1.5;const float EE=1000.0;float sunIntensity(float zenithAngleCos){zenithAngleCos=clamp(zenithAngleCos,-1.0,1.0);return EE*max(0.0,1.0-pow(e,-((cutoffAngle-acos(zenithAngleCos))/steepness)));}vec3 totalMie(float T){float c=(0.2*T)*10E-18;return 0.434*c*MieConst;}void main(){vec4 worldPosition=modelMatrix*vec4(position,1.0);vWorldPosition=worldPosition.xyz;gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.0);gl_Position.z=gl_Position.w;vSunDirection=normalize(sunPosition);vSunE=sunIntensity(dot(vSunDirection,up));vSunfade=1.0-clamp(1.0-exp((sunPosition.y/450000.0)),0.0,1.0);float rayleighCoefficient=rayleigh-(1.0*(1.0-vSunfade));vBetaR=totalRayleigh*rayleighCoefficient;vBetaM=totalMie(turbidity)*mieCoefficient;}",fragmentShader:"varying vec3 vWorldPosition;varying vec3 vSunDirection;varying float vSunfade;varying vec3 vBetaR;varying vec3 vBetaM;varying float vSunE;uniform float mieDirectionalG;uniform vec3 up;uniform vec3 surfaceUp;const float pi=3.141592653589793238462643383279502884197169;const float n=1.0003;const float N=2.545E25;const float rayleighZenithLength=8.4E3;const float mieZenithLength=1.25E3;const float sunAngularDiameterCos=0.999956676946448443553574619906976478926848692873900859324;const float THREE_OVER_SIXTEENPI=0.05968310365946075;const float ONE_OVER_FOURPI=0.07957747154594767;float rayleighPhase(float cosTheta){return THREE_OVER_SIXTEENPI*(1.0+pow(cosTheta,2.0));}float hgPhase(float cosTheta,float g){float g2=pow(g,2.0);float inverse=1.0/pow(1.0-2.0*g*cosTheta+g2,1.5);return ONE_OVER_FOURPI*((1.0-g2)*inverse);}void main(){vec3 direction=normalize(vWorldPosition-cameraPosition);float zenithAngle=acos(max(0.0,dot(surfaceUp,direction)));float inverse=1.0/(cos(zenithAngle)+0.15*pow(93.885-((zenithAngle*180.0)/pi),-1.253));float sR=rayleighZenithLength*inverse;float sM=mieZenithLength*inverse;vec3 Fex=exp(-(vBetaR*sR+vBetaM*sM));float cosTheta=dot(direction,vSunDirection);float rPhase=rayleighPhase(cosTheta*0.5+0.5);vec3 betaRTheta=vBetaR*rPhase;float mPhase=hgPhase(cosTheta,mieDirectionalG);vec3 betaMTheta=vBetaM*mPhase;vec3 Lin=pow(vSunE*((betaRTheta+betaMTheta)/(vBetaR+vBetaM))*(1.0-Fex),vec3(1.5));Lin*=mix(vec3(1.0),pow(vSunE*((betaRTheta+betaMTheta)/(vBetaR+vBetaM))*Fex,vec3(1.0/2.0)),clamp(pow(1.0-dot(up,vSunDirection),5.0),0.0,1.0));float theta=acos(direction.y);float phi=atan(direction.z,direction.x);vec2 uv=vec2(phi,theta)/vec2(2.0*pi,pi)+vec2(0.5,0.0);vec3 L0=vec3(0.1)*Fex;float sundisk=smoothstep(sunAngularDiameterCos,sunAngularDiameterCos+0.00002,cosTheta);L0+=(vSunE*19000.0*Fex)*sundisk;vec3 texColor=(Lin+L0)*0.04+vec3(0.0,0.0003,0.00075);vec3 retColor=pow(texColor,vec3(1.0/(1.2+(1.2*vSunfade))));gl_FragColor=vec4(retColor,1.0);\n#include <tonemapping_fragment>\n#include <colorspace_fragment>\n}",side:l.BackSide,depthWrite:!1});super(new l.BoxGeometry(1,1,1),e),this.isSky=!0,this.type="Sky",this.material=e}setSurfaceUp(e){this.material.uniforms.surfaceUp.value.copy(e)}}class fc extends l.Object3D{constructor(){super(),this.type="ContentLayer",this.isContentLayer=!0,this.contentLayerId=null,this.labels=new Set}setLabels(e){this.labels.clear();for(let t=0;t<e.length;t++)this.labels.add(e[t])}setEnabled(e){this.visible=e}update(){}dispose(){super.dispose()}disposeObjectResources(e=this){e.traverse((e=>{var t,i,r,a,s;null==(i=null==(t=e.geometry)?void 0:t.dispose)||i.call(t);const n=Array.isArray(e.material)?e.material:e.material?[e.material]:[];for(const o of n){for(const e of Object.values(o))(null==e?void 0:e.isTexture)&&(null==(r=e.dispose)||r.call(e));null==(a=o.dispose)||a.call(o)}e!==this&&(null==(s=e.dispose)||s.call(e))}))}}class gc extends fc{constructor(e,t={},i={}){super(),this.type="TilesLayer",this.isTilesLayer=!0,this.disposed=!1;const r=(null==t?void 0:t.renderOrder)??0,a=(null==t?void 0:t.implicit)??!1,s="overlay"==(null==t?void 0:t.blendeMode),n=l.normalizeLayerOffset(t.offset,"3D Tiles offset"),o=0!==n.lon||0!==n.lat||0!==n.alt;let c=!1;this.firstSet=(null==t?void 0:t.firstSet)??null,this.camera=(null==t?void 0:t.camera)??null,this.renderer=(null==t?void 0:t.renderer)??null,this.ownsDecoders=!t.decoders,this.decoders=t.decoders??new ts(this.renderer),this.dracoLoader=this.decoders.getDraco(),this.ktx2loader=this.decoders.getKTX2(),this.layers.set(r);const h=new _r(e);e.startsWith("http")||h.registerPlugin(new Po({apiToken:nc.CESIUM,assetId:e,autoRefreshToken:!0})),a&&h.registerPlugin(new un),h.registerPlugin(new Rl({rtc:!0,dracoLoader:this.dracoLoader,ktxLoader:this.ktx2loader,autoDispose:!1})),h.errorTarget=20,this.firstSet&&(h.lruCache=this.firstSet.lruCache,h.downloadQueue=this.firstSet.downloadQueue,h.parseQueue=this.firstSet.parseQueue,h.processNodeQueue=this.firstSet.processNodeQueue),is(h,this.camera,this.renderer),h.addEventListener("load-model",(e=>{var t;if(!this.disposed){if(o&&!c)try{const e=new l.Sphere;if(!h.getBoundingSphere(e))throw new Error("3D Tiles offset requires root bounds");const t=l.ecefToGeodeticPosition(...e.center.toArray()),i=l.geodeticOffsetToEcefDelta(t,n);h.group.position.add((new l.Vector3).fromArray(i)),c=!0}catch(r){null==(t=i.onError)||t.call(i,r instanceof Error?r:new Error(String(r)))}e.scene.traverse((e=>{e.layers.mask=this.layers.mask,e.material&&(e.material.isPointsMaterial?(e.material.sizeAttenuation=!0,e.material.size=.2,e.material.map=(new l.TextureLoader).load("/assets/viewer/dot.png",(e=>{})),e.material.alphaTest=.1,e.material.transparent=!0,e.material.onBeforeCompile=e=>{e.vertexShader="uniform float size;uniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\nvarying vec2 vUv;uniform mat3 uvTransform;\n#endif\nvoid main(){\n#ifdef USE_POINTS_UV\nvUv=(uvTransform*vec3(uv,1)).xy;\n#endif\n#include <color_vertex>\n#include <morphinstance_vertex>\n#include <morphcolor_vertex>\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <project_vertex>\ngl_PointSize=size;bool isPerspective=isPerspectiveMatrix(projectionMatrix);if(isPerspective){gl_PointSize*=(scale/-mvPosition.z);gl_PointSize=max(gl_PointSize,5.0);}\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\n#include <worldpos_vertex>\n#include <fog_vertex>\n}",e.fragmentShader="uniform vec3 diffuse;uniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main(){vec4 diffuseColor=vec4(diffuse,opacity);\n#include <clipping_planes_fragment>\nvec3 outgoingLight=vec3(0.0);\n#include <logdepthbuf_fragment>\n#include <map_particle_fragment>\n#include <color_fragment>\n#include <alphatest_fragment>\n#include <alphahash_fragment>\noutgoingLight=diffuseColor.rgb;\n#include <opaque_fragment>\n#include <tonemapping_fragment>\n#include <colorspace_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n}"}):(e.material.onBeforeCompile=e=>{s&&(e.vertexShader="#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main(){\n#include <uv_vertex>\n#include <color_vertex>\n#include <morphinstance_vertex>\n#include <morphcolor_vertex>\n#include <batching_vertex>\n#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinbase_vertex>\n#include <skinnormal_vertex>\n#include <defaultnormal_vertex>\n#endif\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <project_vertex>\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\n#include <worldpos_vertex>\n#include <envmap_vertex>\n#include <fog_vertex>\n}",e.fragmentShader="uniform vec3 diffuse;uniform float opacity;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nuniform float overlayMode;void main(){vec4 diffuseColor=vec4(diffuse,opacity);\n#include <clipping_planes_fragment>\n#include <logdepthbuf_fragment>\n#include <map_fragment>\n#include <color_fragment>\n#include <alphamap_fragment>\n#include <alphatest_fragment>\n#include <alphahash_fragment>\n#include <specularmap_fragment>\nReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));\n#ifdef USE_LIGHTMAP\nvec4 lightMapTexel=texture2D(lightMap,vLightMapUv);reflectedLight.indirectDiffuse+=lightMapTexel.rgb*lightMapIntensity*RECIPROCAL_PI;\n#else\nreflectedLight.indirectDiffuse+=vec3(1.0);\n#endif\n#include <aomap_fragment>\nreflectedLight.indirectDiffuse*=diffuseColor.rgb;vec3 outgoingLight=reflectedLight.indirectDiffuse;\n#include <envmap_fragment>\n#include <opaque_fragment>\n#include <tonemapping_fragment>\n#include <colorspace_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\ngl_FragColor=mix(gl_FragColor,vec4(gl_FragColor.rgb,gl_FragColor.a*pow(gl_FragColor.b,0.667)),overlayMode);}",e.uniforms.overlayMode={value:s?1:0})},s&&(e.material.transparent=!0,e.material.alphaTest=.1)))}))}})),this.tiles=h,this.add(h.group)}update(){super.update(),this.visible&&(is(this.tiles,this.camera,this.renderer),this.tiles.update())}dispose(){this.disposed||(this.disposed=!0,super.dispose(),this.tiles&&(this.tiles.dispose(),this.remove(this.tiles.group),this.tiles=null),this.ownsDecoders&&this.decoders.dispose())}}var bc=function(){var e=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if("object"!=typeof WebAssembly)return{supported:!1};var i,r=WebAssembly.validate(e)?s("b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuixkbbebeeddddilve9Weeeviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WbwY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbDl79IV9Rbqq:W9Dklbzik94evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaeai86b:q:W:cjbaecitab8Piw83i:q:G:cjbaecefgecjd9hmbkk:JBl8Aud97dur978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaialfgxar9RhodnadTgmmbavaoad;8qbbkaicefhPcj;abad9Uc;WFbGcjdadca0EhsdndndnadTmbaoadfhzcbhHinaeaH9nmdaxaP9RaD6miabaHad2fhOaPaDfhAasaeaH9RaHasfae6EgCcsfgocl4cifcd4hXavcj;cbfaoc9WGgQcetfhLavcj;cbfaQci2fhKavcj;cbfaQfhYcbh8Aaoc;ab6hEincbh3dnawTmbaPa8Acd4fRbbh3kcbh5avcj;cbfh8Eindndndndna3a5cet4ciGgoc9:fPdebdkaxaA9RaQ6mwdnaQTmbavcj;cbfa5aQ2faAaQ;8qbbkaAaCfhAxdkaQTmeavcj;cbfa5aQ2fcbaQ;8kbxekaxaA9RaX6moaoclVcbawEhraAaXfhocbhidnaEmbaxao9Rc;Gb6mbcbhlina8EalfhidndndndndndnaAalco4fRbbgqciGarfPDbedibledibkaipxbbbbbbbbbbbbbbbbpklbxlkaiaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaiaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaiaopbbbpklbaoczfhoxekaiaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqcd4ciGarfPDbedibledibkaiczfpxbbbbbbbbbbbbbbbbpklbxlkaiczfaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaiczfaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaiczfaopbbbpklbaoczfhoxekaiczfaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqcl4ciGarfPDbedibledibkaicafpxbbbbbbbbbbbbbbbbpklbxlkaicafaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaicafaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaicafaopbbbpklbaoczfhoxekaicafaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqco4arfPDbedibledibkaic8Wfpxbbbbbbbbbbbbbbbbpklbxlkaic8Wfaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbaiaoclffaqRb:q:W:cjbfhoxikaic8Wfaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbaiaocwffaqRb:q:W:cjbfhoxdkaic8Wfaopbbbpklbaoczfhoxekaic8WfaopbbdaoRbbgicitpbi:q:G:cjbaiRb:q:W:cjbgipsaoRbegqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbaiaocdffaqRb:q:W:cjbfhokalc;abfhialcjefaQ0meaihlaxao9Rc;Fb0mbkkdnaiaQ9pmbaici4hlinaxao9RcK6mwa8EaifhqdndndndndndnaAaico4fRbbalcoG4ciGarfPDbedibledibkaqpxbbbbbbbbbbbbbbbbpkbbxlkaqaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spkbbahaoclffagRb:q:W:cjbfhoxikaqaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spkbbahaocwffagRb:q:W:cjbfhoxdkaqaopbbbpkbbaoczfhoxekaqaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpkbbahaocdffagRb:q:W:cjbfhokalcdfhlaiczfgiaQ6mbkkaohAaoTmoka8EaQfh8Ea5cefg5cl9hmbkdndndndnawTmbaza8Acd4fRbbglciGPlbedwbkaQTmdavcjdfa8Afhlava8Afpbdbh8Jcbhoinalavcj;cbfaofpblbg8KaYaofpblbg8LpmbzeHdOiAlCvXoQrLg8MaLaofpblbg8NaKaofpblbgypmbzeHdOiAlCvXoQrLg8PpmbezHdiOAlvCXorQLg8Fcep9Ta8Fpxeeeeeeeeeeeeeeeegap9op9Hp9rg8Fa8Jp9Ug8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9Abbbaladfgla8Ja8Ma8PpmwDKYqk8AExm35Ps8E8Fg8Fcep9Ta8Faap9op9Hp9rg8Fp9Ug8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9Abbbaladfgla8Ja8Ka8LpmwKDYq8AkEx3m5P8Es8Fg8Ka8NaypmwKDYq8AkEx3m5P8Es8Fg8LpmbezHdiOAlvCXorQLg8Fcep9Ta8Faap9op9Hp9rg8Fp9Ug8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9Abbbaladfgla8Ja8Ka8LpmwDKYqk8AExm35Ps8E8Fg8Fcep9Ta8Faap9op9Hp9rg8Fp9Ugap9Abbbaladfglaaa8Fa8Fpmlvorlvorlvorlvorp9Ugap9Abbbaladfglaaa8Fa8FpmwDqkwDqkwDqkwDqkp9Ugap9Abbbaladfglaaa8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9AbbbaladfhlaoczfgoaQ6mbxikkaQTmeavcjdfa8Afhlava8Afpbdbh8Jcbhoinalavcj;cbfaofpblbg8KaYaofpblbg8LpmbzeHdOiAlCvXoQrLg8MaLaofpblbg8NaKaofpblbgypmbzeHdOiAlCvXoQrLg8PpmbezHdiOAlvCXorQLg8Fcep:nea8Fpxebebebebebebebebgap9op:bep9rg8Fa8Jp:oeg8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9Abbbaladfgla8Ja8Ma8PpmwDKYqk8AExm35Ps8E8Fg8Fcep:nea8Faap9op:bep9rg8Fp:oeg8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9Abbbaladfgla8Ja8Ka8LpmwKDYq8AkEx3m5P8Es8Fg8Ka8NaypmwKDYq8AkEx3m5P8Es8Fg8LpmbezHdiOAlvCXorQLg8Fcep:nea8Faap9op:bep9rg8Fp:oeg8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9Abbbaladfgla8Ja8Ka8LpmwDKYqk8AExm35Ps8E8Fg8Fcep:nea8Faap9op:bep9rg8Fp:oegap9Abbbaladfglaaa8Fa8Fpmlvorlvorlvorlvorp:oegap9Abbbaladfglaaa8Fa8FpmwDqkwDqkwDqkwDqkp:oegap9Abbbaladfglaaa8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9AbbbaladfhlaoczfgoaQ6mbxdkkaQTmbcbhocbalcl4gl9Rc8FGhiavcjdfa8Afhrava8Afpbdbhainaravcj;cbfaofpblbg8JaYaofpblbg8KpmbzeHdOiAlCvXoQrLg8LaLaofpblbg8MaKaofpblbg8NpmbzeHdOiAlCvXoQrLgypmbezHdiOAlvCXorQLg8Faip:Rea8Falp:Tep9qg8Faap9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8LaypmwDKYqk8AExm35Ps8E8Fg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8Ja8KpmwKDYq8AkEx3m5P8Es8Fg8Ja8Ma8NpmwKDYq8AkEx3m5P8Es8Fg8KpmbezHdiOAlvCXorQLg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8Ja8KpmwDKYqk8AExm35Ps8E8Fg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9AbbbaradfhraoczfgoaQ6mbkka8Aclfg8Aad6mbkdnaCad2goTmbaOavcjdfao;8qbbkdnammbavavcjdfaCcufad2fad;8qbbkaCaHfhHc9:hoaAhPaAmbxlkkaeTmbaDalfhrcbhocuhlinaralaD9RglfaD6mdasaeao9Raoasfae6Eaofgoae6mbkaial9RhPkcbc99axaP9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaokwbz:bjjjbkNsezu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbavaiaqaDcsGfRbbgscl4gP9RcsGcdtfydbaxcefgOaPEhDavaias9RcsGcdtfydbaOaPTgzfgOascsGgPEhsaPThPdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiazfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaPfhiaOaPfhxxekaxcbalRbbgsEgHaDc;:eSgDfhOascsGhAdndnascl4gCmbaOcefhzxekaOhzavaiaC9RcsGcdtfydbhOkdndnaAmbazcefhxxekazhxavaias9RcsGcdtfydbhzkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhHascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaHhDxekaDcefhDkasce4cbasceG9R7amfgmhHkdndnaCcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhOaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkaOhsxekascefhskaPce4cbaPceG9R7amfgmhOkdndnaAcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhzaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkazhlxekalcefhlkaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabarcetfgDaH87ebaDclfaz87ebaDcdfaO87ebxekabarcdtfgDaHBdbaDcwfazBdbaDclfaOBdbkavc;abfaocitfgDaOBdbaDaHBdlavaicdtfaHBdbavc;abfaocefcsGcitfgDazBdbaDaOBdlavaicefgicsGcdtfaOBdbavc;abfaocdfcsGcitfgDaHBdbaDazBdlavaiaCTaCcsSVfgicsGcdtfazBdbaiaATaAcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk;Toio97eue97aec98Ghedndnadcl9hmbaeTmecbhdinababpbbbgicKp:RecKp:Sep;6eglaicwp:RecKp:Sep;6ealp;Geaiczp:RecKp:Sep;6egvp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgwp9op9rp;Keglpxbb;:9cbb;:9cbb;:9cbb;:9calalp;Meaoaop;Meavaravawp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFbbbFbbbFbbbFbbbp9oaipxbbbFbbbFbbbFbbbFp9op9qalavp;Mearp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaoavp;Mearp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgDaDpbbbgipxbbbbbbFFbbbbbbFFgwp9oabpbbbgoaipmbediwDqkzHOAKY8AEgvczp:Reczp:Sep;6eglaoaipmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eavczp:Sep;6egvp;Gealp;Gep;Kep;Legipxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgqp9op9rp;Keglpxb;:FSb;:FSb;:FSb;:FSalalp;Meaiaip;Meavaravaqp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbp9oaiavp;Mearp;Keczp:Rep9qgialavp;Mearp;KepxFFbbFFbbFFbbFFbbp9oglpmwDKYqk8AExm35Ps8E8Fp9qpkbbabaoawp9oaialpmbezHdiOAlvCXorQLp9qpkbbabcafhbadclfgdae6mbkkk;2ileue97euo97dnaec98GgiTmbcbheinabcKfpx:ji:1S:ji:1S:ji:1S:ji:1SabpbbbglabczfgvpbbbgopmlvorxmPsCXQL358E8Fgrczp:Segwpxibbbibbbibbbibbbp9qp;6egDp;NegqaDaDp;MegDaDp;KealaopmbediwDqkzHOAKY8AEgDczp:Reczp:Sep;6eglalp;MeaDczp:Sep;6egoaop;Mearczp:Reczp:Sep;6egrarp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gDp;KepxFFbbFFbbFFbbFFbbgkp9oaqaop;MeaDp;Keczp:Rep9qgoaqalp;MeaDp;Keakp9oaqarp;MeaDp;Keczp:Rep9qgDpmwDKYqk8AExm35Ps8E8Fglp5eawclp:RegqpEi:T:j83ibavalp5baqpEd:T:j83ibabcwfaoaDpmbezHdiOAlvCXorQLgDp5eaqpEe:T:j83ibabaDp5baqpEb:T:j83ibabcafhbaeclfgeai6mbkkkuee97dnadcd4ae2c98GgeTmbcbhdinababpbbbgicwp:Recwp:Sep;6eaicep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepkbbabczfhbadclfgdae6mbkkk:Sodw97euaec98Ghedndnadcl9hmbaeTmecbhdinabpxbbuJbbuJbbuJbbuJabpbbbgicKp:TeglaicYp:Tep9qgvcdp:Teavp9qgvclp:Teavp9qgop;6ep;Negvaicwp:RecKp:SegraipxFbbbFbbbFbbbFbbbgwp9ogDp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oavaDarp:Xeaiczp:RecKp:Segip:Uep;6ep;Meaqp;Keawp9op9qavaDaraip:Uep:Xep;6ep;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qavaoalcep:Rep9oalpxebbbebbbebbbebbbp9op9qp;6ep;Meaqp;KecKp:Rep9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgkpxbFu9hbFu9hbFu9hbFu9habpbbbglakpbbbgrpmlvorxmPsCXQL358E8Fgvczp:TegqavcHp:Tep9qgicdp:Teaip9qgiclp:Teaip9qgicwp:Teaip9qgop;6ep;NegialarpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbglp9ograDczp:Segwp:Ueavczp:Reczp:SegDp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gvp;Kealp9oaiarawaDp:Uep:Xep;6ep;Meavp;Keczp:Rep9qgwaiaoaqcep:Rep9oaqpxebbbebbbebbbebbbp9op9qp;6ep;Meavp;Keczp:ReaiaDarp:Uep;6ep;Meavp;Kealp9op9qgipmwDKYqk8AExm35Ps8E8FpkbbabawaipmbezHdiOAlvCXorQLpkbbabcafhbadclfgdae6mbkkk9teiucbcbydj:G:cjbgeabcifc98GfgbBdj:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkxebcj:Gdklz:zbb"):s("b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuixkbeeeddddillviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WboY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbrl79IV9Rbwq:VZkdbk:XYi5ud9:du8Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxcj;abad9Uc;WFbGcjdadca0EhmaialfgPar9Rgoadfhsavaoadz:jjjjbgzceVhHcbhOdndninaeaO9nmeaPax9RaD6mdamaeaO9RaOamfgoae6EgAcsfglc9WGhCabaOad2fhXaAcethQaxaDfhiaOaeaoaeao6E9RhLalcl4cifcd4hKazcj;cbfaAfhYcbh8AazcjdfhEaHh3incbh5dnawTmbaxa8Acd4fRbbh5kcbh8Eazcj;cbfhqinaih8Fdndndndna5a8Ecet4ciGgoc9:fPdebdkaPa8F9RaA6mrazcj;cbfa8EaA2fa8FaAz:jjjjb8Aa8FaAfhixdkazcj;cbfa8EaA2fcbaAz:kjjjb8Aa8FhixekaPa8F9RaK6mva8FaKfhidnaCTmbaPai9RcK6mbaocdtc:q:G:cjbfcj:G:cjbawEhaczhrcbhlinargoc9Wfghaqfhrdndndndndndnaaa8Fahco4fRbbalcoG4ciGcdtfydbPDbedvivvvlvkar9cb83bwar9cb83bbxlkarcbaiRbdai8Xbb9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbaqaofgrcGfcbaicdfa8J9c8N1:NfghRbbag9cjjjjjw:dg8J9qE86bbarcVfcbaha8J9c8M1:NfghRbbag9cjjjjjl:dg8J9qE86bbarc7fcbaha8J9c8L1:NfghRbbag9cjjjjjd:dg8J9qE86bbarctfcbaha8J9c8K1:NfghRbbag9cjjjjje:dg8J9qE86bbarc91fcbaha8J9c8J1:NfghRbbag9cjjjj;ab:dg8J9qE86bbarc4fcbaha8J9cg1:NfghRbbag9cjjjja:dg8J9qE86bbarc93fcbaha8J9ch1:NfghRbbag9cjjjjz:dgg9qE86bbarc94fcbahag9ca1:NfghRbbai8Xbe9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbarc95fcbaha8J9c8N1:NfgiRbbag9cjjjjjw:dg8J9qE86bbarc96fcbaia8J9c8M1:NfgiRbbag9cjjjjjl:dg8J9qE86bbarc97fcbaia8J9c8L1:NfgiRbbag9cjjjjjd:dg8J9qE86bbarc98fcbaia8J9c8K1:NfgiRbbag9cjjjjje:dg8J9qE86bbarc99fcbaia8J9c8J1:NfgiRbbag9cjjjj;ab:dg8J9qE86bbarc9:fcbaia8J9cg1:NfgiRbbag9cjjjja:dg8J9qE86bbarcufcbaia8J9ch1:NfgiRbbag9cjjjjz:dgg9qE86bbaiag9ca1:NfhixikaraiRblaiRbbghco4g8Ka8KciSg8KE86bbaqaofgrcGfaiclfa8Kfg8KRbbahcl4ciGg8La8LciSg8LE86bbarcVfa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc7fa8Ka8Lfg8KRbbahciGghahciSghE86bbarctfa8Kahfg8KRbbaiRbeghco4g8La8LciSg8LE86bbarc91fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc4fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc93fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc94fa8Kahfg8KRbbaiRbdghco4g8La8LciSg8LE86bbarc95fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc96fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc97fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc98fa8KahfghRbbaiRbigico4g8Ka8KciSg8KE86bbarc99faha8KfghRbbaicl4ciGg8Ka8KciSg8KE86bbarc9:faha8KfghRbbaicd4ciGg8Ka8KciSg8KE86bbarcufaha8KfgrRbbaiciGgiaiciSgiE86bbaraifhixdkaraiRbwaiRbbghcl4g8Ka8KcsSg8KE86bbaqaofgrcGfaicwfa8Kfg8KRbbahcsGghahcsSghE86bbarcVfa8KahfghRbbaiRbeg8Kcl4g8La8LcsSg8LE86bbarc7faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarctfaha8KfghRbbaiRbdg8Kcl4g8La8LcsSg8LE86bbarc91faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc4faha8KfghRbbaiRbig8Kcl4g8La8LcsSg8LE86bbarc93faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc94faha8KfghRbbaiRblg8Kcl4g8La8LcsSg8LE86bbarc95faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc96faha8KfghRbbaiRbvg8Kcl4g8La8LcsSg8LE86bbarc97faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc98faha8KfghRbbaiRbog8Kcl4g8La8LcsSg8LE86bbarc99faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc9:faha8KfghRbbaiRbrgicl4g8Ka8KcsSg8KE86bbarcufaha8KfgrRbbaicsGgiaicsSgiE86bbaraifhixekarai8Pbw83bwarai8Pbb83bbaiczfhikdnaoaC9pmbalcdfhlaoczfhraPai9RcL0mekkaoaC6moaimexokaCmva8FTmvkaqaAfhqa8Ecefg8Ecl9hmbkdndndndnawTmbasa8Acd4fRbbgociGPlbedrbkaATmdaza8Afh8Fazcj;cbfhhcbh8EaEhaina8FRbbhraahocbhlinaoahalfRbbgqce4cbaqceG9R7arfgr86bbaoadfhoaAalcefgl9hmbkaacefhaa8Fcefh8FahaAfhha8Ecefg8Ecl9hmbxikkaATmeaza8Afhaazcj;cbfhhcbhoceh8EaYh8FinaEaofhlaa8Vbbhrcbhoinala8FaofRbbcwtahaofRbbgqVc;:FiGce4cbaqceG9R7arfgr87bbaladfhlaLaocefgofmbka8FaQfh8FcdhoaacdfhaahaQfhha8EceGhlcbh8EalmbxdkkaATmbaocl4h8Eaza8AfRbbhqcwhoa3hlinalRbbaotaqVhqalcefhlaocwfgoca9hmbkcbhhaEh8FaYhainazcj;cbfahfRbbhrcwhoaahlinalRbbaotarVhralaAfhlaocwfgoca9hmbkara8E94aq7hqcbhoa8Fhlinalaqao486bbalcefhlaocwfgoca9hmbka8Fadfh8FaacefhaahcefghaA9hmbkkaEclfhEa3clfh3a8Aclfg8Aad6mbkaXazcjdfaAad2z:jjjjb8AazazcjdfaAcufad2fadz:jjjjb8AaAaOfhOaihxaimbkc9:hoxdkcbc99aPax9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaok:ysezu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:kjjjb8Aav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbavaiaqaDcsGfRbbgscl4gP9RcsGcdtfydbaxcefgOaPEhDavaias9RcsGcdtfydbaOaPTgzfgOascsGgPEhsaPThPdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiazfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaPfhiaOaPfhxxekaxcbalRbbgsEgHaDc;:eSgDfhOascsGhAdndnascl4gCmbaOcefhzxekaOhzavaiaC9RcsGcdtfydbhOkdndnaAmbazcefhxxekazhxavaias9RcsGcdtfydbhzkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhHascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaHhDxekaDcefhDkasce4cbasceG9R7amfgmhHkdndnaCcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhOaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkaOhsxekascefhskaPce4cbaPceG9R7amfgmhOkdndnaAcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhzaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkazhlxekalcefhlkaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabarcetfgDaH87ebaDclfaz87ebaDcdfaO87ebxekabarcdtfgDaHBdbaDcwfazBdbaDclfaOBdbkavc;abfaocitfgDaOBdbaDaHBdlavaicdtfaHBdbavc;abfaocefcsGcitfgDazBdbaDaOBdlavaicefgicsGcdtfaOBdbavc;abfaocdfcsGcitfgDaHBdbaDazBdlavaiaCTaCcsSVfgicsGcdtfazBdbaiaATaAcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk:4ioiue99dud99dud99dnaeTmbcbhiabhlindndnal8Uebgv:YgoJ:ji:1Salcof8UebgrciVgw:Y:vgDNJbbbZJbbb:;avcu9kEMgq:lJbbb9p9DTmbaq:Ohkxekcjjjj94hkkalclf8Uebhvalcdf8UebhxalarcefciGcetfak87ebdndnax:YgqaDNJbbbZJbbb:;axcu9kEMgm:lJbbb9p9DTmbam:Ohxxekcjjjj94hxkabaiarciGgkfcd7cetfax87ebdndnav:YgmaDNJbbbZJbbb:;avcu9kEMgP:lJbbb9p9DTmbaP:Ohvxekcjjjj94hvkalarcufciGcetfav87ebdndnawaw2:ZgPaPMaoaoN:taqaqN:tamamN:tgoJbbbbaoJbbbb9GE:raDNJbbbZMgD:lJbbb9p9DTmbaD:Ohrxekcjjjj94hrkalakcetfar87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2gdTmbinababydbgecwtcw91:Yaece91cjjj98Gcjjj;8if::NUdbabclfhbadcufgdmbkkk:Tvirud99eudndnadcl9hmbaeTmeindndnabRbbgiabcefgl8Sbbgvabcdfgo8Sbbgrf9R:YJbbuJabcifgwRbbgdce4adVgDcd4aDVgDcl4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax86bbdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao86bbdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai86bbdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad86bbabclfhbaecufgembxdkkaeTmbindndnab8Vebgiabcdfgl8Uebgvabclfgo8Uebgrf9R:YJbFu9habcofgw8Vebgdce4adVgDcd4aDVgDcl4aDVgDcw4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax87ebdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao87ebdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai87ebdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad87ebabcwfhbaecufgembkkk9teiucbcbyd:K:G:cjbgeabcifc98GfgbBd:K:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkk83dbcj:Gdk8Kbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbc:K:Gdkl8W:qbb"),a=WebAssembly.instantiate(r,{}).then((function(e){(i=e.instance).exports.__wasm_call_ctors()}));function s(e){for(var i=new Uint8Array(e.length),r=0;r<e.length;++r){var a=e.charCodeAt(r);i[r]=a>96?a-97:a>64?a-39:a+4}var s=0;for(r=0;r<e.length;++r)i[s++]=i[r]<60?t[i[r]]:64*(i[r]-60)+i[++r];return i.buffer.slice(0,s)}function n(e,t,i,r,a,s,n){var o=e.exports.sbrk,l=r+3&-4,c=o(l*a),h=o(s.length),d=new Uint8Array(e.exports.memory.buffer);d.set(s,h);var u=t(c,r,a,h,s.length);if(0==u&&n&&n(c,l,a),i.set(d.subarray(c,c+r*a)),o(c-o(0)),0!=u)throw new Error("Malformed buffer data: "+u)}var o={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp",COLOR:"meshopt_decodeFilterColor"},l={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},c=[],h=0;function d(e){var t={object:new Worker(e),pending:0,requests:{}};return t.object.onmessage=function(e){var i=e.data;t.pending-=i.count,t.requests[i.id][i.action](i.value),delete t.requests[i.id]},t}function u(e){var t=e.data;self.ready.then((function(e){if(!t.id)return self.close();try{var i=new Uint8Array(t.count*t.size);n(e,e.exports[t.mode],i,t.count,t.size,t.source,e.exports[t.filter]),self.postMessage({id:t.id,count:t.count,action:"resolve",value:i},[i.buffer])}catch(r){self.postMessage({id:t.id,count:t.count,action:"reject",value:r})}}))}return{ready:a,supported:!0,useWorkers:function(e){!function(e){for(var t="self.ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(r)+"]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = "+u.name+";"+n.toString()+u.toString(),i=new Blob([t],{type:"text/javascript"}),a=URL.createObjectURL(i),s=c.length;s<e;++s)c[s]=d(a);for(s=e;s<c.length;++s)c[s].object.postMessage({});c.length=e,URL.revokeObjectURL(a)}(e)},decodeVertexBuffer:function(e,t,r,a,s){n(i,i.exports.meshopt_decodeVertexBuffer,e,t,r,a,i.exports[o[s]])},decodeIndexBuffer:function(e,t,r,a){n(i,i.exports.meshopt_decodeIndexBuffer,e,t,r,a)},decodeIndexSequence:function(e,t,r,a){n(i,i.exports.meshopt_decodeIndexSequence,e,t,r,a)},decodeGltfBuffer:function(e,t,r,a,s,c){n(i,i.exports[l[s]],e,t,r,a,i.exports[o[c]])},decodeGltfBufferAsync:function(e,t,r,s,d){return c.length>0?function(e,t,i,r,a){for(var s=c[0],n=1;n<c.length;++n)c[n].pending<s.pending&&(s=c[n]);return new Promise((function(n,o){var l=new Uint8Array(i),c=++h;s.pending+=e,s.requests[c]={resolve:n,reject:o},s.object.postMessage({id:c,count:e,size:t,source:l,mode:r,filter:a},[l.buffer])}))}(e,t,r,l[s],o[d]):a.then((function(){var a=new Uint8Array(e*t);return n(i,i.exports[l[s]],a,e,t,r,i.exports[o[d]]),a}))}}}();const yc=new Set(["ply","sog","spz","rad"]);function vc(e,t){if("string"!=typeof e||0===e.trim().length)throw new Error(`${t} must be a non-empty string.`)}function xc(e){const{anchor:t,translationENU:i,rotationDegrees:r,scale:a}=e,s=l.getEnuBasis(t.longitude,t.latitude),n=(new l.Vector3).fromArray(s.east),o=(new l.Vector3).fromArray(s.north),c=(new l.Vector3).fromArray(s.up),h=(new l.Matrix4).makeBasis(n,o,c);h.setPosition((new l.Vector3).fromArray(l.geodeticToEcefPosition(t.longitude,t.latitude,t.altitude)));const d=(new l.Quaternion).setFromEuler(new l.Euler(r[0]*Math.PI/180,r[1]*Math.PI/180,r[2]*Math.PI/180,"XYZ")),u=(new l.Matrix4).compose((new l.Vector3).fromArray(i),d,new l.Vector3(a,a,a));return h.multiply(u)}class wc extends fc{constructor(e,t={},i={}){super(),this.type="MeshLayer",this.isMeshLayer=!0;const r=(null==t?void 0:t.renderOrder)??0;if(void 0!==t.transform&&(void 0!==t.offset||void 0!==t.offsetOrigin))throw new Error("Mesh transform and legacy offset/offsetOrigin are mutually exclusive.");const a=void 0===t.transform?null:function(e){if(!e||"object"!=typeof e)throw new Error("Mesh transform must be an object.");const t=e.anchor;if(!t)throw new Error("Mesh transform anchor is required.");l.validateGeodeticPosition(t.longitude,t.latitude,t.altitude,"Mesh transform anchor");const i=e.translationENU??[0,0,0],r=e.rotationDegrees??[90,0,0],a=e.scale??1;return l.validateTuple(i,"Mesh translationENU"),l.validateTuple(r,"Mesh rotationDegrees"),l.validateScale(a,"Mesh scale"),{anchor:{...t},translationENU:[...i],rotationDegrees:[...r],scale:a}}(t.transform),s=a?0:6;this.xrRenderLayer=s;const n=a?{lon:0,lat:0,alt:0}:l.normalizeLayerOffset(t.offset,"Mesh offset"),o=0!==n.lon||0!==n.lat||0!==n.alt;a&&(this.matrix.copy(xc(a)),this.matrix.decompose(this.position,this.quaternion,this.scale)),this.abortController=new AbortController,this.disposed=!1;const c=new at;c.setMeshoptDecoder(bc),t.decoders&&(c.setDRACOLoader(t.decoders.getDraco()),c.setKTX2Loader(t.decoders.getKTX2()));const h=e=>{var t;this.disposed||"AbortError"===(null==e?void 0:e.name)||null==(t=i.onError)||t.call(i,e instanceof Error?e:new Error(String(e)))},d=e=>{var r;const c=e.scene;if(this.disposed)this.disposeObjectResources(c);else if(c.traverse((e=>{if(e.layers.set(s),!a){const t=Array.isArray(e.material)?e.material:e.material?[e.material]:[];for(const e of t)e.transparent=!0,e.onBeforeCompile=e=>{e.fragmentShader="uniform vec3 diffuse;uniform float opacity;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main(){vec4 diffuseColor=vec4(diffuse,opacity);\n#include <clipping_planes_fragment>\n#include <logdepthbuf_fragment>\n#include <map_fragment>\n#include <alphamap_fragment>\n#include <alphatest_fragment>\n#include <alphahash_fragment>\n#include <specularmap_fragment>\nReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));\n#ifdef USE_LIGHTMAP\nvec4 lightMapTexel=texture2D(lightMap,vLightMapUv);reflectedLight.indirectDiffuse+=lightMapTexel.rgb*lightMapIntensity*RECIPROCAL_PI;\n#else\nreflectedLight.indirectDiffuse+=vec3(1.0);\n#endif\n#include <aomap_fragment>\nreflectedLight.indirectDiffuse*=diffuseColor.rgb;vec3 outgoingLight=reflectedLight.indirectDiffuse;\n#include <envmap_fragment>\n#include <opaque_fragment>\n#include <tonemapping_fragment>\n#include <colorspace_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n#include <dithering_fragment>\n#ifdef USE_COLOR\ngl_FragColor.a=vColor.r;\n#endif\n}"}}})),this.mesh=c,this.add(c),o)try{const e=t.offsetOrigin,i=l.validateGeodeticPosition(null==e?void 0:e.longitude,null==e?void 0:e.latitude,null==e?void 0:e.altitude,"Mesh offset origin");this.position.fromArray(l.geodeticOffsetToEcefDelta({lon:i.longitude,lat:i.latitude,alt:i.altitude},n))}catch(h){null==(r=i.onError)||r.call(i,h instanceof Error?h:new Error(String(h)))}};fetch(e,{signal:this.abortController.signal}).then((async t=>{if(!t.ok)throw new Error(`Failed to load mesh: ${t.status} ${t.statusText}`);const i=await t.arrayBuffer();this.disposed||c.parse(i,e.slice(0,e.lastIndexOf("/")+1),d,h)})).catch(h),this.layers.set(a?0:r)}dispose(){this.disposed||(this.disposed=!0,this.abortController.abort(),super.dispose(),this.mesh&&(this.disposeObjectResources(this.mesh),this.mesh.removeFromParent(),this.mesh=null))}}function Tc(){return new DOMException("Worker job canceled","AbortError")}var _c="#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying float vOpacity;void main(){\n#include <uv_vertex>\n#include <color_vertex>\n#include <morphinstance_vertex>\n#include <morphcolor_vertex>\n#include <batching_vertex>\n#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinbase_vertex>\n#include <skinnormal_vertex>\n#include <defaultnormal_vertex>\n#endif\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <project_vertex>\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\n#include <worldpos_vertex>\n#include <envmap_vertex>\n#include <fog_vertex>\nvOpacity=smoothstep(100.0,500.0,-mvPosition.z);}",Ac="uniform vec3 diffuse;uniform float opacity;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying float vOpacity;void main(){vec4 diffuseColor=vec4(diffuse,opacity);\n#include <clipping_planes_fragment>\n#include <logdepthbuf_fragment>\n#include <map_fragment>\n#include <color_fragment>\n#include <alphamap_fragment>\n#include <alphatest_fragment>\n#include <alphahash_fragment>\n#include <specularmap_fragment>\nReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));\n#ifdef USE_LIGHTMAP\nvec4 lightMapTexel=texture2D(lightMap,vLightMapUv);reflectedLight.indirectDiffuse+=lightMapTexel.rgb*lightMapIntensity*RECIPROCAL_PI;\n#else\nreflectedLight.indirectDiffuse+=vec3(1.0);\n#endif\n#include <aomap_fragment>\nreflectedLight.indirectDiffuse*=diffuseColor.rgb;vec3 outgoingLight=reflectedLight.indirectDiffuse;\n#include <envmap_fragment>\n#include <opaque_fragment>\n#include <tonemapping_fragment>\n#include <colorspace_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n#include <dithering_fragment>\ngl_FragColor.a*=vOpacity;}";const Sc=new class{constructor(e=4){this.limit=e,this.queue=[],this.workers=[],this.active=[],this.workerStatus=0,this.workerCreator=null,this.disposed=!1}initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",(i=>this.onMessage(e,t,i))),t.addEventListener("error",(i=>this.onError(e,t,i))),this.workers[e]=t}}getIdleWorker(){for(let e=0;e<this.limit;e++)if(!(this.workerStatus&1<<e))return e;return-1}finishJob(e,t){var i;return this.active[e]===t&&(null==(i=t.signal)||i.removeEventListener("abort",t.onAbort),this.active[e]=null,this.workerStatus&=~(1<<e),!0)}onMessage(e,t,i){if(this.workers[e]!==t)return;const r=this.active[e];r&&this.finishJob(e,r)&&(r.resolve(i),this.drain())}onError(e,t,i){if(this.workers[e]!==t)return;const r=this.active[e];r&&this.finishJob(e,r)&&(t.terminate(),this.workers[e]=null,r.reject((null==i?void 0:i.error)??new Error("Worker job failed")),this.drain())}cancelJob(e){var t,i;if(null===e.workerId){const i=this.queue.indexOf(e);if(i<0)return;return this.queue.splice(i,1),null==(t=e.signal)||t.removeEventListener("abort",e.onAbort),void e.reject(Tc())}const r=e.workerId;this.finishJob(r,e)&&(null==(i=this.workers[r])||i.terminate(),this.workers[r]=null,e.reject(Tc()),this.drain())}startJob(e,t){this.initWorker(e),t.workerId=e,this.active[e]=t,this.workerStatus|=1<<e;try{this.workers[e].postMessage(t.msg,t.transfer)}catch(i){this.onError(e,this.workers[e],{error:i})}}drain(){for(;this.queue.length;){const e=this.getIdleWorker();if(e<0)return;this.startJob(e,this.queue.shift())}}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.limit=e,this.drain()}postMessage(e,t,{signal:i}={}){return this.disposed||(null==i?void 0:i.aborted)?Promise.reject(Tc()):new Promise(((r,a)=>{const s={msg:e,transfer:t,signal:i,resolve:r,reject:a,workerId:null,onAbort:null};s.onAbort=()=>this.cancelJob(s),null==i||i.addEventListener("abort",s.onAbort,{once:!0}),this.queue.push(s),this.drain()}))}dispose(){var e;if(!this.disposed){this.disposed=!0;for(const t of this.queue.splice(0))null==(e=t.signal)||e.removeEventListener("abort",t.onAbort),t.reject(Tc());for(let e=0;e<this.active.length;e++){const t=this.active[e];t&&(this.finishJob(e,t),t.reject(Tc()))}this.workers.forEach((e=>null==e?void 0:e.terminate())),this.workers.length=0,this.workerStatus=0}}};function Mc(e=new Date(-864e13),t=new Date(864e13),i,r){return i&&r?i<=t&&r>e:i?i<=t:!r||r>e}Sc.setWorkerCreator((function(e){return new Worker(new URL("./assets/viewer/geojson.worker-D3uq_RbR.js", require("url").pathToFileURL(__filename)),{name:null==e?void 0:e.name})}));class Cc extends l.Object3D{constructor(){super(),this.workerAbortController=new AbortController,this.disposed=!1}runWorker(e,t,i){Sc.postMessage(e,void 0,{signal:this.workerAbortController.signal}).then((e=>{var r;if(this.disposed)return;const{success:a,error:s}=e.data;a?i(e.data):null==(r=t.onError)||r.call(t,new Error((null==s?void 0:s.message)??String(s)))})).catch((e=>{var i;this.disposed||"AbortError"===(null==e?void 0:e.name)||null==(i=t.onError)||i.call(t,e instanceof Error?e:new Error(String(e)))}))}dispose(){this.disposed||(this.disposed=!0,this.workerAbortController.abort())}}class Ec extends Cc{constructor(e,t={},i={}){var r,a,s;super(),this.type="ArrowFeature",this.isArrowFeature=!0,this.timeStart=(null==(r=null==e?void 0:e.properties)?void 0:r.timeStart)?new Date(e.properties.timeStart):null,this.timeEnd=(null==(a=null==e?void 0:e.properties)?void 0:a.timeEnd)?new Date(e.properties.timeEnd):null;const n=(null==t?void 0:t.renderOrder)??0,o=(null==(s=null==e?void 0:e.properties)?void 0:s.color)??15955057;this.runWorker({type:"arrow",data:e,color:o},i,(({origin:e,meshVertexBuffer:t})=>{this.position.fromArray(e);const i=new l.BufferGeometry;i.setAttribute("position",new l.BufferAttribute(t,3));const r=new l.MeshBasicMaterial({color:o,side:l.DoubleSide,depthTest:!1,opacity:.75,transparent:!0,toneMapped:!1});r.onBeforeCompile=e=>{e.vertexShader=_c,e.fragmentShader=Ac};const a=new l.Mesh(i,r);a.layers.set(n),this.add(a)}))}}class Rc extends Cc{constructor(e,t={},i={}){var r,a,s;super(),this.type="PerimeterFeature",this.isPerimeterFeature=!0,this.timeStart=(null==(r=null==e?void 0:e.properties)?void 0:r.timeStart)?new Date(e.properties.timeStart):null,this.timeEnd=(null==(a=null==e?void 0:e.properties)?void 0:a.timeEnd)?new Date(e.properties.timeEnd):null;const n=(null==t?void 0:t.renderOrder)??0,o=(null==(s=null==e?void 0:e.properties)?void 0:s.color)??15955057;this.runWorker({type:"perimeter",data:e,color:o},i,(({origin:e,lineVertexBuffer:t,lineVertexRGBBuffer:i,meshVertexBuffer:r,meshVertexRGBBuffer:a,meshIndexBuffer:s})=>{this.position.fromArray(e);const o=new l.BufferGeometry;o.setAttribute("position",new l.BufferAttribute(r,3)),o.setAttribute("color",new l.BufferAttribute(a,3,!0)),o.setIndex(new l.BufferAttribute(s,1));const c=new l.MeshBasicMaterial({opacity:.2,transparent:!0,side:l.DoubleSide,depthTest:!1,vertexColors:!0,toneMapped:!1});c.onBeforeCompile=e=>{e.vertexShader=_c,e.fragmentShader=Ac};const h=new l.Mesh(o,c);h.layers.set(n);const d=new l.BufferGeometry;d.setAttribute("position",new l.BufferAttribute(t,3)),d.setAttribute("color",new l.BufferAttribute(i,3,!0));const u=new l.LineSegments(d,new l.LineBasicMaterial({vertexColors:!0,toneMapped:!1}));u.layers.set(n),u.add(h),this.add(u)}))}}class kc extends fc{constructor(e,t={},i={}){var r;super(),this.type="GeojsonLayer",this.isGeojsonLayer=!0,this.disposed=!1;for(let a=0;a<(null==(r=e.features)?void 0:r.length);a++){const r=e.features[a];switch(r.properties.type){case"arrow":const e=new Ec(r,t,i);this.add(e);break;case"perimeter":const a=new Rc(r,t,i);this.add(a)}}}setTimeFrame(e,t){e&&!e.isDate&&(e=new Date(e)),t&&!t.isDate&&(t=new Date(t));for(let i=0;i<this.children.length;i++){const r=this.children[i],a=r.timeStart,s=r.timeEnd;r.visible=Mc(e,t,a,s)}}dispose(){this.disposed||(this.disposed=!0,super.dispose(),this.disposeObjectResources(),this.clear())}}function Pc(e,t){return{ply:e.SplatFileType.PLY,sog:e.SplatFileType.PCSOGSZIP,spz:e.SplatFileType.SPZ,rad:e.SplatFileType.RAD}[t]}class Fc extends fc{constructor(e,t={}){super(),this.type="GaussianSplatLayer",this.isGaussianSplatLayer=!0,this.contentLayerId=e.id,this.definition=e,this.callbacks=t,this.loadState="idle",this.loadAttempt=0,this.abortController=null,this.splatMesh=null,this.visible=!1,this.layers.set(0),this.setLabels(e.labels),this.transformMatrix=xc(e.options.transform)}setEnabled(e){if("disposed"===this.loadState)return;if(!e)return void this.dispose();const t=this.visible;this.visible=e,!e||t||"idle"!==this.loadState&&"error"!==this.loadState||this.load()}async load(){var e,t,i,r,a,s,n,o,l,c;if("loading"===this.loadState||"ready"===this.loadState||"disposed"===this.loadState)return;const h=++this.loadAttempt;this.loadState="loading";let d=null;try{null==(t=(e=this.callbacks).onStart)||t.call(e,this);const o=await b();if("disposed"===this.loadState||h!==this.loadAttempt)return;if(await(null==(r=(i=this.callbacks).ensureRenderer)?void 0:r.call(i)),"disposed"===this.loadState||h!==this.loadAttempt)return;if(d="rad"===this.definition.data.format?this.createPagedMesh(o):await this.createDirectMesh(o,h),d.layers.set(0),d.matrix.copy(this.transformMatrix),d.matrix.decompose(d.position,d.quaternion,d.scale),d.matrixAutoUpdate=!1,d.matrixWorldNeedsUpdate=!0,this.splatMesh=d,this.add(d),"rad"===this.definition.data.format){if(!(null==(a=d.paged)?void 0:a.getRadMeta))throw new Error("Failed to initialize paged RAD streaming.");await Promise.all([d.initialized,d.paged.getRadMeta()])}else await d.initialized;if("disposed"===this.loadState||h!==this.loadAttempt)return void this.disposeMesh(d);this.abortController=null,this.loadState="ready",null==(n=(s=this.callbacks).onReady)||n.call(s,this)}catch(u){this.disposeMesh(d);const e=null==(o=this.abortController)?void 0:o.signal.aborted;if(this.abortController=null,"disposed"===this.loadState||h!==this.loadAttempt||e)return;this.loadState="error",null==(c=(l=this.callbacks).onError)||c.call(l,this,function(e){return e instanceof Error?e:new Error(String(e))}(u))}}createPagedMesh(e){const t=new e.PagedSplats({rootUrl:this.definition.data.url,fileType:Pc(e,this.definition.data.format)});return new e.SplatMesh({paged:t})}async createDirectMesh(e,t){this.abortController=new AbortController;const i=await fetch(this.definition.data.url,{signal:this.abortController.signal});if(!i.ok)throw new Error(`Failed to load Gaussian splat: ${i.status} ${i.statusText}`);if(!i.body)throw new Error("Failed to load Gaussian splat: response body is unavailable.");const r=i.headers.get("Content-Length"),a=null===r?void 0:Number.parseInt(r,10);return new e.SplatMesh({stream:i.body,streamLength:Number.isFinite(a)&&a>=0?a:void 0,fileType:Pc(e,this.definition.data.format),onProgress:e=>{var i,r;"disposed"!==this.loadState&&t===this.loadAttempt&&(null==(r=(i=this.callbacks).onProgress)||r.call(i,this,{loaded:e.loaded,total:e.total,lengthComputable:e.lengthComputable}))}})}disposeMesh(e){var t,i;e&&!e.userData.gaussianSplatDisposed&&(e.userData.gaussianSplatDisposed=!0,e.removeFromParent(),e.paged&&(null==(i=(t=this.callbacks).releasePagedSplats)||i.call(t,e.paged)),e.dispose(),this.splatMesh===e&&(this.splatMesh=null))}dispose(){var e;"disposed"!==this.loadState&&(this.loadState="disposed",this.loadAttempt++,null==(e=this.abortController)||e.abort(),this.abortController=null,this.disposeMesh(this.splatMesh),this.callbacks={},super.dispose())}}class Lc{constructor({group:e,createLayer:t,onError:i,onAllSplatsDisabled:r}={}){this.group=e,this.createLayer=t,this.onError=i,this.onAllSplatsDisabled=r,this.definitions=[],this.enabledLabels=new Set,this.active=new Map,this.timeFrameStart=null,this.timeFrameEnd=null,this.disposed=!1}setDefinitions(e=[]){this.disposed||(this.clear(),this.definitions=[...e],this.reconcile())}setEnabledLabels(e=[]){this.disposed||(this.enabledLabels=new Set(e),this.reconcile())}setTimeFrame(e,t){var i;if(!this.disposed){this.timeFrameStart=e,this.timeFrameEnd=t;for(const r of this.active.values())null==(i=r.setTimeFrame)||i.call(r,e,t)}}getActiveLayer(e){return this.active.get(e)??null}createActiveLayer(e){var t,i,r,a,s;const n=this.createLayer(e);try{return n.contentLayerId=e.id,n.setLabels(e.labels),n.contentRenderOrder="mesh"===e.type&&(null==(t=e.options)?void 0:t.transform)?0:(null==(i=e.options)?void 0:i.renderOrder)??0,n.xrRenderLayer=n.xrRenderLayer??("mesh"===e.type&&(null==(r=e.options)?void 0:r.transform)?0:"mesh"===e.type?6:n.contentRenderOrder),null==(a=n.setTimeFrame)||a.call(n,this.timeFrameStart,this.timeFrameEnd),n.setEnabled(!0),n}catch(o){throw null==(s=n.dispose)||s.call(n),o}}orderActiveLayers(){const e=new Map(this.definitions.map(((e,t)=>[e.id,t])));this.group.children.sort(((t,i)=>(e.get(t.contentLayerId)??0)-(e.get(i.contentLayerId)??0)))}replaceDefinition(e,t){var i,r,a,s;if(this.disposed)return!1;const n=this.definitions.findIndex((t=>t.id===e));let o=null;if((null==(i=null==t?void 0:t.labels)?void 0:i.some((e=>this.enabledLabels.has(e))))??!1)try{o=this.createActiveLayer(t)}catch(h){return null==(r=this.onError)||r.call(this,t,h),!1}const l=this.active.get(e),c=[...this.active.values()].some((e=>e.isGaussianSplatLayer));return l&&(null==(a=l.dispose)||a.call(l),this.group.remove(l),this.active.delete(e)),t?n<0?this.definitions.push(t):this.definitions[n]=t:n>=0&&this.definitions.splice(n,1),o&&(this.group.add(o),this.active.set(e,o)),this.orderActiveLayers(),c&&![...this.active.values()].some((e=>e.isGaussianSplatLayer))&&(null==(s=this.onAllSplatsDisabled)||s.call(this)),!0}reconcile(){var e,t,i;const r=new Set(this.definitions.filter((e=>{var t;return null==(t=e.labels)?void 0:t.some((e=>this.enabledLabels.has(e)))})).map((e=>e.id))),a=[...this.active.values()].some((e=>e.isGaussianSplatLayer));for(const[n,o]of this.active)r.has(n)||(null==(e=o.dispose)||e.call(o),this.group.remove(o),this.active.delete(n));for(const n of this.definitions)if(r.has(n.id)&&!this.active.has(n.id))try{const e=this.createActiveLayer(n);this.group.add(e),this.active.set(n.id,e)}catch(s){null==(t=this.onError)||t.call(this,n,s)}this.orderActiveLayers(),a&&![...this.active.values()].some((e=>e.isGaussianSplatLayer))&&(null==(i=this.onAllSplatsDisabled)||i.call(this))}clear(){var e,t;for(const r of this.active.values())null==(e=r.dispose)||e.call(r),this.group.remove(r);const i=[...this.active.values()].some((e=>e.isGaussianSplatLayer));this.active.clear(),this.definitions=[],i&&(null==(t=this.onAllSplatsDisabled)||t.call(this))}dispose(){this.disposed||(this.clear(),this.disposed=!0)}}class Dc{constructor({getRenderer:e,getLayer:t}){this.getRenderer=e,this.getLayer=t,this.target=null,this.boundRenderer=null,this.boundMeshes=[],this.timeoutId=null,this.disposed=!1}set(e){this.disposed||!e||!Number.isFinite(e.timeoutMs)||e.timeoutMs<=0||e.timeoutMs>3e4||(this.clear("cancel"),this.target=e,this.timeoutId=setTimeout((()=>this.clear("timeout")),e.timeoutMs),this.sync())}sync(){var e;if(this.disposed||!this.target)return;const t=this.getRenderer(),i=[...new Set(this.target.layerIds)].map((e=>this.getLayer(e))).filter((e=>{var t,i,r;return(null==e?void 0:e.isGaussianSplatLayer)&&e.visible&&"rad"===(null==(i=null==(t=e.definition)?void 0:t.data)?void 0:i.format)&&(null==(r=e.splatMesh)?void 0:r.paged)&&"disposed"!==e.loadState})).map((e=>e.splatMesh));if(t===this.boundRenderer&&i.length===this.boundMeshes.length&&i.every(((e,t)=>e===this.boundMeshes[t])))return;if(null==(e=this.boundRenderer)||e.clearDestinationHint(!1),this.boundRenderer=null,this.boundMeshes=[],!t||0===i.length)return;const r=this.target;t.setDestinationHint({position:(new l.Vector3).fromArray(l.geodeticToEcefPosition(r.longitude,r.latitude,r.altitude)),quaternion:$s(r.longitude,r.latitude,r.pitch,r.yaw,r.roll),meshes:i,maxChunks:"xr"===r.mode?1:4,maxSplats:3e4}),this.boundRenderer=t,this.boundMeshes=i}clear(e="cancel"){var t;null!==this.timeoutId&&clearTimeout(this.timeoutId),this.timeoutId=null,this.target=null,null==(t=this.boundRenderer)||t.clearDestinationHint("arrival"===e),this.boundRenderer=null,this.boundMeshes=[]}dispose(){this.disposed||(this.clear("cancel"),this.disposed=!0)}}function Uc(e,t,i={}){var r,a,s;const n=i.source??"all";if(!["all","splats","globe","content"].includes(n))throw new TypeError("Unknown surface pick source.");const o=i.layerIds&&new Set(i.layerIds);let c=null;const h=(e,t,i)=>{e&&(!c||e.distance<c.distance)&&(c={...e,source:t,layerId:i})},d=(e,i,r)=>{var a,s;if(!e||!e.visible)return;if(e===(null==(a=e.parent)?void 0:a.splatMesh))return void h(function(e,t){if(!e||!1===e.visible||!1===e.raycastable||0===e.opacity)return null;if(!e.matrixWorld.determinant())return null;const i=e.matrixWorld.clone().invert(),r=t.ray.origin.clone().applyMatrix4(i),a=t.ray.direction.clone().applyMatrix3((new l.Matrix3).setFromMatrix4(i)),s=new l.Vector3,n=new l.Vector3,o=new l.Quaternion,c=Math.max(0,t.near);let h=t.far,d=-1;return e.forEachSplat(((t,i,l,u,p)=>{if(!Number.isFinite(p)||p<(e.minRaycastOpacity??.2))return;const m=4*Math.max(p,1)-3,f=l.x*m,g=l.y*m,b=l.z*m;if(![f,g,b].every(Number.isFinite)||Math.min(f,g,b)<0)return;o.copy(u).normalize().conjugate(),s.copy(r).sub(i).applyQuaternion(o),n.copy(a).applyQuaternion(o);const y=.01*Math.max(f,g,b);let v;if(b<y||g<y||f<y){const e=b<y?"z":g<y?"y":"x",[t,i,r,a]="z"===e?["x","y",f,g]:"y"===e?["x","z",f,b]:["y","z",g,b];if(Math.abs(n[e])<1e-12||0===r||0===a)return;if(v=-s[e]/n[e],((s[t]+v*n[t])/r)**2+((s[i]+v*n[i])/a)**2>1)return}else{if(0===y)return;s.set(s.x/f,s.y/g,s.z/b),n.set(n.x/f,n.y/g,n.z/b);const e=n.lengthSq();if(!Number.isFinite(e)||0===e)return;const t=-s.dot(n)/e;s.addScaledVector(n,t);const i=1-s.lengthSq();if(i<0)return;const r=Math.sqrt(i/e);v=t-r,v<c&&(v=t+r)}Number.isFinite(v)&&v>=c&&v<=h&&(h=v,d=t)})),d<0?null:{distance:h,point:t.ray.at(h,new l.Vector3),object:e,splatIndex:d}}(e,t),"splats",r);const n=[],o=null==(s=e.raycast)?void 0:s.call(e,t,n);for(const t of n)h(t,i,r);if(!1!==o)for(const t of e.children)d(t,i,r)},u=t.layers.mask;t.layers.enableAll();try{if(!o&&("all"===n||"globe"===n)){const t=null==(a=null==(r=e.globeManager)?void 0:r.tiles)?void 0:a.group;null==t||t.updateWorldMatrix(!0,!0),d(t,"globe",null)}if("globe"!==n)for(const t of(null==(s=e.content)?void 0:s.children)??[])!t.visible||o&&!o.has(t.contentLayerId)||("splats"!==n||t.isGaussianSplatLayer)&&(t.updateWorldMatrix(!0,!0),d(t,t.isGaussianSplatLayer?"splats":"content",t.contentLayerId??null))}finally{t.layers.mask=u}return c}const Ic=e=>(e%360+360)%360;class Oc{constructor(e,t){this.headLocal=(new l.Matrix4).fromArray(t.matrix),this.trackingReference=null,this.visualReference=null,this.visualOrientation=null,this.visualBlend=1;const i=(new l.Vector3).setFromMatrixPosition(e),r=l.ecefToGeodeticPosition(...i.toArray()),{east:a,north:s,up:n}=l.getEnuBasis(r.lon,r.lat),o=(new l.Vector3).fromArray(a),c=(new l.Vector3).fromArray(s),h=new l.Vector3(0,0,-1).transformDirection(e),d=Math.atan2(h.dot(o),h.dot(c)),u=new l.Vector3(0,0,-1).transformDirection(this.headLocal),p=Math.atan2(u.x,-u.z);this.worldFromLocal=(new l.Matrix4).makeBasis(o,(new l.Vector3).fromArray(n),c.negate()).multiply((new l.Matrix4).makeRotationY(p-d));const m=(new l.Vector3).setFromMatrixPosition(this.headLocal).applyMatrix4(this.worldFromLocal);this.worldFromLocal.setPosition(i.sub(m)),this.anchor=this.getHeadPose().geodetic}updateHeadPose(e){this.headLocal.fromArray(e.matrix)}getWorldFromLocalMatrix(){return this.worldFromLocal.clone()}getWorldHeadMatrix(){return this.worldFromLocal.clone().multiply(this.headLocal)}getVisualWorldFromLocalMatrix(){const e=this.getWorldFromLocalMatrix();if(!this.visualOrientation)return e;const t=e.clone().multiply(this.visualReference??this.headLocal),i=(new l.Vector3).setFromMatrixPosition(t),r=l.ecefToGeodeticPosition(...i.toArray()),{headingDegrees:a}=this.poseFromWorld(t),s=$s(r.lon,r.lat,this.visualOrientation.pitchDegrees,-a,this.visualOrientation.rollDegrees),n=(new l.Quaternion).setFromRotationMatrix(t),o=s.multiply(n.invert());o.slerp(new l.Quaternion,1-this.visualBlend);const c=(new l.Vector3).setFromMatrixPosition(this.getWorldHeadMatrix());return(new l.Matrix4).makeTranslation(c.x,c.y,c.z).multiply((new l.Matrix4).makeRotationFromQuaternion(o)).multiply((new l.Matrix4).makeTranslation(-c.x,-c.y,-c.z)).multiply(e)}getVisualWorldHeadMatrix(){return this.getVisualWorldFromLocalMatrix().multiply(this.headLocal)}getVisualHeadForward(){return new l.Vector3(0,0,-1).transformDirection(this.getVisualWorldHeadMatrix()).toArray()}poseFromWorld(e){const t=(new l.Vector3).setFromMatrixPosition(e),i=l.ecefToGeodeticPosition(...t.toArray()),r=l.getEnuBasis(i.lon,i.lat),a=new l.Vector3(0,0,-1).transformDirection(e),s=Ic(180*Math.atan2(a.dot((new l.Vector3).fromArray(r.east)),a.dot((new l.Vector3).fromArray(r.north)))/Math.PI);return{worldEcef:t.toArray(),geodetic:{longitude:i.lon,latitude:i.lat,altitude:i.alt},headingDegrees:s}}getHeadPose(){const e=this.getWorldHeadMatrix(),t=this.poseFromWorld(e),i=this.getVisualWorldHeadMatrix(),r=(new l.Quaternion).setFromRotationMatrix(i),{pitch:a,yaw:s,roll:n}=Ys(...(new l.Vector3).setFromMatrixPosition(i).toArray(),r),o=(new l.Quaternion).setFromRotationMatrix(this.headLocal);return{...t,localHeadOffset:(new l.Vector3).setFromMatrixPosition(this.headLocal).toArray(),localHeadOrientation:o.toArray(),displayedOrientation:{pitch:a,yaw:s,roll:n}}}getNavigationFrame(){const{longitude:e,latitude:t,altitude:i}=this.anchor,r=l.getEnuBasis(e,t),a=(new l.Matrix4).makeBasis((new l.Vector3).fromArray(r.east),(new l.Vector3).fromArray(r.up),(new l.Vector3).fromArray(r.north).negate());return a.setPosition((new l.Vector3).fromArray(l.geodeticToEcefPosition(e,t,i))),a}getControllerWorldRay(e){var t,i;const r=null==e?void 0:e.ray;if(!r||3!==(null==(t=r.position)?void 0:t.length)||4!==(null==(i=r.orientation)?void 0:i.length)||![...r.position,...r.orientation].every(Number.isFinite))return null;const a=new l.Quaternion(...r.orientation);if(a.lengthSq()<1e-12)return null;const s=this.getVisualWorldFromLocalMatrix(),n=new l.Vector3(...r.position).applyMatrix4(s),o=new l.Vector3(0,0,-1).applyQuaternion(a.normalize()).transformDirection(s);return{origin:n.toArray(),direction:o.toArray()}}setPose({anchor:e,east:t=0,north:i=0,up:r=0,headingDegrees:a,trackingReference:s,visualOrientation:n}){if(this.trackingReference=function(e){if(!e)return null;const{position:t,orientation:i}=e;if(3!==(null==t?void 0:t.length)||4!==(null==i?void 0:i.length)||![...t,...i].every(Number.isFinite))throw new Error("Invalid XR tracking reference");const r=new l.Quaternion(...i);if(r.lengthSq()<1e-12)throw new Error("Invalid XR tracking reference orientation");return(new l.Matrix4).compose(new l.Vector3(...t),r.normalize(),new l.Vector3(1,1,1))}(s),void 0!==n){if(n&&![n.pitchDegrees,n.rollDegrees].every(Number.isFinite))throw new Error("Invalid XR visual orientation");this.visualOrientation=n,this.visualReference=n?(this.trackingReference??this.headLocal).clone():null,this.visualBlend=1}const o=this.trackingReference??this.headLocal,c=this.poseFromWorld(this.worldFromLocal.clone().multiply(o)),h=(new l.Vector3).fromArray(l.geodeticToEcefPosition(e.longitude,e.latitude,e.altitude));h.add((new l.Vector3).fromArray(l.enuToEcefDelta([t,i,r],e.longitude,e.latitude)));const d=h.clone().sub((new l.Vector3).fromArray(c.worldEcef));if(this.worldFromLocal.setPosition((new l.Vector3).setFromMatrixPosition(this.worldFromLocal).add(d)),Number.isFinite(a)){let t=Ic(a-c.headingDegrees);if(t>180&&(t-=360),Math.abs(t)>1e-10){const i=(new l.Vector3).fromArray(l.getEnuBasis(e.longitude,e.latitude).up),r=(new l.Matrix4).makeRotationFromQuaternion((new l.Quaternion).setFromAxisAngle(i,-t*Math.PI/180));this.worldFromLocal.premultiply((new l.Matrix4).makeTranslation(-h.x,-h.y,-h.z)),this.worldFromLocal.premultiply(r),this.worldFromLocal.premultiply((new l.Matrix4).makeTranslation(h.x,h.y,h.z))}}const u=(new l.Vector3).fromArray(l.geodeticToEcefPosition(this.anchor.longitude,this.anchor.latitude,this.anchor.altitude));h.distanceTo(u)>100&&this.reanchor(a)}setVisualBlend(e){if(!Number.isFinite(e)||e<0||e>1)throw new Error("Invalid XR visual blend");this.visualBlend=e,0===e&&(this.visualOrientation=null,this.visualReference=null)}reanchor(e){const t=this.trackingReference??this.headLocal,i=this.poseFromWorld(this.worldFromLocal.clone().multiply(t)),{longitude:r,latitude:a}=i.geodetic,{east:s,north:n,up:o}=l.getEnuBasis(r,a),c=new l.Vector3(0,0,-1).transformDirection(t),h=Math.atan2(c.x,-c.z),d=(Number.isFinite(e)?e:i.headingDegrees)*Math.PI/180,u=(new l.Matrix4).makeBasis((new l.Vector3).fromArray(s),(new l.Vector3).fromArray(o),(new l.Vector3).fromArray(n).negate()).multiply((new l.Matrix4).makeRotationY(h-d)),p=(new l.Vector3).setFromMatrixPosition(t).applyMatrix4(u);u.setPosition(new l.Vector3(...i.worldEcef).sub(p)),this.worldFromLocal.copy(u),this.anchor=i.geodetic}}const Bc=(new l.Matrix4).makeTranslation(0,0,-.5);class Vc{constructor(){this.material=new l.ShaderMaterial({transparent:!0,depthTest:!1,depthWrite:!1,side:l.DoubleSide,uniforms:{vignette:{value:0},limit:{value:0},fade:{value:0}},vertexShader:"varying vec2 uvOut; void main() { uvOut = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }",fragmentShader:"varying vec2 uvOut; uniform float vignette; uniform float limit; uniform float fade; void main() { float edge = smoothstep(0.48, 1.0, length((uvOut - 0.5) * 2.0)); vec3 color = limit > 2.5 ? vec3(0.2, 0.65, 1.0) : limit > 1.5 ? vec3(0.95, 0.65, 0.12) : vec3(0.95, 0.3, 0.08); float alpha = limit > 0.5 ? 0.48 : vignette; gl_FragColor = vec4(mix(limit > 0.5 ? color : vec3(0.0), vec3(0.0), fade), max(edge * alpha, fade)); }"}),this.mesh=new l.Mesh(new l.PlaneGeometry(2.5,2.5),this.material),this.mesh.matrixAutoUpdate=!1,this.mesh.layers.set(31),this.mesh.renderOrder=10001,this.mesh.visible=!1,this.moving=!1,this.navigationLimit=null,this.fade=0}setNavigationLimit(e){const t="floor"===e||"unknown"===e||"loading"===e?e:null;return this.navigationLimit!==t&&(this.navigationLimit=t,!0)}setFade(e){this.fade=Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}update(e){this.mesh.matrix.copy(e).multiply(Bc),this.mesh.matrixWorldNeedsUpdate=!0,this.material.uniforms.vignette.value=this.moving?.65:0,this.material.uniforms.limit.value="floor"===this.navigationLimit?1:"unknown"===this.navigationLimit?2:"loading"===this.navigationLimit?3:0,this.material.uniforms.fade.value=this.fade,this.mesh.visible=this.moving||null!==this.navigationLimit||this.fade>0}dispose(){this.mesh.geometry.dispose(),this.material.dispose()}}const Nc={valid:5242789,blocked:16747366,unknown:16765802};class jc{constructor(e){this.scene=e,this.group=new l.Group,this.group.name="XRNavigationCue",this.group.matrixAutoUpdate=!1,this.group.visible=!1,this.scene.add(this.group)}set(e){if(this.clearChildren(),!e)return void(this.group.visible=!1);const{anchor:t,arc:i,marker:r,state:a}=e;if(!t||![t.longitude,t.latitude,t.altitude].every(Number.isFinite)||!Array.isArray(i)||i.length>17||!["valid","blocked","unknown"].includes(a))return void(this.group.visible=!1);const s=l.getEnuBasis(t.longitude,t.latitude),n=(new l.Vector3).fromArray(s.east),o=(new l.Vector3).fromArray(s.up),c=(new l.Vector3).fromArray(s.north).negate();this.group.matrix.copy((new l.Matrix4).makeBasis(n,o,c)),this.group.matrix.setPosition(...l.geodeticToEcefPosition(t.longitude,t.latitude,t.altitude)),this.group.updateMatrixWorld(!0);const h=Nc[a];if(i.length>=2&&i.every((e=>3===(null==e?void 0:e.length)&&e.every(Number.isFinite)))){const e=new l.BufferGeometry;e.setAttribute("position",new l.Float32BufferAttribute(i.flatMap((([e,t,i])=>[e,i,-t])),3));const t=new l.Line(e,new l.LineBasicMaterial({color:h,depthTest:!0,depthWrite:!1}));t.layers.set(0),this.group.add(t)}if(3===(null==r?void 0:r.length)&&r.every(Number.isFinite)){const e=new l.Mesh(new l.RingGeometry(.13,.19,24),new l.MeshBasicMaterial({color:h,side:l.DoubleSide,depthTest:!0,depthWrite:!1}));e.rotation.x=-Math.PI/2,e.position.set(r[0],r[2]+.03,-r[1]),e.layers.set(0),this.group.add(e);const t=(new l.BufferGeometry).setFromPoints([new l.Vector3(r[0],r[2]+.03,-r[1]),new l.Vector3(r[0],r[2]+.23,-r[1])]),i=new l.Line(t,new l.LineBasicMaterial({color:h,depthTest:!0,depthWrite:!1}));i.layers.set(0),this.group.add(i)}this.group.visible=this.group.children.length>0}clearChildren(){var e,t;for(const i of[...this.group.children])this.group.remove(i),null==(e=i.geometry)||e.dispose(),null==(t=i.material)||t.dispose()}dispose(){this.clearChildren(),this.scene.remove(this.group)}}const zc=(new l.Matrix4).makeTranslation(.35,-.32,-.9);class Gc{constructor(){const e=document.createElement("canvas");e.width=480,e.height=220,this.context=e.getContext("2d"),this.texture=new l.CanvasTexture(e),this.texture.colorSpace=l.SRGBColorSpace,this.mesh=new l.Mesh(new l.PlaneGeometry(.42,.1925),new l.MeshBasicMaterial({map:this.texture,transparent:!0,depthTest:!1,depthWrite:!1,side:l.DoubleSide,toneMapped:!1})),this.mesh.name="XRDiagnosticsPanel",this.mesh.matrixAutoUpdate=!1,this.mesh.layers.set(31),this.mesh.renderOrder=10003,this.rows=[]}setRows(e){this.rows=e.slice(0,5).map(String);const t=this.context;t&&(t.clearRect(0,0,480,220),t.fillStyle="rgba(17,24,39,0.9)",t.beginPath(),t.roundRect(0,0,480,220,24),t.fill(),t.fillStyle="#e5e7eb",t.font="32px Arial, sans-serif",this.rows.forEach(((e,i)=>t.fillText(e,24,45+39*i,432))),this.texture.needsUpdate=!0)}update(e){this.mesh.matrix.copy(e).multiply(zc),this.mesh.matrixWorldNeedsUpdate=!0}dispose(){this.mesh.geometry.dispose(),this.mesh.material.dispose(),this.texture.dispose()}}class Hc{constructor(e,t={}){this.viewer=e,this.onFrame=t.onFrame,this.onStateChange=t.onStateChange,this.session=null,this.starting=null,this.bridge=null,this.desktop=null,this.sparkProfiles=new Map,this.disposed=!1,this.stopping=!1,this.endRequested=!1,this.active=!1,this.handleSessionEnd=()=>this.cleanup(),this.handleFrame=(e,t)=>this.frame(e,t)}start(){var e;if(this.disposed)return Promise.reject(new Error("VR session has been disposed"));if(this.active)return Promise.resolve();if(this.starting)return this.starting;if(!(null==(e=globalThis.navigator)?void 0:e.xr))return Promise.reject(new Error("Immersive VR is unavailable in this browser"));let t;this.stopping=!1,this.endRequested=!1;try{t=navigator.xr.requestSession("immersive-vr",{requiredFeatures:["local-floor"],optionalFeatures:["high-fixed-foveation-level"]})}catch(i){return Promise.reject(i)}return this.starting=this.activate(t).finally((()=>{this.starting=null})),this.starting}async activate(e){var t;const i=await e;if(this.disposed||this.stopping)return void(await this.endSessionOnce(i));this.session=i;const{viewer:r}=this,{renderer:a,camera:s}=r,n=a.xr;s.updateMatrixWorld(!0),this.desktop={cameraWorld:s.matrixWorld.clone(),near:s.near,far:s.far,globeEnabled:r.globeControls.enabled,keysEnabled:r.keysEnabled,xrEnabled:n.enabled,foveation:n.getFoveation()??1,referenceSpaceType:n.referenceSpaceType??"local-floor",framebufferScaleFactor:n.framebufferScaleFactor??1,labelRender:r.css2DRenderer.render,ensureSparkRenderer:r.ensureSparkRenderer,transitionAnimateTo:r.transitionControls.animateTo,tilesSchedulerSession:he.session};try{r.setAnimate(!1),r.transitionControls.cancel(),r.transitionControls.animateTo=async()=>!1,r.globeControls.enabled=!1,r.keysEnabled=!1,r.css2DRenderer.render=()=>{},s.near=.25,s.updateProjectionMatrix(),n.enabled=!0,n.setReferenceSpaceType("local-floor"),n.setFramebufferScaleFactor(.8),n.setFoveation(.75),n.addEventListener("sessionend",this.handleSessionEnd),this.applySparkProfile(r.sparkRenderer);const e=this.desktop.ensureSparkRenderer;if(r.ensureSparkRenderer=async()=>{const t=await e.call(r);return this.desktop&&this.applySparkProfile(t),t},await n.setSession(i),this.disposed||this.stopping||this.session!==i)return await this.endSessionOnce(i),void this.cleanup();he.setXRSession(i),a.setAnimationLoop(this.handleFrame),this.active=!0,null==(t=this.onStateChange)||t.call(this,!0)}catch(o){try{await this.endSessionOnce(i)}finally{this.cleanup()}throw o}}frame(e,t){var i;if(t&&this.session&&!this.stopping)try{const r=this.viewer.renderer.xr.getReferenceSpace();if(!r)return;const a=t.getViewerPose(r);if(!a)return;this.bridge?this.bridge.updateHeadPose(a.transform):(this.bridge=function(e,t){const{camera:i,renderer:r}=e;if(null!==i.parent)throw new Error("WebXR camera bridge requires an unparented viewer camera");i.updateMatrixWorld(!0);const a=new Oc(i.matrixWorld,t),s=new l.Group;s.matrixAutoUpdate=!1,s.matrix.copy(a.getVisualWorldFromLocalMatrix()),s.updateMatrixWorld(!0),e.scene.add(s);const n=r.render,o=r.xr.cameraAutoUpdate;let c=i.matrix.clone().fromArray(t.matrix),h=!1;const d=new Vc;let u=null;const p=new jc(e.scene);s.add(d.mesh);const m=e=>{i.parent===s&&s.remove(i),e.decompose(i.position,i.quaternion,i.scale),i.updateMatrixWorld(!0)},f=(e,t)=>{if(h||t!==i)return n.call(r,e,t);i.updateMatrixWorld(!0);const o=i.matrixWorld.clone();s.matrix.copy(a.getVisualWorldFromLocalMatrix()),s.updateMatrixWorld(!0),d.update(c),null==u||u.update(c),s.add(i),c.decompose(i.position,i.quaternion,i.scale),i.updateMatrixWorld(!0);try{if(r.xr.isPresenting){r.xr.cameraAutoUpdate=!1,r.xr.updateCamera(i);const e=r.xr.getCamera();e.layers.mask=i.layers.mask;for(const t of e.cameras)t.layers.mask=i.layers.mask}return n.call(r,e,t)}finally{m(o)}};return r.render=f,{getHeadPose:()=>a.getHeadPose(),getHeadForward:()=>a.getVisualHeadForward(),getControllerWorldRay:e=>a.getControllerWorldRay(e),setNavigationCue:e=>p.set(e),setTerrainCredits:()=>{},setDiagnosticsRows(e){if(!h)if(Array.isArray(e)&&0!==e.length){if(!u){if("undefined"==typeof document)return;u=new Gc,s.add(u.mesh)}u.setRows(e),u.update(c)}else u&&(s.remove(u.mesh),u.dispose(),u=null)},setPlayerPose(e){h||(a.setPose(e),m(a.getVisualWorldHeadMatrix()))},setVisualBlend(e){h||(a.setVisualBlend(e),m(a.getVisualWorldHeadMatrix()))},hasUi:()=>Boolean(u)||d.moving||null!==d.navigationLimit||d.fade>0,setNavigationLimit(e){d.setNavigationLimit(e)&&d.update(c)},setComfortMoving(e){d.moving=Boolean(e),d.update(c)},setFade(e){d.setFade(e),d.update(c)},updateHeadPose(e){h||(c=i.matrix.clone().fromArray(e.matrix),a.updateHeadPose(e),d.update(c),m(a.getVisualWorldHeadMatrix()))},dispose(){h||(h=!0,r.xr.cameraAutoUpdate=o,r.render===f&&(r.render=n),i.parent===s&&m(a.getVisualWorldHeadMatrix()),s.remove(d.mesh),d.dispose(),u&&(s.remove(u.mesh),u.dispose(),u=null),p.dispose(),e.scene.remove(s))}}}(this.viewer,a.transform,{showAttribution:!1}),this.bridge.setDiagnosticsRows(this.viewer.xrDiagnosticsRows)),null==(i=this.onFrame)||i.call(this,{time:e,frame:t,pose:a}),this.applySparkProfile(this.viewer.sparkRenderer),this.viewer.animate(e);const s=this.viewer.sparkRenderer;s&&(this.viewer.renderer.xr.getCamera().layers.mask=s.layers.mask)}catch(r){this.stop()}}applySparkProfile(e){e&&"object"==typeof e&&(this.sparkProfiles.has(e)||this.sparkProfiles.set(e,{lodSplatCount:e.lodSplatCount,lodRenderScale:e.lodRenderScale}),e.lodSplatCount=5e4,e.lodRenderScale=4)}cleanup(){var e,t;const i=this.desktop;if(!i)return;this.desktop=null;const{viewer:r}=this,{renderer:a,camera:s}=r,n=a.xr;n.removeEventListener("sessionend",this.handleSessionEnd),a.setAnimationLoop(null),he.setXRSession(i.tilesSchedulerSession),null==(e=this.bridge)||e.dispose(),this.bridge=null,r.ensureSparkRenderer=i.ensureSparkRenderer,r.transitionControls.animateTo=i.transitionAnimateTo;for(const[o,l]of this.sparkProfiles)Object.assign(o,l);this.sparkProfiles.clear(),i.cameraWorld.decompose(s.position,s.quaternion,s.scale),s.updateMatrixWorld(!0),s.near=i.near,s.far=i.far,s.updateProjectionMatrix(),r.globeControls.enabled=i.globeEnabled,r.keysEnabled=i.keysEnabled,r.css2DRenderer.render=i.labelRender,n.setReferenceSpaceType(i.referenceSpaceType),n.setFramebufferScaleFactor(i.framebufferScaleFactor),n.setFoveation(i.foveation),n.enabled=i.xrEnabled,this.session=null,r.setAnimate(!0),this.active&&(this.active=!1,null==(t=this.onStateChange)||t.call(this,!1))}async endSessionOnce(e){if(!this.endRequested){this.endRequested=!0;try{await e.end()}catch(t){if(!(t instanceof DOMException&&"InvalidStateError"===t.name))throw t}}}async stop(){this.stopping=!0;const e=this.session;if(e)try{await this.endSessionOnce(e)}finally{this.cleanup()}}async dispose(){this.disposed=!0,this.stopping=!0;const e=this.session?this.endSessionOnce(this.session):Promise.resolve();this.cleanup(),await e}}function qc(e){if(!e)return null;const{position:t,orientation:i}=e;return{position:[t.x,t.y,t.z],orientation:[i.x,i.y,i.z,i.w]}}class Wc{constructor(e,t){var i;this.canvas=e,this.onLook=t,this.root=e.ownerDocument??e.getRootNode(),this.window=this.root.defaultView??("undefined"==typeof window?null:window),this.pointer=null,this.down=e=>{"mouse"!==e.pointerType||1!==e.buttons&&2!==e.buttons||this.pointer||(this.pointer={id:e.pointerId,startX:e.clientX,startY:e.clientY,x:e.clientX,y:e.clientY,dragging:!1})},this.move=e=>{var t,i;const r=this.pointer;if(!r||e.pointerId!==r.id)return;if(!r.dragging){if(Math.hypot(e.clientX-r.startX,e.clientY-r.startY)<4)return;r.dragging=!0,null==(i=(t=this.canvas).setPointerCapture)||i.call(t,r.id)}const a=e.clientX-r.x,s=e.clientY-r.y;r.x=e.clientX,r.y=e.clientY,(a||s)&&this.onLook(a,s),e.preventDefault()},this.end=e=>{var t,i;if(this.pointer&&(void 0===e.pointerId||e.pointerId===this.pointer.id)){if(this.pointer.dragging)try{null==(i=(t=this.canvas).releasePointerCapture)||i.call(t,this.pointer.id)}catch{}this.pointer=null}},this.wheel=e=>e.preventDefault(),this.contextMenu=e=>e.preventDefault(),e.addEventListener("pointerdown",this.down),e.addEventListener("wheel",this.wheel,{passive:!1}),e.addEventListener("contextmenu",this.contextMenu),this.root.addEventListener("pointermove",this.move),this.root.addEventListener("pointerup",this.end),this.root.addEventListener("pointercancel",this.end),this.root.addEventListener("lostpointercapture",this.end),null==(i=this.window)||i.addEventListener("blur",this.end)}handleKeyDown(e){if(e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return!1;const t=e.target;if((null==t?void 0:t.isContentEditable)||["INPUT","TEXTAREA","SELECT"].includes(null==t?void 0:t.tagName))return!1;if(t!==this.canvas&&t!==this.root.body&&t!==this.root.documentElement)return!1;const i={ArrowLeft:[-16,0],ArrowRight:[16,0],ArrowUp:[0,-16],ArrowDown:[0,16]}[e.key];return!!i&&(e.preventDefault(),this.onLook(i[0],i[1]),!0)}dispose(){var e;this.end({}),this.canvas.removeEventListener("pointerdown",this.down),this.canvas.removeEventListener("wheel",this.wheel),this.canvas.removeEventListener("contextmenu",this.contextMenu),this.root.removeEventListener("pointermove",this.move),this.root.removeEventListener("pointerup",this.end),this.root.removeEventListener("pointercancel",this.end),this.root.removeEventListener("lostpointercapture",this.end),null==(e=this.window)||e.removeEventListener("blur",this.end)}}const Kc=document.createElement("canvas");Kc.width=128,Kc.height=128;const Jc=Kc.getContext("2d"),Xc=Kc.width/2,Qc=Kc.height/2,Yc=Math.min(Kc.width,Kc.height)/2,Zc="0, 0, 0",$c=Jc.createRadialGradient(Xc,Qc,0,Xc,Qc,Yc);$c.addColorStop(0,`rgba(${Zc}, 1)`),$c.addColorStop(.5,`rgba(${Zc}, 0.25)`),$c.addColorStop(1,`rgba(${Zc}, 0)`),Jc.fillStyle=$c,Jc.fillRect(0,0,Kc.width,Kc.height);const eh={APPENDED:"viewer-appended",READY:"viewer-ready",ANIMATED:"viewer-animated",TRANSITIONED:"viewer-transitioned",CONTENT_LAYER_LOAD_START:"content-layer-load-start",CONTENT_LAYER_LOAD_PROGRESS:"content-layer-load-progress",CONTENT_LAYER_READY:"content-layer-ready",CONTENT_LAYER_ERROR:"content-layer-error",GLOBE_TILE_LOADED:"globe-tile-loaded"};exports.FullScreenQuad=vn,exports.Viewer=class extends y{constructor(e,t={}){super(),this.isViewer=!0,this.type="viewer",this.disposed=!1,this.xrSession=null,this.xrDiagnosticsRows=null,this.loadingDiagnosticsEnabled=!1,this.diagnosticFps=null,this.diagnosticWindowStart=null,this.diagnosticFrameCount=0,this.sparkRenderer=null,this.transparentBackground=t.transparentBackground??!0,nc.CESIUM=t.cesiumToken||void 0,nc.GOOGLEMAPS=t.googleMapsToken||void 0,this.state=new A({time:{type:"f",value:0},loaded:!1,added:!1,ready:!1}),this.renderer=new l.WebGLRenderer({antialias:!0,powerPreference:"high-performance",alpha:this.transparentBackground,premultipliedAlpha:!0}),this.renderer.setClearColor(this.transparentBackground?0:16777215,this.transparentBackground?0:1),this.renderer.toneMapping=l.AgXToneMapping,this.renderer.outputColorSpace=l.SRGBColorSpace,this.renderer.toneMappingExposure=1,this.renderer.supportedFloatType=this.renderer.getContext().getSupportedExtensions().indexOf("OES_texture_float_linear")>=0?l.FloatType:l.HalfFloatType,this.renderer.autoClear=!1,this.css2DRenderer=new f,this.css2DRenderer.domElement.style.setProperty("position","absolute"),this.css2DRenderer.domElement.style.setProperty("left","0"),this.css2DRenderer.domElement.style.setProperty("top","0"),this.css2DRenderer.domElement.style.setProperty("pointer-events","none"),this.clock=new l.Clock,this.camera=new l.PerspectiveCamera(90,1,10,1e8),this.camera.up.set(0,0,1),this.camera.position.fromArray(l.geodeticToEcefPosition(-105.18896,39.93,9e3)),this.camera.lookAt((new l.Vector3).fromArray(l.geodeticToEcefPosition(-105.18896,40,0))),this.cameraForward=new l.Vector3,this.cameraRight=new l.Vector3,this.cameraUp=new l.Vector3,this.scene=new l.Scene,this.content=new l.Group,this.scene.add(this.content),this.contentLayerRegistry=new Lc({group:this.content,createLayer:e=>this.createContentLayer(e),onError:(e,t)=>this.dispatchEvent({type:eh.CONTENT_LAYER_ERROR,layerId:"string"==typeof(null==e?void 0:e.id)&&e.id.length>0?e.id:null,error:t instanceof Error?t:new Error(String(t))}),onAllSplatsDisabled:()=>this.disposeSparkRenderer()}),this.splatDestinationPrefetch=new Dc({getRenderer:()=>this.sparkRenderer,getLayer:e=>this.contentLayerRegistry.getActiveLayer(e)}),this.topLayerIndex=0,this.enabledLayers=[],this.labels=new Map,this.features=new Map,this.globeControls=new Vr(this.scene,this.camera,this.renderer.domElement),this.globeControls.enableDamping=!0,this._viewModeState={version:0,confirmedRotationSpeed:this.globeControls.rotationSpeed},this.desktopNavigationController=null,this._desktopControlsBefore=null,this.desktopLookControls=null,this._onGlobeControlsStart=()=>{this.transitionControls.cancel(),this.globeControls.adjustHeight=!0},this.globeControls.addEventListener("start",this._onGlobeControlsStart),this.transitionControls=new pc(this.camera),this.tileDecoders=new ts(this.renderer),this.globeManager=new Yl(this.scene,this.camera,this.renderer,{apiToken:nc.CESIUM,googleMapsToken:nc.GOOGLEMAPS,decoders:this.tileDecoders}),this._onGlobeTileLoaded=()=>this.dispatchEvent({type:eh.GLOBE_TILE_LOADED}),this.globeManager.addEventListener("globe-tile-loaded",this._onGlobeTileLoaded),this.globeManager.tiles&&(this.globeManager.tiles.group.visible=!this.transparentBackground,this.globeControls.setTilesRenderer(this.globeManager.tiles)),this.camera.updateMatrixWorld(!0),this.cameraCoords=Ys(this.camera.position.x,this.camera.position.y,this.camera.position.z,this.camera.quaternion),this.pointerCoords={},this.pointerXYZ=new l.Vector3,this.keysDown={},this._keysEnabled=!0,this.movementSpeed=100,this.boostMultiplier=5,this.movementKeys={BOOST:["ShiftLeft","ShiftRight"],FRONT:["KeyW"],BACK:["KeyS"],LEFT:["KeyA"],RIGHT:["KeyD"],UP:["KeyE"],DOWN:["KeyQ"]},this.movementState={BOOST:!1,FRONT:!1,BACK:!1,LEFT:!1,RIGHT:!1,UP:!1,DOWN:!1},this._onKeyDown=e=>{var t;this.desktopNavigationController&&this.keysEnabled&&(null==(t=this.desktopLookControls)?void 0:t.handleKeyDown(e))||e.repeat&&!this.keysDown[e.code]||(this.keysDown[e.code]=!0,this.updateMovementState())},this._onKeyUp=e=>{this.keysDown[e.code]=!1,this.updateMovementState()},this._onResize=e=>{this.resizeView(e)},this._onWindowBlur=()=>this._clearHeldKeys(),this._onVisibilityChange=()=>{document.hidden&&this._clearHeldKeys()},window.addEventListener("keydown",this._onKeyDown),window.addEventListener("keyup",this._onKeyUp),window.addEventListener("resize",this._onResize),window.addEventListener("blur",this._onWindowBlur),document.addEventListener("visibilitychange",this._onVisibilityChange),e&&this.appendTo(e),this.sky=new mc,this.sky.scale.setScalar(2e7),this.sky.visible=!this.transparentBackground,this.scene.add(this.sky);const i=l.MathUtils.degToRad(80),r=l.MathUtils.degToRad(180),a=(new l.Vector3).setFromSphericalCoords(1,i,r);this.sky.material.uniforms.sunPosition.value=a,this.pointerRaycaster=new l.Raycaster,this._onPointerMove=e=>{if(!this.globeManager.tiles)return void(this.pointerCoords={});const t={};t.x=e.clientX/window.innerWidth*2-1,t.y=-e.clientY/window.innerHeight*2+1,this.pointerRaycaster.setFromCamera(t,this.camera);const i=this.pointerRaycaster.intersectObject(this.globeManager.tiles.group,!0);if(i.length>0){const e=i[0];e?(this.pointerCoords=l.ecefToGeodeticPosition(e.point.x,e.point.y,e.point.z),this.pointerXYZ.copy(e.point)):this.pointerCoords={}}else this.pointerCoords={}},window.addEventListener("pointermove",this._onPointerMove),this.setAnimate()}get xrActive(){var e;return(null==(e=this.xrSession)?void 0:e.active)??!1}startXRSession(e={}){var t,i;return this.disposed?Promise.reject(new Error("Viewer has been disposed")):(null==(i=null==(t=this.desktopNavigationController)?void 0:t.interrupt)||i.call(t,"XR session started"),this.xrSession?(this.xrSession.onFrame=e.onFrame,this.xrSession.onStateChange=e.onStateChange):this.xrSession=new Hc(this,e),this.xrSession.start())}endXRSession(){var e;return(null==(e=this.xrSession)?void 0:e.stop())??Promise.resolve()}getXRFrameInput(e){return function(e,t){var i;return t?{head:qc(null==(i=e.getViewerPose(t))?void 0:i.transform),controllers:[...e.session.inputSources].map((i=>{var r,a;const s=i.gamepad;return{handedness:i.handedness,mapping:(null==s?void 0:s.mapping)??null,axes:s?[...s.axes]:[],buttons:s?s.buttons.map((e=>({pressed:e.pressed,touched:e.touched,value:e.value}))):[],ray:qc(null==(r=e.getPose(i.targetRaySpace,t))?void 0:r.transform),grip:i.gripSpace?qc(null==(a=e.getPose(i.gripSpace,t))?void 0:a.transform):null}}))}:{head:null,controllers:[]}}(e,this.renderer.xr.getReferenceSpace())}setXRPlayerPose(e){var t;if(!(null==(t=this.xrSession)?void 0:t.bridge))throw new Error("No tracked XR head pose is available");this.xrSession.bridge.setPlayerPose(e)}setXRVisualBlend(e){var t;if(!(null==(t=this.xrSession)?void 0:t.bridge))throw new Error("No tracked XR head pose is available");this.xrSession.bridge.setVisualBlend(e)}getXRHeadPose(){var e,t;return(null==(t=null==(e=this.xrSession)?void 0:e.bridge)?void 0:t.getHeadPose())??null}getXRHeadForward(){var e,t;return(null==(t=null==(e=this.xrSession)?void 0:e.bridge)?void 0:t.getHeadForward())??null}getXRControllerWorldRay(e){var t,i;return(null==(i=null==(t=this.xrSession)?void 0:t.bridge)?void 0:i.getControllerWorldRay(e))??null}setXRComfortMoving(e){var t,i;null==(i=null==(t=this.xrSession)?void 0:t.bridge)||i.setComfortMoving(e)}setXRNavigationLimit(e){var t,i;null==(i=null==(t=this.xrSession)?void 0:t.bridge)||i.setNavigationLimit(e)}setXRNavigationCue(e){var t,i;null==(i=null==(t=this.xrSession)?void 0:t.bridge)||i.setNavigationCue(e)}setXRAttribution(e){var t,i;null==(i=null==(t=this.xrSession)?void 0:t.bridge)||i.setTerrainCredits(e)}setXRNavigationFade(e){var t,i;null==(i=null==(t=this.xrSession)?void 0:t.bridge)||i.setFade(e)}get keysEnabled(){return this._keysEnabled}set keysEnabled(e){e!==this._keysEnabled&&(this._keysEnabled=e,this._clearHeldKeys())}_clearHeldKeys(){this.keysDown={};for(const e in this.movementState)this.movementState[e]=!1}updateMovementState(){if(this.keysEnabled){for(const e in this.movementKeys){this.movementState[e]=!1;for(let t=0;t<this.movementKeys[e].length;t++){const i=this.movementKeys[e][t];if(this.keysDown[i]){this.movementState[e]=!0;break}}}(this.movementState.FRONT||this.movementState.BACK||this.movementState.LEFT||this.movementState.RIGHT||this.movementState.UP||this.movementState.DOWN)&&this.globeControls&&(this.globeControls.adjustHeight=!0)}}setDesktopNavigationController(e){var t,i,r,a;if(!(this.desktopNavigationController===e||e&&this.xrActive))if(this._clearHeldKeys(),e){this.transitionControls.cancel(),this.desktopNavigationController&&(null==(i=(t=this.desktopNavigationController).interrupt)||i.call(t,"replaced")),this._desktopControlsBefore||(this._desktopControlsBefore={enabled:this.globeControls.enabled,rotationSpeed:this.globeControls.rotationSpeed}),this.globeControls.enabled=!1,this.globeControls.adjustHeight=!1,this.globeControls.globeInertiaFactor=0,this.globeControls.globeInertia.identity(),this.desktopNavigationController=e;const a=null==(r=this.renderer)?void 0:r.domElement;(null==a?void 0:a.getRootNode)&&!this.desktopLookControls&&(this.desktopLookControls=new Wc(a,((e,t)=>this._applyDesktopLook(e,t)))),(null==a?void 0:a.focus)&&(a.tabIndex<0&&(a.tabIndex=0),a.focus({preventScroll:!0}))}else this.desktopNavigationController=null,null==(a=this.desktopLookControls)||a.dispose(),this.desktopLookControls=null,this._desktopControlsBefore&&(this.globeControls.adjustHeight=!0,this.globeControls.rotationSpeed=this._desktopControlsBefore.rotationSpeed,this.globeControls.enabled=this._desktopControlsBefore.enabled,this._desktopControlsBefore=null)}_applyDesktopLook(e,t){var i,r;if(!this.desktopNavigationController||!1===(null==(r=(i=this.desktopNavigationController).canLook)?void 0:r.call(i))||this.xrActive)return;const{lon:a,lat:s,pitch:n,yaw:o,roll:c}=this.cameraCoords;if(![a,s,n,o,c,e,t].every(Number.isFinite))return;const h=l.MathUtils.clamp(n-.15*t,-80,80),d=o-.15*e;this.camera.quaternion.copy($s(a,s,h,d,c)),this.camera.updateMatrixWorld(!0),this.cameraCoords=Ys(this.camera.position.x,this.camera.position.y,this.camera.position.z,this.camera.quaternion)}turnDesktopNorth(){if(!this.desktopNavigationController||this.xrActive)return!1;const{lon:e,lat:t,pitch:i,roll:r}=this.cameraCoords;return!![e,t,i,r].every(Number.isFinite)&&(this.camera.quaternion.copy($s(e,t,i,0,r)),this.camera.updateMatrixWorld(!0),this.cameraCoords=Ys(this.camera.position.x,this.camera.position.y,this.camera.position.z,this.camera.quaternion),!0)}_applyDesktopNavigationFrame(e,t){const i=this.desktopNavigationController;if(!i||this.xrActive)return;const r=this.cameraCoords,a=i.update({timeMs:e,deltaSeconds:t,pose:{lon:r.lon,lat:r.lat,alt:r.alt,pitch:r.pitch,yaw:r.yaw,roll:r.roll},movement:{...this.movementState}}),{longitude:s,latitude:n,altitude:o}=(null==a?void 0:a.position)??{};![s,n,o].every(Number.isFinite)||s<-180||s>180||n<-90||n>90||void 0!==a.pitch&&!Number.isFinite(a.pitch)||(this.camera.position.fromArray(l.geodeticToEcefPosition(s,n,o)),void 0!==a.pitch&&this.camera.quaternion.copy($s(s,n,a.pitch,r.yaw,r.roll)),this.camera.updateMatrixWorld(!0),this.cameraCoords=Ys(this.camera.position.x,this.camera.position.y,this.camera.position.z,this.camera.quaternion))}getElevation(e,t,i={}){l.validateGeodeticPosition(e,t,1e4,"Elevation query");const r=(new l.Vector3).fromArray(l.geodeticToEcefPosition(e,t,1e4)),a=Zs(e,t).negate(),s=new l.Raycaster;s.ray.set(r,a);const n=this._raycastSurfaces(s,i);if(!n)throw new Error(`Elevation query found no loaded surface at ${e}, ${t}.`);const o=l.ecefToGeodeticPosition(n.point.x,n.point.y,n.point.z);return l.validateGeodeticPosition(o.lon,o.lat,o.alt,"Computed elevation"),{...o,source:n.source,layerId:n.layerId}}updateCoordsElevation(e){for(let t=0;t<e.length;t++){const[i,r]=e[t];e[t][2]=this.getElevation(i,r).alt}return e}setBackgroundColor(e){this.renderer.setClearColor(e,this.transparentBackground?0:1)}appendTo(e){this.container=e,this.container.appendChild(this.renderer.domElement),this.container.appendChild(this.css2DRenderer.domElement),this.resizeView(),this.state.update({added:!0}),this.dispatchEvent({type:eh.APPENDED})}updateCameraDirections(){const e=new l.Matrix4;e.extractRotation(this.camera.matrixWorld),this.cameraForward.set(0,0,-1).applyMatrix4(e),this.cameraRight.set(1,0,0).applyMatrix4(e),this.cameraUp.set(0,1,0).applyMatrix4(e)}setAnimate(e=!0){e?this.renderer.setAnimationLoop(((e,t)=>{this.animate(e)})):this.renderer.setAnimationLoop(null)}resizeView(e){if(this.container){const e=this.container.offsetWidth,t=this.container.offsetHeight;this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.renderer.setSize(e,t),this.css2DRenderer.setSize(e,t),this.renderer.render(this.scene,this.camera),this.css2DRenderer.render(this.scene,this.camera)}}async loadEnv(e){const t=await new hc(e,{floatType:this.renderer.supportedFloatType});t.mapping=l.EquirectangularReflectionMapping,this.scene.environment=t,this.scene.environmentRotation.set(Math.PI/2,0,0)}clearContentLayers(){var e;null==(e=this.splatDestinationPrefetch)||e.clear("cancel"),this.contentLayerRegistry.clear(),this.disposeSparkRenderer()}async ensureSparkRenderer(){if(this.sparkRenderer)return this.sparkRenderer;const e=this.sparkRendererGeneration??0,{SparkRenderer:t}=await b();return this.disposed||e!==(this.sparkRendererGeneration??0)?null:(this.sparkRenderer||(this.sparkRenderer=new t({renderer:this.renderer}),this.sparkRenderer.layers.set(0),this.scene.add(this.sparkRenderer)),this.sparkRenderer)}disposeSparkRenderer(){var e,t,i;this.sparkRendererGeneration=(this.sparkRendererGeneration??0)+1,this.sparkRenderer&&(null==(e=this.splatDestinationPrefetch)||e.sync(),this.sparkRenderer.removeFromParent(),null==(i=(t=this.sparkRenderer).clearSplats)||i.call(t),this.sparkRenderer.dispose(),this.sparkRenderer=null)}prepareContentLayerDefinition(e){const t="gaussian-splat"===(null==e?void 0:e.type)?function(e){var t,i,r,a;if(!e||"object"!=typeof e)throw new Error("Gaussian splat layer definition must be an object.");if(vc(e.id,"id"),vc(e.name,"name"),"gaussian-splat"!==e.type)throw new Error('type must be "gaussian-splat".');if(!Array.isArray(e.labels)||!e.labels.every((e=>"string"==typeof e)))throw new Error("labels must be an array of strings.");if(vc(null==(t=e.data)?void 0:t.url,"data.url"),!yc.has(null==(i=e.data)?void 0:i.format))throw new Error('data.format must be "ply", "sog", "spz", or "rad".');if(0!==((null==(r=e.options)?void 0:r.renderOrder)??0))throw new Error("Gaussian splat layers only support renderOrder 0.");const s=null==(a=e.options)?void 0:a.transform,n=null==s?void 0:s.anchor;if(!n)throw new Error("options.transform.anchor must contain finite longitude, latitude, and altitude values.");l.validateGeodeticPosition(n.longitude,n.latitude,n.altitude,"Gaussian anchor");const o=s.translationENU??[0,0,0],c=s.rotationDegrees??[0,0,0],h=s.scale??1;return l.validateTuple(o,"translationENU"),l.validateTuple(c,"rotationDegrees"),l.validateScale(h,"scale"),{...e,labels:[...e.labels],data:{...e.data},options:{...e.options,renderOrder:0,transform:{anchor:{...n},translationENU:[...o],rotationDegrees:[...c],scale:h}}}}(e):e;if("string"!=typeof(null==t?void 0:t.id)||!t.id||!Array.isArray(t.labels))throw new Error("Content layer requires a non-empty id and labels array.");if(!["3d-tiles","mesh","geojson","gaussian-splat"].includes(t.type))throw new Error(`Unsupported content layer type: ${String(t.type)}`);return t}createContentLayer(e){const t=t=>this.dispatchEvent({type:eh.CONTENT_LAYER_ERROR,layerId:e.id,error:t});switch(e.type){case"3d-tiles":return new gc(e.data.url,{camera:this.camera,renderer:this.renderer,...e.options,decoders:this.tileDecoders},{onError:t});case"mesh":return new wc(e.data.url,{...e.options,decoders:this.tileDecoders},{onError:t});case"geojson":return new kc(e.data,e.options,{onError:t});case"gaussian-splat":return new Fc(e,{ensureRenderer:()=>this.ensureSparkRenderer(),releasePagedSplats:e=>{var t,i;return null==(i=null==(t=this.sparkRenderer)?void 0:t.releasePagedSplats)?void 0:i.call(t,e)},onStart:e=>this.dispatchEvent({type:eh.CONTENT_LAYER_LOAD_START,layerId:e.contentLayerId}),onProgress:(e,t)=>this.dispatchEvent({type:eh.CONTENT_LAYER_LOAD_PROGRESS,layerId:e.contentLayerId,progress:t}),onReady:e=>{this.dispatchEvent({type:eh.CONTENT_LAYER_READY,layerId:e.contentLayerId}),this.splatDestinationPrefetch.sync()},onError:(e,t)=>this.dispatchEvent({type:eh.CONTENT_LAYER_ERROR,layerId:e.contentLayerId,error:t})});default:throw new Error(`Unsupported content layer type: ${String(e.type)}`)}}reportContentLayerError(e,t){this.dispatchEvent({type:eh.CONTENT_LAYER_ERROR,layerId:"string"==typeof(null==e?void 0:e.id)&&e.id.length>0?e.id:null,error:t instanceof Error?t:new Error(String(t))})}refreshContentLayerDepth(){this.topLayerIndex=Math.max(0,...this.content.children.map((e=>Math.max(e.contentRenderOrder??0,e.xrRenderLayer??0)))),this.globeControls.pivotMesh.layers.set(this.topLayerIndex)}defineContentLayers(e=[]){const t=[];for(const r of e)try{t.push(this.prepareContentLayerDefinition(r))}catch(i){this.reportContentLayerError(r,i)}this.contentLayerRegistry.setDefinitions(t),this.splatDestinationPrefetch.sync(),this.refreshContentLayerDepth()}replaceContentLayer(e,t){if(this.disposed)return;if("string"!=typeof e||0===e.length)throw new Error("Content layer id must be a non-empty string.");if(t&&t.id!==e)throw new Error("Replacement layer id must match the requested id.");let i=null;if(t)try{i=this.prepareContentLayerDefinition(t)}catch(r){return void this.reportContentLayerError(t,r)}this.contentLayerRegistry.replaceDefinition(e,i)&&(this.splatDestinationPrefetch.sync(),this.refreshContentLayerDepth())}enableContentLayers(e=[]){this.enabledLayers=e,this.contentLayerRegistry.setEnabledLabels(e),this.splatDestinationPrefetch.sync(),this.refreshContentLayerDepth()}setTimeFrame(e,t){this.timeFrameStart=e?new Date(e):null,this.timeFrameEnd=t?new Date(t):null,this.contentLayerRegistry.setTimeFrame(this.timeFrameStart,this.timeFrameEnd)}updateLabel(e,t){var i,r;const{longitude:a,latitude:s,altitude:n}=l.validateGeodeticPosition(null==t?void 0:t.lon,null==t?void 0:t.lat,null==t?void 0:t.alt,"Label position"),o=t.visible??!0,h=t.hovered??!1,d=t.selected??!1;let u=null;if(this.labels.has(e))u=this.labels.get(e);else{const i=t.element??document.createElement("div");u=new c(i);const r=new l.Mesh(new l.PlaneGeometry(1e3,1e3),new l.MeshBasicMaterial({map:new l.CanvasTexture(Kc),opacity:1,transparent:!0,side:l.DoubleSide}));r.layers.set(this.topLayerIndex),u.add(r),u.lookAt(0,0,0),this.scene.add(u),this.labels.set(e,u)}return t.element&&t.element!==u.element&&(null==(r=(i=u.element).remove)||r.call(i),u.element=new c(t.element).element),u.position.fromArray(l.geodeticToEcefPosition(a,s,n)),u.lookAt(0,0,0),u.visible=o,h?u.element.classList.add("hovered"):u.element.classList.remove("hovered"),d?u.element.classList.add("selected"):u.element.classList.remove("selected"),u.element}animate(e){var t,i,r;if(this.loadingDiagnosticsEnabled){null===this.diagnosticWindowStart&&(this.diagnosticWindowStart=e),this.diagnosticFrameCount++;const t=e-this.diagnosticWindowStart;t>=1e3&&(this.diagnosticFps=Math.round(1e3*this.diagnosticFrameCount/t),this.diagnosticWindowStart=e,this.diagnosticFrameCount=0)}this.transitionControls.update(e),this.state.get("time").value=e;const a=this.clock.getDelta();this.globeControls.update(),this.camera.updateMatrixWorld(),this.updateCameraDirections(),this.cameraCoords=Ys(this.camera.position.x,this.camera.position.y,this.camera.position.z,this.camera.quaternion),this.sky.setSurfaceUp(Zs(this.cameraCoords.lon,this.cameraCoords.lat)),this.desktopNavigationController?(this._applyDesktopNavigationFrame(e,a),this.updateCameraDirections()):this.keysEnabled&&function(e,t,i,r,a,s,n,o){const l=n*s*(a.BOOST?o:1);a.FRONT&&e.addScaledVector(t,l),a.BACK&&e.addScaledVector(t,-l),a.LEFT&&e.addScaledVector(i,-l),a.RIGHT&&e.addScaledVector(i,l),a.UP&&e.addScaledVector(r,l),a.DOWN&&e.addScaledVector(r,-l)}(this.camera.position,this.cameraForward,this.cameraRight,this.cameraUp,this.movementState,a,this.movementSpeed,this.boostMultiplier),this.globeManager.update();for(let s=0;s<this.content.children.length;s++){this.content.children[s].update()}for(const[s,n]of this.labels)if(n.element){n.element.classList.remove("far"),n.element.classList.remove("mid"),n.element.classList.remove("close");const e=(new l.Vector3).subVectors(n.position,this.camera.position).dot(this.cameraForward);n.scale.setScalar(e/1e4),n.children[0].material.opacity=Math.min(Math.max(1-e/2e3,.1),1),e>3200?n.element.classList.add("far"):e>1e3?n.element.classList.add("mid"):n.element.classList.add("close")}for(let s=0;s<this.topLayerIndex+1;s++)s>0&&(null==(t=this.xrSession)?void 0:t.active)&&!this.content.children.some((e=>{var t;return e.visible&&(e.xrRenderLayer===s||(null==(t=e.layers)?void 0:t.isEnabled(s)))}))||(this.camera.layers.set(s),0==s?(this.renderer.clear(),this.render()):(this.renderer.clearDepth(),this.renderer.render(this.scene,this.camera)));(null==(i=this.xrSession)?void 0:i.active)&&(null==(r=this.xrSession.bridge)?void 0:r.hasUi())&&(this.camera.layers.set(31),this.renderer.clearDepth(),this.renderer.render(this.scene,this.camera)),this.cameraCoords=Ys(this.camera.position.x,this.camera.position.y,this.camera.position.z,this.camera.quaternion),this.dispatchEvent({type:eh.ANIMATED,time:e,deltaTime:a})}render(){this.splatDestinationPrefetch.sync(),this.renderer.render(this.scene,this.camera),this.css2DRenderer.render(this.scene,this.camera),!0===this.state.get("added")&&!1===this.state.get("ready")&&(this.state.update({ready:!0}),window.setTimeout((()=>{this.dispatchEvent({type:eh.READY})}),0))}pickCoordinates(e,t,i={}){var r;const a=null==(r=this.renderer)?void 0:r.domElement.getBoundingClientRect();if(!a||a.width<=0||a.height<=0||!Number.isFinite(e)||!Number.isFinite(t)||e<a.left||e>a.right||t<a.top||t>a.bottom)return null;this.pickRaycaster??(this.pickRaycaster=new l.Raycaster),this.camera.updateMatrixWorld(),this.pickRaycaster.setFromCamera({x:(e-a.left)/a.width*2-1,y:-(t-a.top)/a.height*2+1},this.camera);const s=this._raycastSurfaces(this.pickRaycaster,i);if(!s)return null;const n=l.ecefToGeodeticPosition(s.point.x,s.point.y,s.point.z);return l.validateGeodeticPosition(n.lon,n.lat,n.alt,"Picked coordinates"),{...n,point:s.point.clone(),source:s.source,layerId:s.layerId}}_raycastSurfaces(e,t){return Uc(this,e,t)}getCameraPivot(){let e=null;const t=new l.Raycaster;if(t.setFromCamera({x:0,y:0},this.camera),this.globeManager.tiles){const i=t.intersectObject(this.globeManager.tiles.group,!0);if(i.length>0){const t=i[0];t&&(e=t.point.clone())}}return e||(e=(new l.Vector3).subVectors(this.camera.position,this.cameraForward.clone().multiplyScalar(2e3))),e}async alignCamera(e,t,i,r,a,s,n){var o,c;null==(c=null==(o=this.desktopNavigationController)?void 0:o.interrupt)||c.call(o,"alignCamera");const h=l.validateGeodeticPosition(e,t,i,"Camera position"),d=l.validateRotation(r??this.cameraCoords.pitch,a??this.cameraCoords.yaw,s??this.cameraCoords.roll,"Camera rotation"),u=l.requireFiniteNumber(n??oc,"Camera transition duration"),p=(new l.Vector3).fromArray(l.geodeticToEcefPosition(h.longitude,h.latitude,h.altitude)),m=$s(h.longitude,h.latitude,d.pitch,d.yaw,d.roll);return this.globeControls&&(this.globeControls.adjustHeight=!1),this.transitionControls.animateTo(p,m,u).then((r=>(r&&this.dispatchEvent({type:eh.TRANSITIONED,lon:e,lat:t,alt:i,...d}),r)))}async focusCamera(e,t,i,r,a,s){var n,o;null==(o=null==(n=this.desktopNavigationController)?void 0:n.interrupt)||o.call(n,"focusCamera");const c=l.validateGeodeticPosition(e,t,i,"Camera focus"),h=l.requireFiniteNumber(r??2e3,"Camera focus distance"),d=l.validateRotation(a??this.cameraCoords.pitch,0,0,"Camera rotation"),u=l.requireFiniteNumber(s??oc,"Camera transition duration"),p=(new l.Vector3).fromArray(l.geodeticToEcefPosition(c.longitude,c.latitude,c.altitude)),m=$s(c.longitude,c.latitude,d.pitch,d.yaw,d.roll),f=new l.Vector3(0,0,1).applyQuaternion(m);return p.addScaledVector(f,h),this.globeControls&&(this.globeControls.adjustHeight=!0),this.transitionControls.animateTo(p,m,u).then((r=>(r&&this.dispatchEvent({type:eh.TRANSITIONED,lon:e,lat:t,alt:i}),r)))}setDestinationTilePrefetch(e){this.disposed||this.globeManager.setDestinationTilePrefetch(e)}setDestinationSplatPrefetch(e,t="cancel"){if(!this.disposed)if(e){try{l.validateGeodeticPosition(e.longitude,e.latitude,e.altitude,"Destination splat prefetch"),l.validateRotation(e.pitch,e.yaw,e.roll,"Destination splat prefetch rotation")}catch{return}Array.isArray(e.layerIds)&&e.layerIds.every((e=>"string"==typeof e))&&["desktop","xr"].includes(e.mode)&&this.splatDestinationPrefetch.set(e)}else this.splatDestinationPrefetch.clear(t)}setLoadingDiagnosticsEnabled(e){this.loadingDiagnosticsEnabled=Boolean(e),e||(this.diagnosticFps=null,this.diagnosticWindowStart=null,this.diagnosticFrameCount=0)}getLoadingDiagnostics(){return function(e){var t,i,r,a,s,n,o,l;const c=null==(i=null==(t=e.globeManager)?void 0:t.tiles)?void 0:i.stats,h=null==(r=e.sparkRenderer)?void 0:r.pager,d=c&&[c.queued,c.downloading,c.parsing].map(dc);let u=null;if(h&&[h.fetchPriority,h.fetchers,h.fetched].every(Array.isArray)){const e=new Map;for(const{splats:t,chunk:i}of[...h.fetchPriority,...h.fetchers,...h.fetched])t&&Number.isInteger(i)&&!(null==(a=h.getSplatsChunk)?void 0:a.call(h,t,i))&&(e.has(t)||e.set(t,new Set),e.get(t).add(i));u=[...e.values()].reduce(((e,t)=>e+t.size),0)}return{fps:dc(e.diagnosticFps),tilesVisible:dc(null==c?void 0:c.visible),tilesPending:(null==d?void 0:d.every((e=>null!==e)))?d.reduce(((e,t)=>e+t),0):null,tilesFailed:dc(null==c?void 0:c.failed),radPages:dc(null==(s=null==h?void 0:h.pageLru)?void 0:s.size),radPending:u,gpuTextures:dc(null==(l=null==(o=null==(n=e.renderer)?void 0:n.info)?void 0:o.memory)?void 0:l.textures)}}(this)}setXRDiagnosticsPanel(e){var t,i;this.xrDiagnosticsRows=Array.isArray(e)&&e.length>0?e.slice(0,5).map(String):null,null==(i=null==(t=this.xrSession)?void 0:t.bridge)||i.setDiagnosticsRows(this.xrDiagnosticsRows)}async angleCamera(e,t,i){var r,a;null==(a=null==(r=this.desktopNavigationController)?void 0:r.interrupt)||a.call(r,"angleCamera");const s=l.validateRotation(e??this.cameraCoords.pitch,t??this.cameraCoords.yaw,0,"Camera rotation"),n=l.requireFiniteNumber(i??oc,"Camera transition duration"),o=this.getCameraPivot(),{lon:c,lat:h,alt:d}=l.ecefToGeodeticPosition(o.x,o.y,o.z),u=this.camera.position.distanceTo(o),p=(new l.Vector3).fromArray(l.geodeticToEcefPosition(c,h,d)),m=$s(c,h,s.pitch,s.yaw,s.roll),f=new l.Vector3(0,0,1).applyQuaternion(m);return p.addScaledVector(f,u),this.transitionControls.animateTo(p,m,n).then((e=>(e&&this.dispatchEvent({type:eh.TRANSITIONED,lon:c,lat:h,alt:d}),e)))}async setViewMode(e="3d"){var t,i;null==(i=null==(t=this.desktopNavigationController)?void 0:t.interrupt)||i.call(t,"setViewMode");const r=this._viewModeState??(this._viewModeState={version:0,confirmedRotationSpeed:this.globeControls.rotationSpeed}),a=++r.version,s="3d"===e?1:0;this.globeControls.rotationSpeed=s;try{const t="3d"===e?await this.angleCamera(-60,void 0,500):await this.angleCamera(-90,0,500);return r.version!==a||this.disposed||(t?r.confirmedRotationSpeed=s:this.globeControls.rotationSpeed=r.confirmedRotationSpeed),t}catch(n){throw r.version!==a||this.disposed||(this.globeControls.rotationSpeed=r.confirmedRotationSpeed),n}}exportScene(){return e=this.scene,void(new as).parse(e,(e=>{const t=new Blob([e],{type:"application/octet-stream"}),i=URL.createObjectURL(t),r=document.createElement("a");r.href=i,r.download="scene.glb",document.body.appendChild(r),r.click(),document.body.removeChild(r)}),(e=>{}),{binary:!0});var e}saveScreenshot(e="screenshot"){for(let r=0;r<this.topLayerIndex+1;r++)this.camera.layers.set(r),0==r?(this.renderer.clear(),this.render()):(this.renderer.clearDepth(),this.renderer.render(this.scene,this.camera));const t=this.renderer.domElement.toDataURL(),i=document.createElement("a");i.setAttribute("href",t),i.setAttribute("target","_blank"),i.setAttribute("download",`${e}.png`),i.click()}dispose(){var e,t,i,r,a,s,n,o,l,c,h,d,u,p,m,f;if(!this.disposed){this.disposed=!0,null==(e=this.splatDestinationPrefetch)||e.dispose(),null==(i=null==(t=this.desktopNavigationController)?void 0:t.interrupt)||i.call(t,"viewer disposed"),(this.desktopNavigationController||this.desktopLookControls)&&this.setDesktopNavigationController(null),this.xrSession&&(this.xrSession.dispose().catch((e=>{})),this.xrSession=null),this.setAnimate(!1),this.transitionControls.cancel(),this.clearContentLayers(),window.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("keyup",this._onKeyUp),window.removeEventListener("resize",this._onResize),window.removeEventListener("blur",this._onWindowBlur),document.removeEventListener("visibilitychange",this._onVisibilityChange),window.removeEventListener("pointermove",this._onPointerMove),this.globeControls.removeEventListener("start",this._onGlobeControlsStart),this.globeControls.dispose(),this.globeManager.removeEventListener("globe-tile-loaded",this._onGlobeTileLoaded),this.globeManager.dispose(),this.tileDecoders.dispose();for(const e of this.labels.values())e.traverse((e=>{var t,i,r,a,s;if(null==(i=null==(t=e.geometry)?void 0:t.dispose)||i.call(t),e.material){const t=Array.isArray(e.material)?e.material:[e.material];for(const e of t)null==(a=null==(r=e.map)?void 0:r.dispose)||a.call(r),null==(s=e.dispose)||s.call(e)}})),e.removeFromParent();this.labels.clear(),this.features.clear(),null==(a=null==(r=this.scene.environment)?void 0:r.dispose)||a.call(r),this.scene.environment=null,null==(o=null==(n=null==(s=this.sky)?void 0:s.geometry)?void 0:n.dispose)||o.call(n),null==(h=null==(c=null==(l=this.sky)?void 0:l.material)?void 0:c.dispose)||h.call(c),null==(d=this.sky)||d.removeFromParent(),this.css2DRenderer.domElement.remove(),this.renderer.domElement.remove(),null==(p=null==(u=this.renderer.renderLists)?void 0:u.dispose)||p.call(u),this.renderer.dispose(),null==(f=(m=this.renderer).forceContextLoss)||f.call(m),this.container=null,this.listeners={}}}},exports.ViewerEvents=eh;
|