@jdultra/threedtiles 14.0.8 → 14.0.9

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.
@@ -1394,5 +1394,5 @@ out vec2 vUv;
1394
1394
  void main() {
1395
1395
  vUv = uv;
1396
1396
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
1397
- }`}function Xt(B,A,g,I){const Q=B.getX(g),C=B.getY(g),E=B.getZ(g),a=A.getX(g),i=A.getY(g),t=A.getZ(g);I.set(Q,C,E,C,a,i,E,i,t)}function Zt(B,A,g){const I=B.determinant();if(Math.abs(I)<1e-12)return void g.set(0,0,0);const Q=1/I,C=new d.Matrix3().copy(B);C.elements[0]=A.x,C.elements[3]=A.y,C.elements[6]=A.z;const E=new d.Matrix3().copy(B);E.elements[1]=A.x,E.elements[4]=A.y,E.elements[7]=A.z;const a=new d.Matrix3().copy(B);a.elements[2]=A.x,a.elements[5]=A.y,a.elements[8]=A.z,g.set(C.determinant()*Q,E.determinant()*Q,a.determinant()*Q)}new d.Vector3,new d.Vector3;var yA;new d.Matrix3().set(1,0,0,0,0,1,0,-1,0),new d.Matrix4().set(1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1);const fg=new V.Sphere(new V.Vector3(0,0,0),1),Sg=new cg([0,0,0,1,0,0,0,1,0,0,0,1]);new V.Box3;const Wg=new V.Vector3(0,0,0),lI=new V.Vector3(0,0,0),_t=new V.Vector3(0,1,0),eB=new V.Ray,iB=new V.Matrix4;new V.Matrix4,new V.Frustum;const tB=new V.Vector3,oB=[],TC=new V.Quaternion,Rg={};function Ma(){var B=[];for(let A in Rg)Rg.hasOwnProperty(A)&&Rg[A]>0&&B.push(A);return B}class JQ extends V.Object3D{constructor(A){super();const g=this;if(g.splatsMesh=A.splatsMesh,g.oldUltraMeshSplats=A.oldUltraMeshSplats,g.iosCompatibility=A.iosCompatibility,g.splatsQuality=A.splatsQuality!=null?A.splatsQuality:.75,g.splatsCPUCulling=A.splatsCPUCulling!=null&&A.splatsCPUCulling,this.contentURL=[],A.domWidth&&A.domHeight?this.rendererSize=new V.Vector2(A.domWidth,A.domHeight):this.rendererSize=new V.Vector2(1e3,1e3),this.setClipShape(A.clipShape),this.loadingStrategy=A.loadingStrategy?A.loadingStrategy.toUpperCase():"INCREMENTAL",this.distanceBias=Math.max(1e-4,A.distanceBias?A.distanceBias:1),this.proxy=A.proxy,this.drawBoundingVolume=!!A.drawBoundingVolume&&A.drawBoundingVolume,this.displayErrors=A.displayErrors,this.displayCopyright=A.displayCopyright,A.queryParams&&(this.queryParams={...A.queryParams}),this.uuid=jE(),A.tileLoader)this.tileLoader=A.tileLoader;else{const C={};C.meshCallback=A.meshCallback?A.meshCallback:(a,i)=>{a.material.wireframe=!1,a.material.side=V.DoubleSide},C.pointsCallback=A.pointsCallback?A.pointsCallback:(a,i)=>{a.material.size=Math.pow(i,.33),a.material.sizeAttenuation=!0},C.proxy=this.proxy,C.renderer=A.renderer,C.dracoLoader=A.dracoLoader,C.ktx2Loader=A.ktx2Loader,g.tileLoader=new KE(C);const E=this.update;this.update=a=>{E.call(g,a),g.tileLoader.update()}}if(this.displayCopyright=!!A.displayCopyright,this.geometricErrorMultiplier=A.geometricErrorMultiplier?A.geometricErrorMultiplier:1,this.splatsCropRadius=Number.MAX_VALUE,this.splatsSizeMultiplier=1,this.renderer=A.renderer,this.meshCallback=A.meshCallback,this.loadOutsideView=A.loadOutsideView,this.cameraOnLoad=A.cameraOnLoad,this.parentTile=A.parentTile,this.occlusionCullingService=A.occlusionCullingService,this.static=A.static,this.occlusionCullingService&&(this.color=new V.Color,this.color.setHex(16777215*Math.random()),this.colorID=V.MathUtils.clamp(255*g.color.r,0,255)<<16^V.MathUtils.clamp(255*g.color.g,0,255)<<8^V.MathUtils.clamp(255*g.color.b,0,255)),this.static&&(this.matrixAutoUpdate=!1,this.matrixWorldAutoUpdate=!1),this.childrenTiles=[],this.meshContent=[],this.tileContent,this.refine,this.rootPath,this.geometricError,this.boundingVolume,this.json,this.materialVisibility=!1,this.level=A.level?A.level:0,this.hasMeshContent=0,this.hasUnloadedJSONContent=0,this.centerModel=A.centerModel,this.abortController=new AbortController,this.onLoadCallback=A.onLoadCallback,A.json)g._setup(A);else if(A.url){var I=A.url;if(g.queryParams){var Q="";for(let C in g.queryParams)g.queryParams.hasOwnProperty(C)&&(Q+="&"+C+"="+g.queryParams[C]);I.includes("?")?I+=Q:I+="?"+Q.substring(1)}(g.proxy?()=>fetch(g.proxy,{method:"POST",body:I,signal:g.abortController.signal}):()=>fetch(I,{signal:g.abortController.signal}))().then(C=>{if(!C.ok)throw new Error(`couldn't load "${A.url}". Request failed with status ${C.status} : ${C.statusText}`);C.json().then(E=>GQ(E,I)).then(E=>{g._setup({rootPath:_g.dirname(A.url),json:E})})}).catch(C=>{g.displayErrors&&OC(C)})}}setClipShape(A){if(A instanceof cg||A instanceof V.Sphere)this.clipShape=A;else if(A instanceof V.Box3){const g=new V.Vector3,I=new V.Vector3;A.getCenter(g),A.getSize(I).multiplyScalar(.5),this.clipShape=new cg([g.x,g.y,g.z,I.x,0,0,0,I.y,0,0,0,I.z])}else A=void 0;this.childrenTiles&&this.childrenTiles.forEach(g=>{g._setClipShape(this.clipShape)})}_setClipShape(A){this.clipShape=A,this.childrenTiles&&this.childrenTiles.forEach(g=>{g._setClipShape(this.clipShape)})}setSplatsSizeMultiplier(A){this.splatsSizeMultiplier=A,this.splatsMesh&&this.splatsMesh.setSplatsSizeMultiplier(this.splatsSizeMultiplier)}setSplatsCropRadius(A){this.splatsCropRadius=A,this.splatsMesh&&this.splatsMesh.setSplatsCropRadius(this.splatsCropRadius)}setSplatsDepthBias(A){this.splatsDepthBias=A,this.splatsMesh&&this.splatsMesh.setDepthBias(this.splatsDepthBias)}setSplatsCPUCulling(A){this.splatsCPUCulling=A,this.splatsMesh&&this.splatsMesh.setSplatsCPUCulling(A)}setSplatsQuality(A){this.splatsQuality=A,this.splatsMesh&&this.splatsMesh.setQuality(A)}updateMatrices(){this.updateMatrix(),this.splatsMesh&&this.splatsMesh.updateMatrix(),this.static&&(this.traverse(A=>{A.isObject3D&&(A.matrixWorldAutoUpdate=!0)}),this.splatsMesh&&(this.splatsMesh.matrixWorldAutoUpdate=!0)),this.updateMatrixWorld(!0),this.static&&(this.traverse(A=>{A.isObject3D&&(A.matrixWorldAutoUpdate=!1)}),this.splatsMesh&&(this.splatsMesh.matrixWorldAutoUpdate=!1))}setCanvasSize(A,g){this.rendererSize.set(A,g)}async _setup(A){const g=this;if(A.json.extensionsRequired&&(A.json.extensionsRequired.includes("JDULTRA_gaussian_splats")||A.json.extensionsRequired.includes("JDULTRA_gaussian_splats_V2"))&&(g.oldUltraMeshSplats=!0),A.json.root?(g.json=A.json.root,g.json.refine||(g.json.refine=A.json.refine),g.json.geometricError||(g.json.geometricError=A.json.geometricError),g.json.transform||(g.json.transform=A.json.transform),g.json.boundingVolume||(g.json.boundingVolume=A.json.boundingVolume)):g.json=A.json,g.json.children||(g.json.getChildren?g.json.children=await g.json.getChildren():g.json.children=[]),g.rootPath=A.json.rootPath?A.json.rootPath:A.rootPath,g.json.refine?g.refine=g.json.refine:g.refine=A.parentRefine,g.json.geometricError?g.geometricError=g.json.geometricError:g.geometricError=A.parentGeometricError,g.json.transform){let Q=new V.Matrix4;Q.elements=g.json.transform,g.applyMatrix4(Q)}if(g.json.boundingVolume)if(g.json.boundingVolume.box)g.boundingVolume=new cg(g.json.boundingVolume.box);else if(g.json.boundingVolume.region){const Q=g.json.boundingVolume.region;g._transformWGS84ToCartesian(Q[0],Q[1],Q[4],Wg),g._transformWGS84ToCartesian(Q[2],Q[3],Q[5],lI),Wg.lerp(lI,.5),g.boundingVolume=new V.Sphere(new V.Vector3(Wg.x,Wg.y,Wg.z),Wg.distanceTo(lI))}else if(g.json.boundingVolume.sphere){const Q=g.json.boundingVolume.sphere;g.boundingVolume=new V.Sphere(new V.Vector3(Q[0],Q[1],Q[2]),Q[3])}else g.boundingVolume=A.parentBoundingVolume;else g.boundingVolume=A.parentBoundingVolume;function I(Q){Q.uri&&Q.uri.includes("json")||Q.url&&Q.url.includes("json")?g.hasUnloadedJSONContent++:g.hasMeshContent++}if(g.json.content?(I(g.json.content),g.hasMeshContent==0&&(g.level=Math.max(0,g.parentTile?g.parentTile.level+.01:0)),g._load()):g.json.contents&&(g.json.contents.forEach(Q=>I(Q)),g.hasMeshContent==0&&(g.level=Math.max(0,g.parentTile?g.parentTile.level+.01:0))),g.centerModel&&(lI.copy(g.boundingVolume.center),this.json.boundingVolume.region&&(this._transformWGS84ToCartesian(.5*(this.json.boundingVolume.region[0]+this.json.boundingVolume.region[2]),.5*(this.json.boundingVolume.region[1]+this.json.boundingVolume.region[3]),.5*(this.json.boundingVolume.region[4]+this.json.boundingVolume.region[5]),Wg),TC.setFromUnitVectors(Wg.normalize(),_t.normalize()),g.applyQuaternion(TC)),lI.applyMatrix4(g.matrix),g.position.sub(lI),g.updateMatrices()),g.onLoadCallback&&g.onLoadCallback(g),g.isSetup=!0,g.level>0&&g.drawBoundingVolume)if(g.bbox&&console.log("double setup"),this.boundingVolume.aabb){let Q=this.boundingVolume.aabb.clone();Q.applyMatrix4(this.matrixWorld),g.bbox=new V.Box3Helper(Q,new V.Color(Math.random(),Math.random(),Math.random())),g.add(g.bbox),g.bbox.material.visible=!1}else g.boundingVolume instanceof cg&&(g.bbox=g.boundingVolume.helper(),g.add(g.bbox),g.bbox.material.visible=!1)}_assembleURL(A,g){A.endsWith("/")||(A+="/");const I=new URL(A);let Q=I.pathname.split("/").filter(E=>E!==""),C=g.split("/").filter(E=>E!=="");for(let E=1;E<=Q.length&&!(E>=C.length);E++)if(Q.slice(Q.length-E,Q.length).join("/")===C.slice(0,E).join("/")){for(let a=0;a<E;a++)Q.pop();break}for(;C.length>0&&C[0]==="..";)Q.pop(),C.shift();return`${I.protocol}//${I.host}/${[...Q,...C].join("/")}`}_extractQueryParams(A,g){const I=new URL(A);for(let[Q,C]of I.searchParams)g[Q]=C;return I.search="",I.toString()}async _load(A=!0,g=!0){var I=this;if(!I.deleted||!g){if(I.json.content)await Q(I.json.content,null,A,g);else if(I.json.contents){let C=I.json.contents.map((E,a)=>Q(E,a,A,g));Promise.all(C)}}async function Q(C,E,a,i){let t;C.uri?t=C.uri:C.url&&(t=C.url);const e=/^(?:http|https|ftp|tcp|udp):\/\/\S+/;if(e.test(I.rootPath)?e.test(t)||(t=I._assembleURL(I.rootPath,t)):_g.isAbsolute(I.rootPath)&&(t=I.rootPath+_g.sep+t),t.startsWith("/local-tiles")||(t=I._extractQueryParams(t,I.queryParams)),I.queryParams){var o="";for(let r in I.queryParams)I.queryParams.hasOwnProperty(r)&&(o+="&"+r+"="+I.queryParams[r]);t.includes("?")?t+=o:t+="?"+o.substring(1)}if(t)if(I.contentURL.push(t),i&&(t.includes(".b3dm")||t.includes(".glb")||t.includes(".gltf")))try{I.tileLoader.get(I.abortController,I.uuid,t,r=>{if(!I.deleted)return r.asset&&r.asset.copyright&&(r.asset.copyright.split(";").forEach(n=>{Rg[n]?Rg[n]++:Rg[n]=1}),I.displayCopyright&&iQ()),r.isSplatsData&&(I.splatsMesh||(I.splatsMesh=new fa(I.tileLoader.renderer),I.splatsMesh.setQuality(I.splatsQuality),I.splatsMesh.setSplatsCPUCulling(I.splatsCPUCulling),I.splatsMesh.setSplatsCropRadius(I.splatsCropRadius),I.splatsMesh.setSplatsSizeMultiplier(I.splatsSizeMultiplier),I.static&&(I.splatsMesh.matrixAutoUpdate=!1,I.splatsMesh.matrixWorldAutoUpdate=!1),I.add(I.splatsMesh),I.updateMatrices()),r=I.splatsMesh.addSplatsTile(r.positions,r.colors,r.cov0,r.cov1)),r.isSplatsBatch||(r.traverse(n=>{if((n.isMesh||n.isPoints)&&n.layers.disable(0),n.isMesh&&I.occlusionCullingService){const s=n.geometry.attributes.position,c=[];for(let D=0;D<s.count;D++)c.push(I.color.r,I.color.g,I.color.b);n.geometry.setAttribute("color",new V.Float32BufferAttribute(c,3))}}),I.add(r),I.updateMatrices()),I.meshContent.push(r),r},I.cameraOnLoad?()=>I.loadingStrategy=="IMMEDIATE"?I._calculateDistanceToCamera(I.cameraOnLoad):I.loadingStrategy=="INCREMENTAL"?I.parentTile?I.parentTile._calculateDistanceToCamera(I.cameraOnLoad)/Math.max(1,I.parentTile.level):I._calculateDistanceToCamera(I.cameraOnLoad)/Math.max(1,I.level):I.loadingStrategy=="PERLEVEL"?I.parentTile?I.level+I.parentTile._calculateDistanceToCamera(I.cameraOnLoad):I.level+I._calculateDistanceToCamera(I.cameraOnLoad):0:()=>0,()=>I._getSiblings(),I.level,I.loadingStrategy,!I.json.boundingVolume.region,!!I.json.boundingVolume.region,I.geometricError,I.oldUltraMeshSplats)}catch(r){I.displayErrors&&OC(r)}else a&&t.includes(".json")&&(I.jsonRequested=t,I.tileLoader.get(I.abortController,I.uuid,t,async r=>{I.jsonReceived=!0,r.rootPath=_g.dirname(t),I.json.children.push(r),E==null?delete I.json.content:I.json.contents.splice(E,1),I.hasUnloadedJSONContent--}))}}dispose(){const A=this;A.meshContent.forEach(g=>{g&&g.asset&&g.asset.copyright&&(g.asset.copyright.split(";").forEach(I=>{Rg[I]&&Rg[I]--}),A.displayCopyright&&iQ())}),A.childrenTiles.forEach(g=>g.dispose()),A.deleted=!0,A.splatsMesh&&(A.meshContent.forEach(g=>g.hide()),A.parentTile||(A.splatsMesh.dispose(),A.splatsMesh=void 0)),A.contentURL&&(A.contentURL.forEach(g=>{A.tileLoader.invalidate(g,A.uuid)}),A.contentURL=[]),A.abortController&&!A.jsonRequested&&A.abortController.abort("tile not needed"),this.parent=null,A.meshContent=[],A.bbox&&A.bbox.dispose(),this.dispatchEvent({type:"removed"})}_disposeMeshContent(){const A=this;if(!A.deleted){A.deleted=!0,A.abortController&&(A.abortController.abort("tile not needed"),A.abortController=new AbortController);for(let g=A.meshContent.length-1;g>=0;g--){const I=A.meshContent[g];I&&I.asset&&I.asset.copyright&&(I.asset.copyright.split(";").forEach(Q=>{Rg[Q]&&Rg[Q]--}),A.displayCopyright&&iQ()),A.remove(I)}A.splatsMesh&&A.meshContent.forEach(g=>g.hide()),A.meshContent=[],A.contentURL.forEach(g=>{A.tileLoader.invalidate(g,A.uuid)}),A.contentURL=[]}}_disposeChildren(){var A=this;A.childrenTiles.forEach(g=>{g.dispose(),A.remove(g)}),A.childrenTiles=[]}raycast(A,g){if(this.splatsMesh){eB.copy(A.ray),iB.copy(this.matrixWorld).invert(),eB.applyMatrix4(iB);let I=!1;if(this.boundingVolume instanceof cg)I=this.boundingVolume.intersectsRay(eB);else{if(!(this.boundingVolume instanceof V.Sphere))return!1;I=ray.intersectsSphere(this.boundingVolume)}return I&&this.materialVisibility&&this.splatsReady&&(oB.length=0,this.meshContent.forEach(Q=>{Q.isSplatsBatch&&(Q.raycast(eB,oB,A.params.Points.threshold),oB.forEach(C=>{C.point.applyMatrix4(this.matrixWorld)}),g.push(...oB))})),I}return super.raycast(A,g)}update(A){this.splatsMesh&&this.splatsMesh.updateShaderParams(A,this.renderer);const g=new V.Frustum;g.setFromProjectionMatrix(new V.Matrix4().multiplyMatrices(A.projectionMatrix,A.matrixWorldInverse));let I=[0],Q=[0],C=[0],E=[0];if(this.refine=="REPLACE"?this.loadingStrategy==="IMMEDIATE"?(this._updateImmediate(A,g),this._statsImmediate(C,I,E,Q)):(this._update(A,g),this._stats(C,I,E,Q)):(this._update(A,g),this._stats(C,I,E,Q)),I>0&&(E[0]/=I[0]),this.splatsMesh)if(tB.copy(A.position),iB.copy(this.matrixWorld).invert(),tB.applyMatrix4(iB),this.splatsCPUCulling){const a=new V.Matrix4().multiplyMatrices(A.projectionMatrix,A.matrixWorldInverse).multiply(this.matrixWorld);this.splatsMesh.sort(tB,a)}else this.splatsMesh.sort(tB);return{numTilesLoaded:I[0],numTilesRendered:Q[0],maxLOD:C[0],percentageLoaded:E[0]}}_updateImmediate(A,g){this._computeMetricRecursive(A,g),this._updateNodeVisibilityImmediate(),this._expandTreeImmediate(A),this.shouldBeVisible=this.metric>0||!!this.loadOutsideView,this._shouldBeVisibleUpdateImmediate(),this._trimTreeImmediate(),this._loadMeshImmediate()}_statsImmediate(A,g,I,Q){A[0]=Math.max(A[0],this.level),(this.shouldBeVisible||this.materialVisibility)&&(g[0]++,this.materialVisibility&&I[0]++),this.materialVisibility&&Q[0]++,this.childrenTiles.forEach(C=>{C._statsImmediate(A,g,I,Q)})}_stats(A,g,I,Q){A[0]=Math.max(A[0],this.level),this.hasMeshContent&&(g[0]++,this.meshContent.length==this.hasMeshContent&&I[0]++,this.materialVisibility&&Q[0]++),this.childrenTiles.forEach(C=>{C._stats(A,g,I,Q)})}_trimTreeImmediate(){const A=this;if(A.metric!=null)if(A.hasMeshContent&&A.shouldBeVisible&&A.materialVisibility){if(A.splatsMesh&&!A.splatsReady)return;A._disposeChildren()}else A.childrenTiles.forEach(g=>{g._trimTreeImmediate()})}_updateNodeVisibilityImmediate(A=!1){const g=this;if(g.hasMeshContent)if(g.shouldBeVisible)g.meshContent.length==g.hasMeshContent?g.materialVisibility?g.childrenTiles.forEach(I=>{I._updateNodeVisibilityImmediate(!0)}):(g._changeContentVisibility(!0),g.childrenTiles.forEach(I=>{I._updateNodeVisibilityImmediate(A)})):g.childrenTiles.forEach(I=>{I._updateNodeVisibilityImmediate(A)});else{if(!g.loadOutsideView&&g.metric<0)return g._changeContentVisibility(!1),g.meshContent.length>0&&g._disposeMeshContent(),void g.childrenTiles.forEach(I=>{I._updateNodeVisibilityImmediate(!0)});if(!g.materialVisibility||g.splatsMesh&&!g.splatsReady)g.childrenTiles.forEach(I=>{I._updateNodeVisibilityImmediate(A)});else if(A)g._changeContentVisibility(!1),g.meshContent.length>0&&g._disposeMeshContent(),g.childrenTiles.forEach(I=>{I._updateNodeVisibilityImmediate(A)});else{let I=!0;g.childrenTiles.every(Q=>!!Q._isReadyImmediate()||(I=!1,!1)),I&&g.childrenTiles.length>0?(g._changeContentVisibility(!1),g.meshContent.length>0&&g._disposeMeshContent(),g.childrenTiles.forEach(Q=>{Q._updateNodeVisibilityImmediate(A)})):g.childrenTiles.forEach(Q=>{Q._updateNodeVisibilityImmediate(!g.splatsMesh||!!g.splatsReady)})}}else g.childrenTiles.forEach(I=>{I._updateNodeVisibilityImmediate(A)})}_shouldBeVisibleUpdateImmediate(){const A=this;A.hasMeshContent?A.metric==null?A.shouldBeVisible=!1:A.metric<0?(A.shouldBeVisible=!!A.loadOutsideView,A.childrenTiles.forEach(g=>{g._setShouldNotBeVisibleRecursive()})):A.metric<A.geometricErrorMultiplier*A.geometricError?A.hasUnloadedJSONContent||(A.json&&A.json.children&&A.json.children.length>0?(A.shouldBeVisible=!1,A.childrenTiles.forEach(g=>{g.shouldBeVisible=!0,g._shouldBeVisibleUpdateImmediate()})):A.shouldBeVisible=!0):A.childrenTiles.forEach(g=>{g._setShouldNotBeVisibleRecursive()}):(A.childrenTiles.forEach(g=>{g.shouldBeVisible=!0,g._shouldBeVisibleUpdateImmediate()}),A.shouldBeVisible=!1)}_setShouldNotBeVisibleRecursive(){this.shouldBeVisible=!1,this.childrenTiles.forEach(A=>{A._setShouldNotBeVisibleRecursive()})}_loadMeshImmediate(){const A=this;A.hasMeshContent&&A.shouldBeVisible?A.meshContent.length<A.hasMeshContent&&A.contentURL.length==0&&(A.deleted=!1,A._load(!1,!0)):A.childrenTiles.forEach(g=>{g._loadMeshImmediate()})}_computeMetricRecursive(A,g){const I=this;I.metric=-1,I.isSetup&&(I.boundingVolume&&I.geometricError&&(I.metric=I._calculateUpdateMetric(A,g)),I.childrenTiles.forEach(Q=>Q._computeMetricRecursive(A,g)))}_expandTreeImmediate(A){const g=this;g.hasUnloadedJSONContent||(g.hasMeshContent?g.occlusionCullingService&&g.hasMeshContent&&!g.occlusionCullingService.hasID(g.colorID)||g.metric>=0&&g.metric<g.geometricErrorMultiplier*g.geometricError&&g.json&&g.json.children&&g.childrenTiles.length<g.json.children.length&&g._loadJsonChildren(A):g.json&&g.json.children&&g.childrenTiles.length<g.json.children.length&&g._loadJsonChildren(A)),g.childrenTiles.forEach(I=>I._expandTreeImmediate(A))}_update(A,g){const I=this;if(!I.isSetup)return;const Q=I.materialVisibility;I.boundingVolume&&I.geometricError&&(I.metric=I._calculateUpdateMetric(A,g)),I.childrenTiles.forEach(C=>C._update(A,g)),function(C){if(C<0)return I.inFrustum=!1,void I._changeContentVisibility(!!I.loadOutsideView);if(I.inFrustum=!0,!!I.hasMeshContent&&!(I.meshContent.length<I.hasMeshContent)){if(I.childrenTiles.length==0)return void I._changeContentVisibility(!0);if(C>=I.geometricErrorMultiplier*I.geometricError)I._changeContentVisibility(!0);else if(C<I.geometricErrorMultiplier*I.geometricError&&I.refine=="REPLACE"){let E=!0;I.childrenTiles.every(a=>!!a._isReady()||(E=!1,!1)),E?I._changeContentVisibility(!1):I._changeContentVisibility(!0)}}}(I.metric),function(C){C<0&&I.hasMeshContent||I.occlusionCullingService&&I.hasMeshContent&&!I.occlusionCullingService.hasID(I.colorID)||(!I.hasMeshContent||C<=I.geometricErrorMultiplier*I.geometricError&&(I.meshContent.length>0||I.splatsMesh))&&I.json&&I.json.children&&I.childrenTiles.length!=I.json.children.length&&I._loadJsonChildren(A)}(I.metric),function(C,E){if(I.hasMeshContent){if(!I.inFrustum)return void I._disposeChildren();if(I.occlusionCullingService&&!E&&I.hasMeshContent&&I.meshContent.length>0&&I.materialVisibility&&I._areAllChildrenLoadedAndHidden())return I.splatsMesh&&I.materialVisibility&&!I.splatsReady?void 0:void I._disposeChildren();if(C>=I.geometricErrorMultiplier*I.geometricError){if(I.splatsMesh&&I.materialVisibility&&!I.splatsReady)return;I._disposeChildren()}}}(I.metric,Q)}_loadJsonChildren(A){const g=this;for(let I=g.json.children.length-1;I>=0;I--)g.json.children[I].root||g.json.children[I].children||g.json.children[I].getChildren||g.json.children[I].content||g.json.children[I].contents||g.json.children.splice(I,1);g.json.children.forEach(I=>{let Q=new JQ({parentTile:g,queryParams:g.queryParams,parentGeometricError:g.geometricError,parentBoundingVolume:g.boundingVolume,parentRefine:g.refine,json:I,rootPath:g.rootPath,geometricErrorMultiplier:g.geometricErrorMultiplier,loadOutsideView:g.loadOutsideView,level:Math.floor(g.level)+1,tileLoader:g.tileLoader,cameraOnLoad:A,occlusionCullingService:g.occlusionCullingService,renderer:g.renderer,static:g.static,centerModel:!1,displayErrors:g.displayErrors,displayCopyright:g.displayCopyright,distanceBias:g.distanceBias,loadingStrategy:g.loadingStrategy,drawBoundingVolume:g.drawBoundingVolume,splatsMesh:g.splatsMesh,clipShape:g.clipShape,oldUltraMeshSplats:g.oldUltraMeshSplats});g.childrenTiles.push(Q),g.add(Q)}),g.updateMatrices(!0)}_areAllChildrenLoadedAndHidden(){let A=!0;const g=this;return this.childrenTiles.every(I=>{if(I.hasMeshContent){if(I.childrenTiles.length>0)return A=!1,!1;if(I.metric<0)return!0;if(I.materialVisibility&&(!g.splatsMesh||g.splatsReady)||g.occlusionCullingService.hasID(I.colorID))return A=!1,!1}else if(!I._areAllChildrenLoadedAndHidden())return A=!1,!1;return!0}),A}_isReady(){if(this.metric==null)return!1;if(this.metric<0)return!0;if(this.hasUnloadedJSONContent)return!1;if(!this.hasMeshContent&&this.json.children.length==0&&!this.hasUnloadedJSONContent)return!0;if(!this.hasMeshContent||this.meshContent.length==0||!this.materialVisibility){if(this.children.length>0){var A=!0;return this.childrenTiles.every(g=>!!g._isReady()||(A=!1,!1)),A}return!1}return!this.hasMeshContent||!(this.meshContent.length<this.hasMeshContent)&&!!this.materialVisibility}_isReadyImmediate(){if(this.materialVisibility||!this.loadOutsideView&&this.metric<0)return!0;if(this.childrenTiles.length>0){var A=!0;return this.childrenTiles.every(g=>!!g._isReadyImmediate()||(A=!1,!1)),A}return!1}_changeContentVisibility(A){const g=this;if(g.bbox&&(g.bbox.material.visible=A),g.splatsMesh)A!=g.materialVisibility&&(g.meshContent.forEach(I=>{A&&I.isSplatsBatch?I.show(()=>{g.materialVisibility&&(g.splatsReady=!0)}):(I.hide(),g.splatsReady=!1)}),g.materialVisibility=A);else{if(g.hasMeshContent&&g.meshContent.length>0&&(A?g.meshContent.forEach(I=>{I.traverse(Q=>{(Q.isMesh||Q.isPoints)&&Q.layers.enable(0)})}):g.meshContent.forEach(I=>{I.traverse(Q=>{(Q.isMesh||Q.isPoints)&&Q.layers.disable(0)})})),g.materialVisibility==A)return;g.materialVisibility=A}}_calculateUpdateMetric(A,g){let I=0;if(this.boundingVolume instanceof cg){if(Sg.copy(this.boundingVolume),Sg.applyMatrix4(this.matrixWorld),!Sg.inFrustum(g))return-1;if(this.clipShape!=null&&(this.clipShape.isSphere&&!Sg.intersectsSphere(this.clipShape)||this.clipShape.isOBB&&!Sg.intersectsOBB(this.clipShape)))return Number.MAX_VALUE;I=Math.max(0,Sg.distanceToPoint(A.position)-A.near)}else{if(!(this.boundingVolume instanceof V.Sphere))return console.error("unsupported shape"),-1;if(fg.copy(this.boundingVolume),fg.applyMatrix4(this.matrixWorld),this.clipShape!=null&&(this.clipShape.isOBB&&!this.clipShape.intersectsSphere(fg)||this.clipShape.isSphere&&!this.clipShape.intersectsSphere(fg)))return Number.MAX_VALUE;if(!g.intersectsSphere(fg))return-1;I=Math.max(0,A.position.distanceTo(fg.center)-fg.radius-A.near)}if(I=Math.pow(I,this.distanceBias),I==0)return 0;const Q=this.matrixWorld.getMaxScaleOnAxis();this.renderer&&this.renderer.getDrawingBufferSize(this.rendererSize);let C=this.rendererSize.y,E=A.fov;return A.aspect<1&&(E*=A.aspect,C=this.rendererSize.x),16*(2*Math.tan(.5*E*.017453292519943295)*I)/(C*Q)}_getSiblings(){const A=this,g=[];if(!A.parentTile)return g;let I=A.parentTile;for(;!I.hasMeshContent&&I.parentTile;)I=I.parentTile;return I.childrenTiles.forEach(Q=>{if(Q&&Q!=A){for(;!Q.hasMeshContent&&Q.childrenTiles[0];)Q=Q.childrenTiles[0];g.push(Q)}}),g}_calculateDistanceToCamera(A){return this.boundingVolume instanceof cg?(Sg.copy(this.boundingVolume),Sg.applyMatrix4(this.matrixWorld),Math.max(0,Sg.distanceToPoint(A.position))):this.boundingVolume instanceof V.Sphere?(fg.copy(this.boundingVolume),fg.applyMatrix4(this.matrixWorld),Math.max(0,A.position.distanceTo(fg.center)-fg.radius)):(console.error("unsupported shape"),-1)}setGeometricErrorMultiplier(A){this.geometricErrorMultiplier=A,this.childrenTiles.forEach(g=>g.setGeometricErrorMultiplier(A))}setDistanceBias(A){this.distanceBias=A,this.childrenTiles.forEach(g=>g.setDistanceBias(A))}_transformWGS84ToCartesian(A,g,I,Q){const C=6378137/Math.sqrt(1-.006694384442042*Math.pow(Math.sin(g),2)),E=Math.cos(g),a=Math.cos(A),i=Math.sin(g),t=C+I,e=t*E*a,o=t*E*Math.sin(A),r=(.993305615557957*C+I)*i;Q.set(e,o,r)}hideCopyright(){(function(){yA||((yA=document.createElement("div")).style.position="fixed",yA.style.bottom="20px",yA.style.left="20px",yA.style.color="white",yA.style.textShadow="2px 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000",yA.style.padding="10px",yA.style.backgroundColor="rgba(0, 0, 0, 0.1)",document.body.appendChild(yA)),yA.style.opacity=0})()}showCopyright(){(function(){yA||((yA=document.createElement("div")).style.position="fixed",yA.style.bottom="20px",yA.style.left="20px",yA.style.color="white",yA.style.textShadow="2px 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000",yA.style.padding="10px",yA.style.backgroundColor="rgba(0, 0, 0, 0.1)",document.body.appendChild(yA)),yA.style.opacity=1})()}}function OC(B){var A=document.createElement("div");A.textContent=B,A.style.position="fixed",A.style.top="10px",A.style.left="50%",A.style.transform="translateX(-50%)",A.style.padding="10px",A.style.backgroundColor="#ff8800",A.style.color="#ffffff",A.style.zIndex="9999",document.body.appendChild(A),setTimeout(function(){A.remove()},8e3)}function iQ(){yA||((yA=document.createElement("div")).style.position="fixed",yA.style.bottom="20px",yA.style.left="20px",yA.style.color="white",yA.style.textShadow="2px 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000",yA.style.padding="10px",yA.style.backgroundColor="rgba(0, 0, 0, 0.1)",document.body.appendChild(yA));const B=Ma();let A="";B.forEach(g=>{A+=g+", "}),A=A.slice(0,-2),yA.textContent=A}const Eg=new V.Sphere(new V.Vector3(0,0,0),1),Pg=new V.Vector3(0,0,0),tQ=new V.Vector3(0,0,0),$t=new V.Vector3(0,1,0),oQ=new V.Vector2,WC=new V.Quaternion,PC=new V.Matrix4;class YQ extends V.Object3D{constructor(A){super();const g=this;if(A.queryParams&&(this.queryParams={...A.queryParams}),this.uuid=jE(),A.tileLoader?this.tileLoader=A.tileLoader:console.error("an instanced tileset must be provided an InstancedTilesetLoader"),this.master=A.master,this.loadOutsideView=A.loadOutsideView,this.cameraOnLoad=A.cameraOnLoad,this.parentTile=A.parentTile,this.distanceBias=Math.max(1e-4,A.distanceBias?A.distanceBias:1),this.childrenTiles=[],this.jsonChildren=[],this.meshContent=new Set,this.static=A.static,this.static&&(this.matrixAutoUpdate=!1,this.matrixWorldAutoUpdate=!1),this.tileContent,this.refinement,this.rootPath,this.geometricError,this.boundingVolume,this.json,this.materialVisibility=!1,this.inFrustum=!0,this.level=A.level?A.level:0,this.hasMeshContent=0,this.hasUnloadedJSONContent=0,this.centerModel=A.centerModel,this.deleted=!1,this.abortController=new AbortController,A.json)this.rootPath=A.json.rootPath?A.json.rootPath:A.rootPath,A.json.children&&(this.jsonChildren=A.json.children),g.setup(A);else if(A.url){this.loadJson=(C,E)=>{const a=_g.dirname(E);g.setup({rootPath:a,json:C,onLoadCallback:A.onLoadCallback})};var I=A.url;if(g.queryParams){var Q="";for(let C in g.queryParams)g.queryParams.hasOwnProperty(C)&&(Q+="&"+C+"="+g.queryParams[C]);I.includes("?")?I+=Q:I+="?"+Q.substring(1)}g.tileLoader.get(g.abortController,I,g.uuid,g)}}async setup(A){const g=this;A.json.root?(g.json=A.json.root,!g.json.children&&g.json.getChildren&&(g.json.children=await g.json.getChildren()),g.jsonChildren=g.json.children,g.json.refinement||(g.json.refinement=A.json.refinement),g.json.geometricError||(g.json.geometricError=A.json.geometricError),g.json.transform||(g.json.transform=A.json.transform),g.json.boundingVolume||(g.json.boundingVolume=A.json.boundingVolume)):(g.json=A.json,!g.json.children&&g.json.getChildren&&(g.json.children=await g.json.getChildren(),g.jsonChildren=g.json.children)),g.rootPath=A.json.rootPath?A.json.rootPath:A.rootPath,g.json.refinement?g.refinement=g.json.refinement:g.refinement=A.parentRefinement,g.json.geometricError?g.geometricError=g.json.geometricError:g.geometricError=A.parentGeometricError;let I=new V.Matrix4;if(g.json.transform&&!g.centerModel&&(I.elements=g.json.transform),g.applyMatrix4(I),g.parentTile&&g.parentTile.matrix&&(g.matrix.premultiply(g.parentTile.matrix),g.matrix.decompose(g.position,g.quaternion,g.scale)),g.matrixWorldNeedsUpdate=!0,g.updateWorldMatrix(!0,!0),g.json.boundingVolume)if(g.json.boundingVolume.box)g.boundingVolume=new cg(g.json.boundingVolume.box);else if(g.json.boundingVolume.region){const C=g.json.boundingVolume.region;g.transformWGS84ToCartesian(C[0],C[1],C[4],Pg),g.transformWGS84ToCartesian(C[2],C[3],C[5],tQ),Pg.lerp(tQ,.5),g.boundingVolume=new V.Sphere(new V.Vector3(Pg.x,Pg.y,Pg.z),Pg.distanceTo(tQ))}else if(g.json.boundingVolume.sphere){const C=g.json.boundingVolume.sphere;g.boundingVolume=new V.Sphere(new V.Vector3(C[0],C[1],C[2]),C[3])}else g.boundingVolume=A.parentBoundingVolume;else g.boundingVolume=A.parentBoundingVolume;function Q(C){C.uri&&C.uri.includes("json")||C.url&&C.url.includes("json")?g.hasUnloadedJSONContent++:g.hasMeshContent++}if(g.json.content?(Q(g.json.content),g.load()):g.json.contents&&(g.json.contents.forEach(C=>Q(C)),g.load()),g.centerModel){const C=new V.Sphere;g.boundingVolume instanceof cg?C.copy(g.boundingVolume.sphere):g.boundingVolume instanceof V.Sphere&&C.copy(g.boundingVolume),this.json.boundingVolume.region&&(g.transformWGS84ToCartesian(.5*(g.json.boundingVolume.region[0]+g.json.boundingVolume.region[2]),.5*(g.json.boundingVolume.region[1]+g.json.boundingVolume.region[3]),.5*(g.json.boundingVolume.region[4]+g.json.boundingVolume.region[5]),Pg),WC.setFromUnitVectors(Pg.normalize(),$t.normalize()),g.master.applyQuaternion(WC),g.master.updateWorldMatrix(!1,!1)),PC.makeTranslation(-C.center.x*g.scale.x,-C.center.y*g.scale.y,-C.center.z*g.scale.z),g.master.matrix.multiply(PC),g.master.matrix.decompose(g.master.position,g.master.quaternion,g.master.scale)}g.isSetup=!0,A.onLoadCallback&&A.onLoadCallback(g)}isAbsolutePathOrURL(A){const g=/^(?:http|https|ftp|tcp|udp):\/\/\S+/.test(A),I=A.startsWith("/")&&!A.startsWith("//");return g||I}assembleURL(A,g){A.endsWith("/")||(A+="/");const I=new URL(A);let Q=I.pathname.split("/").filter(E=>E!==""),C=g.split("/").filter(E=>E!=="");for(let E=1;E<=Q.length&&!(E>=C.length);E++)if(Q.slice(Q.length-E,Q.length).join("/")===C.slice(0,E).join("/")){for(let a=0;a<E;a++)Q.pop();break}for(;C.length>0&&C[0]==="..";)Q.pop(),C.shift();return`${I.protocol}//${I.host}/${[...Q,...C].join("/")}`}extractQueryParams(A,g){const I=new URL(A);for(let[Q,C]of I.searchParams)g[Q]=C;return I.search="",I.toString()}load(){var A=this;function g(I){let Q;I.uri?Q=I.uri:I.url&&(Q=I.url);const C=/^(?:http|https|ftp|tcp|udp):\/\/\S+/;if(C.test(A.rootPath)?C.test(Q)||(Q=A.assembleURL(A.rootPath,Q)):_g.isAbsolute(A.rootPath)&&(Q=A.rootPath+_g.sep+Q),Q=A.extractQueryParams(Q,A.queryParams),A.queryParams){var E="";for(let a in A.queryParams)A.queryParams.hasOwnProperty(a)&&(E+="&"+a+"="+A.queryParams[a]);Q.includes("?")?Q+=E:Q+="?"+E.substring(1)}Q&&(Q.includes(".b3dm")||Q.includes(".glb")||Q.includes(".gltf")?(A.contentURL=Q,A.tileLoader.get(A.abortController,Q,A.uuid,A,A.cameraOnLoad?()=>A.calculateDistanceToCamera(A.cameraOnLoad):()=>0,()=>A.getSiblings(),A.level,!A.json.boundingVolume.region,!!A.json.boundingVolume.region,A.geometricError)):Q.includes(".json")&&A.tileLoader.get(A.abortController,Q,A.uuid,A))}A.deleted||(A.json.content?g(A.json.content):A.json.contents&&A.json.contents.forEach(I=>g(I)))}loadMesh(A){this.deleted||this.meshContent.add(A)}loadJson(A,g){this.deleted||(this.json.children&&(this.jsonChildren=this.json.children),A.rootPath=_g.dirname(g),this.jsonChildren.push(A),this.hasUnloadedJSONContent--)}dispose(){const A=this;A.childrenTiles.forEach(g=>g.dispose()),A.deleted=!0,A.abortController&&A.abortController.abort(),this.parent=null,this.parentTile=null,this.dispatchEvent({type:"removed"})}disposeChildren(){this.childrenTiles.forEach(A=>A.dispose()),this.childrenTiles=[]}_update(A,g){const I=this;function Q(C){if(I.hasMeshContent&&!(I.meshContent.size<I.hasMeshContent)){if(C<0)return I.inFrustum=!1,void I.changeContentVisibility(!!I.loadOutsideView);if(I.inFrustum=!0,I.childrenTiles.length!=0){if(C>=I.master.geometricErrorMultiplier*I.geometricError)I.changeContentVisibility(!0);else if(C<I.master.geometricErrorMultiplier*I.geometricError){let E=!0;I.childrenTiles.every(a=>!!a.isReady()||(E=!1,!1)),E&&I.changeContentVisibility(!1)}}else I.changeContentVisibility(!0)}}I.isSetup&&(I.materialVisibility,I.boundingVolume&&I.geometricError&&(I.metric=I.calculateUpdateMetric(A,g)),I.childrenTiles.forEach(C=>C._update(A,g)),Q(I.metric),function(C){C<0&&I.hasMeshContent||(!I.hasMeshContent&&I.rootPath||C<I.master.geometricErrorMultiplier*I.geometricError&&I.meshContent.size>0)&&I.json&&I.jsonChildren&&I.childrenTiles.length!=I.jsonChildren.length&&I.jsonChildren.forEach(E=>{if(!(E.root||E.children||E.getChildren||E.content||E.contents))return;let a=new YQ({parentTile:I,queryParams:I.queryParams,parentGeometricError:I.geometricError,parentBoundingVolume:I.boundingVolume,parentRefinement:I.refinement,json:E,rootPath:I.rootPath,loadOutsideView:I.loadOutsideView,level:I.level+1,tileLoader:I.tileLoader,cameraOnLoad:A,master:I.master,centerModel:!1});I.childrenTiles.push(a)})}(I.metric),function(C){if(I.hasMeshContent){if(!I.inFrustum)return I.disposeChildren(),void Q(C);C>=I.master.geometricErrorMultiplier*I.geometricError&&(I.disposeChildren(),Q(C))}}(I.metric))}areAllChildrenLoadedAndHidden(){let A=!0;return this.childrenTiles.every(g=>{if(g.hasMeshContent){if(g.childrenTiles.length>0)return A=!1,!1;if(!g.inFrustum)return!0;if(!g.materialVisibility||g.meshesToDisplay!=g.meshesDisplayed)return A=!1,!1}else if(!g.areAllChildrenLoadedAndHidden())return A=!1,!1;return!0}),A}isReady(){if(!this.inFrustum)return!0;if(this.hasUnloadedJSONContent)return!1;if(!this.hasMeshContent||this.meshContent.size==0||!this.materialVisibility){if(this.childrenTiles.length>0){var A=!0;return this.childrenTiles.every(g=>!!g.isReady()||(A=!1,!1)),A}return!1}return!this.hasMeshContent||!(this.meshContent.size<this.hasMeshContent)&&!!this.materialVisibility}changeContentVisibility(A){this.materialVisibility=A}calculateUpdateMetric(A,g){if(this.boundingVolume instanceof cg){if(Eg.copy(this.boundingVolume.sphere),Eg.applyMatrix4(this.matrixWorld),!g.intersectsSphere(Eg))return-1}else{if(!(this.boundingVolume instanceof V.Sphere))return console.error("unsupported shape"),-1;if(Eg.copy(this.boundingVolume),Eg.applyMatrix4(this.matrixWorld),!g.intersectsSphere(Eg))return-1}let I=Math.max(0,A.position.distanceTo(Eg.center)-Eg.radius);if(I=Math.pow(I,this.distanceBias),I==0)return 0;const Q=this.matrixWorld.getMaxScaleOnAxis();this.master._renderSize(oQ);let C=oQ.y,E=A.fov;A.aspect<1&&(E*=A.aspect,C=oQ.x);let a=2*Math.tan(.5*E*.017453292519943295)*I;return 16*window.devicePixelRatio*a/(C*Q)}getSiblings(){const A=this,g=[];if(!A.parentTile)return g;let I=A.parentTile;for(;!I.hasMeshContent&&I.parentTile;)I=I.parentTile;return I.childrenTiles.forEach(Q=>{if(Q&&Q!=A){for(;!Q.hasMeshContent&&Q.childrenTiles[0];)Q=Q.childrenTiles[0];g.push(Q)}}),g}calculateDistanceToCamera(A){return this.boundingVolume instanceof cg?(Eg.copy(this.boundingVolume.sphere),Eg.applyMatrix4(this.matrixWorld)):this.boundingVolume instanceof V.Sphere?(Eg.copy(this.boundingVolume),Eg.applyMatrix4(this.matrixWorld)):console.error("unsupported shape"),Math.max(0,A.position.distanceTo(Eg.center)-Eg.radius)}getWorldMatrix(){return this.matrixWorld}transformWGS84ToCartesian(A,g,I,Q){const C=6378137/Math.sqrt(1-.006694384442042*Math.pow(Math.sin(g),2)),E=Math.cos(g),a=Math.cos(A),i=Math.sin(g),t=C+I,e=t*E*a,o=t*E*Math.sin(A),r=(.993305615557957*C+I)*i;Q.set(e,o,r)}}class Ao extends V.Object3D{constructor(A){super(),A.master=this,A.domWidth&&A.domHeight?this.rendererSize=new V.Vector2(A.domWidth,A.domHeight):this.rendererSize=new V.Vector2(1e3,1e3),this.renderer=A.renderer,this.distanceBias=Math.max(1e-4,A.distanceBias?A.distanceBias:1),this.geometricErrorMultiplier=A.geometricErrorMultiplier?A.geometricErrorMultiplier:1,this.tileset=new YQ(A),A.static&&(this.matrixAutoUpdate=!1),this.tileLoader=A.tileLoader}_renderSize(A){this.renderer?this.renderer.getDrawingBufferSize(A):A.copy(this.rendererSize)}setCanvasSize(A,g){this.rendererSize.set(A,g)}update(A,g){if(g)this.tileset._update(A,g);else{const I=new V.Frustum;I.setFromProjectionMatrix(new V.Matrix4().multiplyMatrices(A.projectionMatrix,A.matrixWorldInverse)),this.tileset._update(A,I)}}setGeometricErrorMultiplier(A){this.geometricErrorMultiplier=A||1}}class go{constructor(A){const g=this;g.scene=A,g.instancedTiles=[],g.instancedMesh,g.reuseableMatrix=new V.Matrix4}addInstance(A){const g=this;A.added=!0,A.listOMesh=g.instancedTiles,g.instancedTiles.push(A),g.instancedMesh&&A.loadMesh(g.instancedMesh)}addToScene(){const A=this;A.instancedMesh.setMatrixAt(0,new V.Matrix4),A.instancedMesh.instanceMatrix.needsUpdate=!0,A.instancedMesh.count=1,A.scene.add(A.instancedMesh),A.instancedMesh.onAfterRender=()=>{delete A.instancedMesh.onAfterRender,A.instancedMesh.displayedOnce=!0}}setObject(A){const g=this;g.instancedMesh=A,g.instancedMesh.matrixAutoUpdate=!1,g.instancedMesh.matrixWorldAutoUpdate=!1,g.scene.children.includes(A)||this.addToScene();for(let I=0;I<g.instancedTiles.length;I++)g.instancedTiles[I].loadMesh(g.instancedMesh)}update(){const A=this;for(let g=A.instancedTiles.length-1;g>=0;g--)A.instancedTiles[g].deleted&&A.instancedTiles.splice(g,1);if(A.instancedMesh){A.instancedMesh.count=0,A.instancedMesh.instancedTiles=[];for(let g=0;g<A.instancedTiles.length;g++)A.instancedTiles[g].meshContent.add(A.instancedMesh),A.instancedTiles[g].materialVisibility&&(A.instancedMesh.count++,A.reuseableMatrix.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),A.reuseableMatrix.multiply(A.instancedTiles[g].matrixWorld),A.reuseableMatrix.multiply(A.instancedMesh.baseMatrix),A.instancedMesh.setMatrixAt(A.instancedMesh.count-1,A.reuseableMatrix),A.instancedMesh.instancedTiles.push(A.instancedTiles[g]));A.instancedMesh.instanceMatrix.needsUpdate=!0,A.instancedMesh.needsUpdate=!0,A.instancedMesh.computeBoundingSphere()}}getCount(){return this.instancedTiles.length}dispose(){const A=this;return!(A.instancedTiles.length>0)&&!!A.instancedMesh&&(A.scene.remove(A.instancedMesh),A.instancedMesh.traverse(g=>{if(g.dispose&&g.dispose(),g.material)if(g.material.length)for(let I=0;I<g.material.length;++I)g.material[I].dispose();else g.material.dispose();g.geometry&&g.geometry.dispose()}),A.instancedMesh.dispose(),!0)}}class Io{constructor(){const A=this;A.count=0,A.json,A.instancedTiles=[]}addInstance(A){this.instancedTiles.push(A),this.json&&A.loadJson(this.json,this.url)}setObject(A,g){const I=this;I.json=A,I.url=g;for(let Q=0;Q<I.instancedTiles.length;Q++)I.instancedTiles[Q].loadJson(I.json,I.url)}getCount(){return this.instancedTiles.length}update(){const A=this;for(let g=A.instancedTiles.length-1;g>=0;g--)A.instancedTiles[g].deleted&&A.instancedTiles.splice(g,1)}dispose(){return!(!this.json||this.instancedTiles.length!=0)}}let CI=0;async function Bo(B){return new Promise(A=>{const g=setInterval(()=>{B.hasDracoLoader&&!B.dracoLoader||B.hasKTX2Loader&&!B.ktx2Loader||(clearInterval(g),A())},10)})}exports.InstancedOGC3DTile=Ao,exports.InstancedTileLoader=class{constructor(B,A){if(this.zUpToYUpMatrix=new V.Matrix4,this.zUpToYUpMatrix.set(1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1),this.maxCachedItems=100,this.maxInstances=1,this.proxy=A.proxy,A&&(this.meshCallback=A.meshCallback,this.pointsCallback=A.pointsCallback,A.maxCachedItems&&(this.maxCachedItems=A.maxCachedItems),A.maxInstances&&(this.maxInstances=A.maxInstances)),this.gltfLoader=new _C,A&&A.dracoLoader)this.gltfLoader.setDRACOLoader(A.dracoLoader),this.hasDracoLoader=!0;else{const g=new gE;g.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),this.gltfLoader.setDRACOLoader(g),this.gltfLoader.hasDracoLoader=!0}if(A&&A.ktx2Loader)this.gltfLoader.setKTX2Loader(A.ktx2Loader),this.hasKTX2Loader=!0;else if(A&&A.renderer){const g=new hg;g.setTranscoderPath("https://storage.googleapis.com/ogc-3d-tiles/basis/").detectSupport(A.renderer),this.gltfLoader.setKTX2Loader(g),this.gltfLoader.hasKTX2Loader=!0}this.gltfLoader.setMeshoptDecoder(HE),this.hasMeshOptDecoder=!0,this.b3dmDecoder=new XC(this.gltfLoader),this.cache=new VC,this.scene=B,this.ready=[],this.downloads=[],this.nextReady=[],this.nextDownloads=[]}update(){const B=this;B._checkSize(),B.cache._data.forEach(A=>{A.update()}),CI<8&&B._download(),B._loadBatch()}_download(){const B=this;if(B.nextDownloads.length!=0||(B._getNextDownloads(),B.nextDownloads.length!=0))for(;B.nextDownloads.length>0;){const g=B.nextDownloads.shift();if(g){if(g.path.includes(".b3dm")&&(A=B.proxy?()=>fetch(B.proxy,{method:"POST",body:g.path}):()=>fetch(g.path),CI++,A().then(I=>{if(!I.ok)throw console.error("could not load tile with path : "+g.path),new Error(`couldn't load "${g.path}". Request failed with status ${I.status} : ${I.statusText}`);return I.arrayBuffer()}).then(I=>this.b3dmDecoder.parseB3DMInstanced(I,Q=>{B.meshCallback(Q,g.geometricError)},B.maxInstances,g.sceneZupToYup,g.meshZupToYup)).then(I=>{I.frustumCulled=!1,g.tile.setObject(I),B.ready.unshift(g)}).catch(I=>console.error(I)).finally(()=>{CI--})),g.path.includes(".glb")||g.path.includes(".gltf"))A=B.proxy?()=>fetch(B.proxy,{method:"POST",body:g.path}):()=>fetch(g.path),CI++,A().then(I=>{if(!I.ok)throw new Error("missing content");return I.arrayBuffer()}).then(async I=>{await Bo(this.gltfLoader),this.gltfLoader.parse(I,null,Q=>{let C;Q.scene.asset=Q.asset,g.sceneZupToYup&&Q.scene.applyMatrix4(this.zUpToYUpMatrix),Q.scene.traverse(E=>{E.geometricError=g.geometricError,E.isMesh&&(g.meshZupToYup&&E.applyMatrix4(this.zUpToYUpMatrix),B.meshCallback&&B.meshCallback(E,E.geometricError)),E.isPoints&&console.error("instanced point cloud is not supported")}),Q.scene.updateWorldMatrix(!1,!0),Q.scene.traverse(E=>{E.isMesh&&(C=new V.InstancedMesh(E.geometry,E.material,B.maxInstances),C.baseMatrix=E.matrixWorld)}),B.ready.unshift(g),C?(C.frustumCulled=!1,g.tile.setObject(C)):Q.scene.traverse(E=>{E.dispose&&E.dispose(),E.material&&E.material.dispose()})})},I=>{console.error("could not load tile : "+g.path)}).finally(()=>{CI--});else if(g.path.includes(".json")){var A;A=B.proxy?()=>fetch(B.proxy,{method:"POST",body:g.path}):()=>fetch(g.path),CI++,A().then(I=>{if(!I.ok)throw console.error("could not load tile with path : "+g.path),new Error(`couldn't load "${g.path}". Request failed with status ${I.status} : ${I.statusText}`);return I.json()}).then(I=>GQ(I,g.path)).then(I=>{g.tile.setObject(I,g.path),B.ready.unshift(g)}).catch(I=>console.error(I)).finally(()=>{CI--})}}}}_loadBatch(){return this.nextReady.length==0&&(this._getNextReady(),this.nextReady.length==0)?0:this.nextReady.shift()?1:0}_getNextReady(){let B=Number.MAX_VALUE,A=-1;for(let g=this.ready.length-1;g>=0;g--)this.ready[g].distanceFunction||this.nextReady.push(this.ready.splice(g,1)[0]);if(!(this.nextReady.length>0)){for(let g=this.ready.length-1;g>=0;g--){const I=this.ready[g].distanceFunction()*this.ready[g].level;I<B&&(B=I,A=g)}if(A>=0){const g=this.ready.splice(A,1).pop();this.nextReady.push(g);const I=g.getSiblings();for(let Q=this.ready.length-1;Q>=0;Q--)I.includes(this.ready[Q].uuid)&&this.nextready.push(this.ready.splice(Q,1).pop())}}}get(B,A,g,I,Q,C,E,a,i,t){const e=this,o=function(n){for(var s=n.split("/"),c=[],D=0,b=0;b<s.length;b++){var h=s[b];h!=="."&&h!==""&&h!==".."?c[D++]=h:h===".."&&D>0&&D--}if(D===0)return"/";var w="";for(b=0;b<D;b++)w+="/"+c[b];return w}(A);if(!(A.includes(".b3dm")||A.includes(".json")||A.includes(".glb")||A.includes(".gltf")))return void console.error("the 3DTiles cache can only be used to load B3DM, gltf and json data");const r=e.cache.get(o);if(r)r.addInstance(I);else if(A.includes(".b3dm")||A.includes(".glb")||A.includes(".gltf")){const n=new go(e.scene);n.addInstance(I),e.cache.put(o,n);const s=new AbortController;B.signal.addEventListener("abort",()=>{n.getCount()==0&&s.abort()}),this.downloads.push({abortController:s,tile:n,key:o,path:A,distanceFunction:Q,getSiblings:C,level:E,uuid:g,sceneZupToYup:a,meshZupToYup:i,geometricError:t,shouldDoDownload:()=>!0})}else if(A.includes(".json")){const n=new Io;n.addInstance(I),e.cache.put(o,n);const s=new AbortController;B.signal.addEventListener("abort",()=>{n.getCount()==0&&s.abort()}),this.downloads.push({abortController:s,tile:n,key:o,path:A,distanceFunction:Q,getSiblings:C,level:E,shouldDoDownload:()=>!0})}}_getNextDownloads(){let B=Number.MAX_VALUE,A=-1;for(let g=this.downloads.length-1;g>=0;g--){const I=this.downloads[g];I.shouldDoDownload()?I.distanceFunction||this.nextDownloads.push(this.downloads.splice(g,1)[0]):this.downloads.splice(g,1)}if(!(this.nextDownloads.length>0)){for(let g=this.downloads.length-1;g>=0;g--){const I=this.downloads[g],Q=I.distanceFunction()*I.level;Q<B&&(B=Q,A=g)}if(A>=0){const g=this.downloads.splice(A,1).pop();this.nextDownloads.push(g);const I=g.getSiblings();for(let Q=this.downloads.length-1;Q>=0;Q--)I.includes(this.downloads[Q].uuid)&&this.nextDownloads.push(this.downloads.splice(Q,1).pop())}}}_checkSize(){const B=this;let A=0;for(;B.cache.size()>B.maxCachedItems&&A<B.cache.size();){A++;const g=B.cache.head();B.cache.remove(g.key),g.value.dispose()||B.cache.put(g.key,g.value)}}},exports.OBB=cg,exports.OGC3DTile=JQ,exports.OcclusionCullingService=class{constructor(){this.cullMap=[],this.cullMaterial=new V.MeshBasicMaterial({vertexColors:!0}),this.cullMaterial.side=V.FrontSide,this.cullTarget=this._createCullTarget(),this.cullPixels=new Uint8Array(4*this.cullTarget.width*this.cullTarget.height)}setSide(B){this.cullMaterial.side=B}_createCullTarget(){const B=new V.WebGLRenderTarget(Math.floor(.05*window.innerWidth),Math.floor(.05*window.innerHeight));return B.texture.format=V.RGBAFormat,B.texture.colorSpace=V.LinearSRGBColorSpace,B.texture.minFilter=V.NearestFilter,B.texture.magFilter=V.NearestFilter,B.texture.generateMipmaps=!1,B.stencilBuffer=!1,B.depthBuffer=!0,B.depthTexture=new V.DepthTexture,B.depthTexture.format=V.DepthFormat,B.depthTexture.type=V.UnsignedShortType,B}update(B,A,g){let I=A.getRenderTarget(),Q=B.overrideMaterial;B.overrideMaterial=this.cullMaterial,A.setRenderTarget(this.cullTarget),A.render(B,g),B.overrideMaterial=Q,A.setRenderTarget(I),A.readRenderTargetPixels(this.cullTarget,0,0,this.cullTarget.width,this.cullTarget.height,this.cullPixels),this.cullMap=[];for(let C=0;C<this.cullPixels.length;C+=4){const E=V.MathUtils.clamp(this.cullPixels[C],0,255)<<16^V.MathUtils.clamp(this.cullPixels[C+1],0,255)<<8^V.MathUtils.clamp(this.cullPixels[C+2],0,255);this.cullMap[E]=!0}}hasID(B){return this.cullMap[B]}},exports.SplatsMesh=fa,exports.TileLoader=KE,exports.getOGC3DTilesCopyrightInfo=Ma,exports.splatsFragmentShader=ya,exports.splatsVertexShader=Fa;
1397
+ }`}function Xt(B,A,g,I){const Q=B.getX(g),C=B.getY(g),E=B.getZ(g),a=A.getX(g),i=A.getY(g),t=A.getZ(g);I.set(Q,C,E,C,a,i,E,i,t)}function Zt(B,A,g){const I=B.determinant();if(Math.abs(I)<1e-12)return void g.set(0,0,0);const Q=1/I,C=new d.Matrix3().copy(B);C.elements[0]=A.x,C.elements[3]=A.y,C.elements[6]=A.z;const E=new d.Matrix3().copy(B);E.elements[1]=A.x,E.elements[4]=A.y,E.elements[7]=A.z;const a=new d.Matrix3().copy(B);a.elements[2]=A.x,a.elements[5]=A.y,a.elements[8]=A.z,g.set(C.determinant()*Q,E.determinant()*Q,a.determinant()*Q)}new d.Vector3,new d.Vector3;var yA;new d.Matrix3().set(1,0,0,0,0,1,0,-1,0),new d.Matrix4().set(1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1);const fg=new V.Sphere(new V.Vector3(0,0,0),1),Sg=new cg([0,0,0,1,0,0,0,1,0,0,0,1]);new V.Box3;const Wg=new V.Vector3(0,0,0),lI=new V.Vector3(0,0,0),_t=new V.Vector3(0,1,0),eB=new V.Ray,iB=new V.Matrix4;new V.Matrix4,new V.Frustum;const tB=new V.Vector3,oB=[],TC=new V.Quaternion,Rg={};function Ma(){var B=[];for(let A in Rg)Rg.hasOwnProperty(A)&&Rg[A]>0&&B.push(A);return B}class JQ extends V.Object3D{constructor(A){super();const g=this;if(g.splatsMesh=A.splatsMesh,g.oldUltraMeshSplats=A.oldUltraMeshSplats,g.iosCompatibility=A.iosCompatibility,g.splatsQuality=A.splatsQuality!=null?A.splatsQuality:.75,g.splatsCPUCulling=A.splatsCPUCulling!=null&&A.splatsCPUCulling,this.contentURL=[],A.domWidth&&A.domHeight?this.rendererSize=new V.Vector2(A.domWidth,A.domHeight):this.rendererSize=new V.Vector2(1e3,1e3),this.setClipShape(A.clipShape),this.loadingStrategy=A.loadingStrategy?A.loadingStrategy.toUpperCase():"INCREMENTAL",this.distanceBias=Math.max(1e-4,A.distanceBias?A.distanceBias:1),this.proxy=A.proxy,this.drawBoundingVolume=!!A.drawBoundingVolume&&A.drawBoundingVolume,this.displayErrors=A.displayErrors,this.displayCopyright=A.displayCopyright,A.queryParams&&(this.queryParams={...A.queryParams}),this.uuid=jE(),A.tileLoader)this.tileLoader=A.tileLoader;else{const C={};C.meshCallback=A.meshCallback?A.meshCallback:(a,i)=>{a.material.wireframe=!1,a.material.side=V.DoubleSide},C.pointsCallback=A.pointsCallback?A.pointsCallback:(a,i)=>{a.material.size=Math.pow(i,.33),a.material.sizeAttenuation=!0},C.proxy=this.proxy,C.renderer=A.renderer,C.dracoLoader=A.dracoLoader,C.ktx2Loader=A.ktx2Loader,g.tileLoader=new KE(C);const E=this.update;this.update=a=>{E.call(g,a),g.tileLoader.update()}}if(this.displayCopyright=!!A.displayCopyright,this.geometricErrorMultiplier=A.geometricErrorMultiplier?A.geometricErrorMultiplier:1,this.splatsCropRadius=Number.MAX_VALUE,this.splatsSizeMultiplier=1,this.renderer=A.renderer,this.meshCallback=A.meshCallback,this.loadOutsideView=A.loadOutsideView,this.cameraOnLoad=A.cameraOnLoad,this.parentTile=A.parentTile,this.occlusionCullingService=A.occlusionCullingService,this.static=A.static,this.occlusionCullingService&&(this.color=new V.Color,this.color.setHex(16777215*Math.random()),this.colorID=V.MathUtils.clamp(255*g.color.r,0,255)<<16^V.MathUtils.clamp(255*g.color.g,0,255)<<8^V.MathUtils.clamp(255*g.color.b,0,255)),this.static&&(this.matrixAutoUpdate=!1,this.matrixWorldAutoUpdate=!1),this.childrenTiles=[],this.meshContent=[],this.tileContent,this.refine,this.rootPath,this.geometricError,this.boundingVolume,this.json,this.materialVisibility=!1,this.level=A.level?A.level:0,this.hasMeshContent=0,this.hasUnloadedJSONContent=0,this.centerModel=A.centerModel,this.abortController=new AbortController,this.onLoadCallback=A.onLoadCallback,A.json)g._setup(A);else if(A.url){var I=A.url;if(g.queryParams){var Q="";for(let C in g.queryParams)g.queryParams.hasOwnProperty(C)&&(Q+="&"+C+"="+g.queryParams[C]);I.includes("?")?I+=Q:I+="?"+Q.substring(1)}(g.proxy?()=>fetch(g.proxy,{method:"POST",body:I,signal:g.abortController.signal}):()=>fetch(I,{signal:g.abortController.signal}))().then(C=>{if(!C.ok)throw new Error(`couldn't load "${A.url}". Request failed with status ${C.status} : ${C.statusText}`);C.json().then(E=>GQ(E,I)).then(E=>{g._setup({rootPath:_g.dirname(A.url),json:E})})}).catch(C=>{g.displayErrors&&OC(C)})}}setClipShape(A){if(A instanceof cg||A instanceof V.Sphere)this.clipShape=A;else if(A instanceof V.Box3){const g=new V.Vector3,I=new V.Vector3;A.getCenter(g),A.getSize(I).multiplyScalar(.5),this.clipShape=new cg([g.x,g.y,g.z,I.x,0,0,0,I.y,0,0,0,I.z])}else A=void 0;this.childrenTiles&&this.childrenTiles.forEach(g=>{g._setClipShape(this.clipShape)})}_setClipShape(A){this.clipShape=A,this.childrenTiles&&this.childrenTiles.forEach(g=>{g._setClipShape(this.clipShape)})}setSplatsSizeMultiplier(A){this.splatsSizeMultiplier=A,this.splatsMesh&&this.splatsMesh.setSplatsSizeMultiplier(this.splatsSizeMultiplier)}setSplatsCropRadius(A){this.splatsCropRadius=A,this.splatsMesh&&this.splatsMesh.setSplatsCropRadius(this.splatsCropRadius)}setSplatsDepthBias(A){this.splatsDepthBias=A,this.splatsMesh&&this.splatsMesh.setDepthBias(this.splatsDepthBias)}setSplatsCPUCulling(A){this.splatsCPUCulling=A,this.splatsMesh&&this.splatsMesh.setSplatsCPUCulling(A)}setSplatsQuality(A){this.splatsQuality=A,this.splatsMesh&&this.splatsMesh.setQuality(A)}updateMatrices(){this.updateMatrix(),this.splatsMesh&&this.splatsMesh.updateMatrix(),this.static&&(this.traverse(A=>{A.isObject3D&&(A.matrixWorldAutoUpdate=!0)}),this.splatsMesh&&(this.splatsMesh.matrixWorldAutoUpdate=!0)),this.updateMatrixWorld(!0),this.static&&(this.traverse(A=>{A.isObject3D&&(A.matrixWorldAutoUpdate=!1)}),this.splatsMesh&&(this.splatsMesh.matrixWorldAutoUpdate=!1))}setCanvasSize(A,g){this.rendererSize.set(A,g)}async _setup(A){const g=this;if(A.json.extensionsRequired&&(A.json.extensionsRequired.includes("JDULTRA_gaussian_splats")||A.json.extensionsRequired.includes("JDULTRA_gaussian_splats_V2"))&&(g.oldUltraMeshSplats=!0),A.json.root?(g.json=A.json.root,g.json.refine||(g.json.refine=A.json.refine),g.json.geometricError||(g.json.geometricError=A.json.geometricError),g.json.transform||(g.json.transform=A.json.transform),g.json.boundingVolume||(g.json.boundingVolume=A.json.boundingVolume)):g.json=A.json,g.json.children||(g.json.getChildren?g.json.children=await g.json.getChildren():g.json.children=[]),g.rootPath=A.json.rootPath?A.json.rootPath:A.rootPath,g.json.refine?g.refine=g.json.refine:g.refine=A.parentRefine,g.json.geometricError?g.geometricError=g.json.geometricError:g.geometricError=A.parentGeometricError,g.json.transform){let Q=new V.Matrix4;Q.elements=g.json.transform,g.applyMatrix4(Q)}if(g.json.boundingVolume)if(g.json.boundingVolume.box)g.boundingVolume=new cg(g.json.boundingVolume.box);else if(g.json.boundingVolume.region){const Q=g.json.boundingVolume.region;g._transformWGS84ToCartesian(Q[0],Q[1],Q[4],Wg),g._transformWGS84ToCartesian(Q[2],Q[3],Q[5],lI),Wg.lerp(lI,.5),g.boundingVolume=new V.Sphere(new V.Vector3(Wg.x,Wg.y,Wg.z),Wg.distanceTo(lI))}else if(g.json.boundingVolume.sphere){const Q=g.json.boundingVolume.sphere;g.boundingVolume=new V.Sphere(new V.Vector3(Q[0],Q[1],Q[2]),Q[3])}else g.boundingVolume=A.parentBoundingVolume;else g.boundingVolume=A.parentBoundingVolume;function I(Q){Q.uri&&Q.uri.includes("json")||Q.url&&Q.url.includes("json")?g.hasUnloadedJSONContent++:g.hasMeshContent++}if(g.json.content?(I(g.json.content),g.hasMeshContent==0&&(g.level=Math.max(0,g.parentTile?g.parentTile.level+.01:0)),g._load()):g.json.contents&&(g.json.contents.forEach(Q=>I(Q)),g.hasMeshContent==0&&(g.level=Math.max(0,g.parentTile?g.parentTile.level+.01:0))),g.centerModel&&(lI.copy(g.boundingVolume.center),this.json.boundingVolume.region&&(this._transformWGS84ToCartesian(.5*(this.json.boundingVolume.region[0]+this.json.boundingVolume.region[2]),.5*(this.json.boundingVolume.region[1]+this.json.boundingVolume.region[3]),.5*(this.json.boundingVolume.region[4]+this.json.boundingVolume.region[5]),Wg),TC.setFromUnitVectors(Wg.normalize(),_t.normalize()),g.applyQuaternion(TC)),lI.applyMatrix4(g.matrix),g.position.sub(lI),g.updateMatrices()),g.onLoadCallback&&g.onLoadCallback(g),g.isSetup=!0,g.level>0&&g.drawBoundingVolume)if(g.bbox&&console.log("double setup"),this.boundingVolume.aabb){let Q=this.boundingVolume.aabb.clone();Q.applyMatrix4(this.matrixWorld),g.bbox=new V.Box3Helper(Q,new V.Color(Math.random(),Math.random(),Math.random())),g.add(g.bbox),g.bbox.material.visible=!1}else g.boundingVolume instanceof cg&&(g.bbox=g.boundingVolume.helper(),g.add(g.bbox),g.bbox.material.visible=!1)}_assembleURL(A,g){A.endsWith("/")||(A+="/");try{const I=new URL(A);let Q=I.pathname.split("/").filter(E=>E!==""),C=g.split("/").filter(E=>E!=="");for(let E=1;E<=Q.length&&!(E>=C.length);E++)if(Q.slice(Q.length-E,Q.length).join("/")===C.slice(0,E).join("/")){for(let i=0;i<E;i++)Q.pop();break}for(;C.length>0&&C[0]==="..";)Q.pop(),C.shift();return`${I.protocol}//${I.host}/${[...Q,...C].join("/")}`}catch{return A.endsWith("/")||g.startsWith("/")?A+g:A+"/"+g}}_extractQueryParams(A,g){try{const I=new URL(A);for(let[Q,C]of I.searchParams)g[Q]=C;return I.search="",I.toString()}catch{return A}}async _load(A=!0,g=!0){var I=this;if(!I.deleted||!g){if(I.json.content)await Q(I.json.content,null,A,g);else if(I.json.contents){let C=I.json.contents.map((E,a)=>Q(E,a,A,g));Promise.all(C)}}async function Q(C,E,a,i){let t;C.uri?t=C.uri:C.url&&(t=C.url);const e=/^(?:http|https|ftp|tcp|udp):\/\/\S+/;if(e.test(I.rootPath)?e.test(t)||(t=I._assembleURL(I.rootPath,t)):_g.isAbsolute(I.rootPath)&&(t=I.rootPath+_g.sep+t),t.startsWith("/local-tiles")||(t=I._extractQueryParams(t,I.queryParams)),I.queryParams){var o="";for(let r in I.queryParams)I.queryParams.hasOwnProperty(r)&&(o+="&"+r+"="+I.queryParams[r]);t.includes("?")?t+=o:t+="?"+o.substring(1)}if(t)if(I.contentURL.push(t),i&&(t.includes(".b3dm")||t.includes(".glb")||t.includes(".gltf")))try{I.tileLoader.get(I.abortController,I.uuid,t,r=>{if(!I.deleted)return r.asset&&r.asset.copyright&&(r.asset.copyright.split(";").forEach(n=>{Rg[n]?Rg[n]++:Rg[n]=1}),I.displayCopyright&&iQ()),r.isSplatsData&&(I.splatsMesh||(I.splatsMesh=new fa(I.tileLoader.renderer),I.splatsMesh.setQuality(I.splatsQuality),I.splatsMesh.setSplatsCPUCulling(I.splatsCPUCulling),I.splatsMesh.setSplatsCropRadius(I.splatsCropRadius),I.splatsMesh.setSplatsSizeMultiplier(I.splatsSizeMultiplier),I.static&&(I.splatsMesh.matrixAutoUpdate=!1,I.splatsMesh.matrixWorldAutoUpdate=!1),I.add(I.splatsMesh),I.updateMatrices()),r=I.splatsMesh.addSplatsTile(r.positions,r.colors,r.cov0,r.cov1)),r.isSplatsBatch||(r.traverse(n=>{if((n.isMesh||n.isPoints)&&n.layers.disable(0),n.isMesh&&I.occlusionCullingService){const s=n.geometry.attributes.position,c=[];for(let D=0;D<s.count;D++)c.push(I.color.r,I.color.g,I.color.b);n.geometry.setAttribute("color",new V.Float32BufferAttribute(c,3))}}),I.add(r),I.updateMatrices()),I.meshContent.push(r),r},I.cameraOnLoad?()=>I.loadingStrategy=="IMMEDIATE"?I._calculateDistanceToCamera(I.cameraOnLoad):I.loadingStrategy=="INCREMENTAL"?I.parentTile?I.parentTile._calculateDistanceToCamera(I.cameraOnLoad)/Math.max(1,I.parentTile.level):I._calculateDistanceToCamera(I.cameraOnLoad)/Math.max(1,I.level):I.loadingStrategy=="PERLEVEL"?I.parentTile?I.level+I.parentTile._calculateDistanceToCamera(I.cameraOnLoad):I.level+I._calculateDistanceToCamera(I.cameraOnLoad):0:()=>0,()=>I._getSiblings(),I.level,I.loadingStrategy,!I.json.boundingVolume.region,!!I.json.boundingVolume.region,I.geometricError,I.oldUltraMeshSplats)}catch(r){I.displayErrors&&OC(r)}else a&&t.includes(".json")&&(I.jsonRequested=t,I.tileLoader.get(I.abortController,I.uuid,t,async r=>{I.jsonReceived=!0,r.rootPath=_g.dirname(t),I.json.children.push(r),E==null?delete I.json.content:I.json.contents.splice(E,1),I.hasUnloadedJSONContent--}))}}dispose(){const A=this;A.meshContent.forEach(g=>{g&&g.asset&&g.asset.copyright&&(g.asset.copyright.split(";").forEach(I=>{Rg[I]&&Rg[I]--}),A.displayCopyright&&iQ())}),A.childrenTiles.forEach(g=>g.dispose()),A.deleted=!0,A.splatsMesh&&(A.meshContent.forEach(g=>g.hide()),A.parentTile||(A.splatsMesh.dispose(),A.splatsMesh=void 0)),A.contentURL&&(A.contentURL.forEach(g=>{A.tileLoader.invalidate(g,A.uuid)}),A.contentURL=[]),A.abortController&&!A.jsonRequested&&A.abortController.abort("tile not needed"),this.parent=null,A.meshContent=[],A.bbox&&A.bbox.dispose(),this.dispatchEvent({type:"removed"})}_disposeMeshContent(){const A=this;if(!A.deleted){A.deleted=!0,A.abortController&&(A.abortController.abort("tile not needed"),A.abortController=new AbortController);for(let g=A.meshContent.length-1;g>=0;g--){const I=A.meshContent[g];I&&I.asset&&I.asset.copyright&&(I.asset.copyright.split(";").forEach(Q=>{Rg[Q]&&Rg[Q]--}),A.displayCopyright&&iQ()),A.remove(I)}A.splatsMesh&&A.meshContent.forEach(g=>g.hide()),A.meshContent=[],A.contentURL.forEach(g=>{A.tileLoader.invalidate(g,A.uuid)}),A.contentURL=[]}}_disposeChildren(){var A=this;A.childrenTiles.forEach(g=>{g.dispose(),A.remove(g)}),A.childrenTiles=[]}raycast(A,g){if(this.splatsMesh){eB.copy(A.ray),iB.copy(this.matrixWorld).invert(),eB.applyMatrix4(iB);let I=!1;if(this.boundingVolume instanceof cg)I=this.boundingVolume.intersectsRay(eB);else{if(!(this.boundingVolume instanceof V.Sphere))return!1;I=ray.intersectsSphere(this.boundingVolume)}return I&&this.materialVisibility&&this.splatsReady&&(oB.length=0,this.meshContent.forEach(Q=>{Q.isSplatsBatch&&(Q.raycast(eB,oB,A.params.Points.threshold),oB.forEach(C=>{C.point.applyMatrix4(this.matrixWorld)}),g.push(...oB))})),I}return super.raycast(A,g)}update(A){this.splatsMesh&&this.splatsMesh.updateShaderParams(A,this.renderer);const g=new V.Frustum;g.setFromProjectionMatrix(new V.Matrix4().multiplyMatrices(A.projectionMatrix,A.matrixWorldInverse));let I=[0],Q=[0],C=[0],E=[0];if(this.refine=="REPLACE"?this.loadingStrategy==="IMMEDIATE"?(this._updateImmediate(A,g),this._statsImmediate(C,I,E,Q)):(this._update(A,g),this._stats(C,I,E,Q)):(this._update(A,g),this._stats(C,I,E,Q)),I>0&&(E[0]/=I[0]),this.splatsMesh)if(tB.copy(A.position),iB.copy(this.matrixWorld).invert(),tB.applyMatrix4(iB),this.splatsCPUCulling){const a=new V.Matrix4().multiplyMatrices(A.projectionMatrix,A.matrixWorldInverse).multiply(this.matrixWorld);this.splatsMesh.sort(tB,a)}else this.splatsMesh.sort(tB);return{numTilesLoaded:I[0],numTilesRendered:Q[0],maxLOD:C[0],percentageLoaded:E[0]}}_updateImmediate(A,g){this._computeMetricRecursive(A,g),this._updateNodeVisibilityImmediate(),this._expandTreeImmediate(A),this.shouldBeVisible=this.metric>0||!!this.loadOutsideView,this._shouldBeVisibleUpdateImmediate(),this._trimTreeImmediate(),this._loadMeshImmediate()}_statsImmediate(A,g,I,Q){A[0]=Math.max(A[0],this.level),(this.shouldBeVisible||this.materialVisibility)&&(g[0]++,this.materialVisibility&&I[0]++),this.materialVisibility&&Q[0]++,this.childrenTiles.forEach(C=>{C._statsImmediate(A,g,I,Q)})}_stats(A,g,I,Q){A[0]=Math.max(A[0],this.level),this.hasMeshContent&&(g[0]++,this.meshContent.length==this.hasMeshContent&&I[0]++,this.materialVisibility&&Q[0]++),this.childrenTiles.forEach(C=>{C._stats(A,g,I,Q)})}_trimTreeImmediate(){const A=this;if(A.metric!=null)if(A.hasMeshContent&&A.shouldBeVisible&&A.materialVisibility){if(A.splatsMesh&&!A.splatsReady)return;A._disposeChildren()}else A.childrenTiles.forEach(g=>{g._trimTreeImmediate()})}_updateNodeVisibilityImmediate(A=!1){const g=this;if(g.hasMeshContent)if(g.shouldBeVisible)g.meshContent.length==g.hasMeshContent?g.materialVisibility?g.childrenTiles.forEach(I=>{I._updateNodeVisibilityImmediate(!0)}):(g._changeContentVisibility(!0),g.childrenTiles.forEach(I=>{I._updateNodeVisibilityImmediate(A)})):g.childrenTiles.forEach(I=>{I._updateNodeVisibilityImmediate(A)});else{if(!g.loadOutsideView&&g.metric<0)return g._changeContentVisibility(!1),g.meshContent.length>0&&g._disposeMeshContent(),void g.childrenTiles.forEach(I=>{I._updateNodeVisibilityImmediate(!0)});if(!g.materialVisibility||g.splatsMesh&&!g.splatsReady)g.childrenTiles.forEach(I=>{I._updateNodeVisibilityImmediate(A)});else if(A)g._changeContentVisibility(!1),g.meshContent.length>0&&g._disposeMeshContent(),g.childrenTiles.forEach(I=>{I._updateNodeVisibilityImmediate(A)});else{let I=!0;g.childrenTiles.every(Q=>!!Q._isReadyImmediate()||(I=!1,!1)),I&&g.childrenTiles.length>0?(g._changeContentVisibility(!1),g.meshContent.length>0&&g._disposeMeshContent(),g.childrenTiles.forEach(Q=>{Q._updateNodeVisibilityImmediate(A)})):g.childrenTiles.forEach(Q=>{Q._updateNodeVisibilityImmediate(!g.splatsMesh||!!g.splatsReady)})}}else g.childrenTiles.forEach(I=>{I._updateNodeVisibilityImmediate(A)})}_shouldBeVisibleUpdateImmediate(){const A=this;A.hasMeshContent?A.metric==null?A.shouldBeVisible=!1:A.metric<0?(A.shouldBeVisible=!!A.loadOutsideView,A.childrenTiles.forEach(g=>{g._setShouldNotBeVisibleRecursive()})):A.metric<A.geometricErrorMultiplier*A.geometricError?A.hasUnloadedJSONContent||(A.json&&A.json.children&&A.json.children.length>0?(A.shouldBeVisible=!1,A.childrenTiles.forEach(g=>{g.shouldBeVisible=!0,g._shouldBeVisibleUpdateImmediate()})):A.shouldBeVisible=!0):A.childrenTiles.forEach(g=>{g._setShouldNotBeVisibleRecursive()}):(A.childrenTiles.forEach(g=>{g.shouldBeVisible=!0,g._shouldBeVisibleUpdateImmediate()}),A.shouldBeVisible=!1)}_setShouldNotBeVisibleRecursive(){this.shouldBeVisible=!1,this.childrenTiles.forEach(A=>{A._setShouldNotBeVisibleRecursive()})}_loadMeshImmediate(){const A=this;A.hasMeshContent&&A.shouldBeVisible?A.meshContent.length<A.hasMeshContent&&A.contentURL.length==0&&(A.deleted=!1,A._load(!1,!0)):A.childrenTiles.forEach(g=>{g._loadMeshImmediate()})}_computeMetricRecursive(A,g){const I=this;I.metric=-1,I.isSetup&&(I.boundingVolume&&I.geometricError&&(I.metric=I._calculateUpdateMetric(A,g)),I.childrenTiles.forEach(Q=>Q._computeMetricRecursive(A,g)))}_expandTreeImmediate(A){const g=this;g.hasUnloadedJSONContent||(g.hasMeshContent?g.occlusionCullingService&&g.hasMeshContent&&!g.occlusionCullingService.hasID(g.colorID)||g.metric>=0&&g.metric<g.geometricErrorMultiplier*g.geometricError&&g.json&&g.json.children&&g.childrenTiles.length<g.json.children.length&&g._loadJsonChildren(A):g.json&&g.json.children&&g.childrenTiles.length<g.json.children.length&&g._loadJsonChildren(A)),g.childrenTiles.forEach(I=>I._expandTreeImmediate(A))}_update(A,g){const I=this;if(!I.isSetup)return;const Q=I.materialVisibility;I.boundingVolume&&I.geometricError&&(I.metric=I._calculateUpdateMetric(A,g)),I.childrenTiles.forEach(C=>C._update(A,g)),function(C){if(C<0)return I.inFrustum=!1,void I._changeContentVisibility(!!I.loadOutsideView);if(I.inFrustum=!0,!!I.hasMeshContent&&!(I.meshContent.length<I.hasMeshContent)){if(I.childrenTiles.length==0)return void I._changeContentVisibility(!0);if(C>=I.geometricErrorMultiplier*I.geometricError)I._changeContentVisibility(!0);else if(C<I.geometricErrorMultiplier*I.geometricError&&I.refine=="REPLACE"){let E=!0;I.childrenTiles.every(a=>!!a._isReady()||(E=!1,!1)),E?I._changeContentVisibility(!1):I._changeContentVisibility(!0)}}}(I.metric),function(C){C<0&&I.hasMeshContent||I.occlusionCullingService&&I.hasMeshContent&&!I.occlusionCullingService.hasID(I.colorID)||(!I.hasMeshContent||C<=I.geometricErrorMultiplier*I.geometricError&&(I.meshContent.length>0||I.splatsMesh))&&I.json&&I.json.children&&I.childrenTiles.length!=I.json.children.length&&I._loadJsonChildren(A)}(I.metric),function(C,E){if(I.hasMeshContent){if(!I.inFrustum)return void I._disposeChildren();if(I.occlusionCullingService&&!E&&I.hasMeshContent&&I.meshContent.length>0&&I.materialVisibility&&I._areAllChildrenLoadedAndHidden())return I.splatsMesh&&I.materialVisibility&&!I.splatsReady?void 0:void I._disposeChildren();if(C>=I.geometricErrorMultiplier*I.geometricError){if(I.splatsMesh&&I.materialVisibility&&!I.splatsReady)return;I._disposeChildren()}}}(I.metric,Q)}_loadJsonChildren(A){const g=this;for(let I=g.json.children.length-1;I>=0;I--)g.json.children[I].root||g.json.children[I].children||g.json.children[I].getChildren||g.json.children[I].content||g.json.children[I].contents||g.json.children.splice(I,1);g.json.children.forEach(I=>{let Q=new JQ({parentTile:g,queryParams:g.queryParams,parentGeometricError:g.geometricError,parentBoundingVolume:g.boundingVolume,parentRefine:g.refine,json:I,rootPath:g.rootPath,geometricErrorMultiplier:g.geometricErrorMultiplier,loadOutsideView:g.loadOutsideView,level:Math.floor(g.level)+1,tileLoader:g.tileLoader,cameraOnLoad:A,occlusionCullingService:g.occlusionCullingService,renderer:g.renderer,static:g.static,centerModel:!1,displayErrors:g.displayErrors,displayCopyright:g.displayCopyright,distanceBias:g.distanceBias,loadingStrategy:g.loadingStrategy,drawBoundingVolume:g.drawBoundingVolume,splatsMesh:g.splatsMesh,clipShape:g.clipShape,oldUltraMeshSplats:g.oldUltraMeshSplats});g.childrenTiles.push(Q),g.add(Q)}),g.updateMatrices(!0)}_areAllChildrenLoadedAndHidden(){let A=!0;const g=this;return this.childrenTiles.every(I=>{if(I.hasMeshContent){if(I.childrenTiles.length>0)return A=!1,!1;if(I.metric<0)return!0;if(I.materialVisibility&&(!g.splatsMesh||g.splatsReady)||g.occlusionCullingService.hasID(I.colorID))return A=!1,!1}else if(!I._areAllChildrenLoadedAndHidden())return A=!1,!1;return!0}),A}_isReady(){if(this.metric==null)return!1;if(this.metric<0)return!0;if(this.hasUnloadedJSONContent)return!1;if(!this.hasMeshContent&&this.json.children.length==0&&!this.hasUnloadedJSONContent)return!0;if(!this.hasMeshContent||this.meshContent.length==0||!this.materialVisibility){if(this.children.length>0){var A=!0;return this.childrenTiles.every(g=>!!g._isReady()||(A=!1,!1)),A}return!1}return!this.hasMeshContent||!(this.meshContent.length<this.hasMeshContent)&&!!this.materialVisibility}_isReadyImmediate(){if(this.materialVisibility||!this.loadOutsideView&&this.metric<0)return!0;if(this.childrenTiles.length>0){var A=!0;return this.childrenTiles.every(g=>!!g._isReadyImmediate()||(A=!1,!1)),A}return!1}_changeContentVisibility(A){const g=this;if(g.bbox&&(g.bbox.material.visible=A),g.splatsMesh)A!=g.materialVisibility&&(g.meshContent.forEach(I=>{A&&I.isSplatsBatch?I.show(()=>{g.materialVisibility&&(g.splatsReady=!0)}):(I.hide(),g.splatsReady=!1)}),g.materialVisibility=A);else{if(g.hasMeshContent&&g.meshContent.length>0&&(A?g.meshContent.forEach(I=>{I.traverse(Q=>{(Q.isMesh||Q.isPoints)&&Q.layers.enable(0)})}):g.meshContent.forEach(I=>{I.traverse(Q=>{(Q.isMesh||Q.isPoints)&&Q.layers.disable(0)})})),g.materialVisibility==A)return;g.materialVisibility=A}}_calculateUpdateMetric(A,g){let I=0;if(this.boundingVolume instanceof cg){if(Sg.copy(this.boundingVolume),Sg.applyMatrix4(this.matrixWorld),!Sg.inFrustum(g))return-1;if(this.clipShape!=null&&(this.clipShape.isSphere&&!Sg.intersectsSphere(this.clipShape)||this.clipShape.isOBB&&!Sg.intersectsOBB(this.clipShape)))return Number.MAX_VALUE;I=Math.max(0,Sg.distanceToPoint(A.position)-A.near)}else{if(!(this.boundingVolume instanceof V.Sphere))return console.error("unsupported shape"),-1;if(fg.copy(this.boundingVolume),fg.applyMatrix4(this.matrixWorld),this.clipShape!=null&&(this.clipShape.isOBB&&!this.clipShape.intersectsSphere(fg)||this.clipShape.isSphere&&!this.clipShape.intersectsSphere(fg)))return Number.MAX_VALUE;if(!g.intersectsSphere(fg))return-1;I=Math.max(0,A.position.distanceTo(fg.center)-fg.radius-A.near)}if(I=Math.pow(I,this.distanceBias),I==0)return 0;const Q=this.matrixWorld.getMaxScaleOnAxis();this.renderer&&this.renderer.getDrawingBufferSize(this.rendererSize);let C=this.rendererSize.y,E=A.fov;return A.aspect<1&&(E*=A.aspect,C=this.rendererSize.x),16*(2*Math.tan(.5*E*.017453292519943295)*I)/(C*Q)}_getSiblings(){const A=this,g=[];if(!A.parentTile)return g;let I=A.parentTile;for(;!I.hasMeshContent&&I.parentTile;)I=I.parentTile;return I.childrenTiles.forEach(Q=>{if(Q&&Q!=A){for(;!Q.hasMeshContent&&Q.childrenTiles[0];)Q=Q.childrenTiles[0];g.push(Q)}}),g}_calculateDistanceToCamera(A){return this.boundingVolume instanceof cg?(Sg.copy(this.boundingVolume),Sg.applyMatrix4(this.matrixWorld),Math.max(0,Sg.distanceToPoint(A.position))):this.boundingVolume instanceof V.Sphere?(fg.copy(this.boundingVolume),fg.applyMatrix4(this.matrixWorld),Math.max(0,A.position.distanceTo(fg.center)-fg.radius)):(console.error("unsupported shape"),-1)}setGeometricErrorMultiplier(A){this.geometricErrorMultiplier=A,this.childrenTiles.forEach(g=>g.setGeometricErrorMultiplier(A))}setDistanceBias(A){this.distanceBias=A,this.childrenTiles.forEach(g=>g.setDistanceBias(A))}_transformWGS84ToCartesian(A,g,I,Q){const C=6378137/Math.sqrt(1-.006694384442042*Math.pow(Math.sin(g),2)),E=Math.cos(g),a=Math.cos(A),i=Math.sin(g),t=C+I,e=t*E*a,o=t*E*Math.sin(A),r=(.993305615557957*C+I)*i;Q.set(e,o,r)}hideCopyright(){(function(){yA||((yA=document.createElement("div")).style.position="fixed",yA.style.bottom="20px",yA.style.left="20px",yA.style.color="white",yA.style.textShadow="2px 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000",yA.style.padding="10px",yA.style.backgroundColor="rgba(0, 0, 0, 0.1)",document.body.appendChild(yA)),yA.style.opacity=0})()}showCopyright(){(function(){yA||((yA=document.createElement("div")).style.position="fixed",yA.style.bottom="20px",yA.style.left="20px",yA.style.color="white",yA.style.textShadow="2px 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000",yA.style.padding="10px",yA.style.backgroundColor="rgba(0, 0, 0, 0.1)",document.body.appendChild(yA)),yA.style.opacity=1})()}}function OC(B){var A=document.createElement("div");A.textContent=B,A.style.position="fixed",A.style.top="10px",A.style.left="50%",A.style.transform="translateX(-50%)",A.style.padding="10px",A.style.backgroundColor="#ff8800",A.style.color="#ffffff",A.style.zIndex="9999",document.body.appendChild(A),setTimeout(function(){A.remove()},8e3)}function iQ(){yA||((yA=document.createElement("div")).style.position="fixed",yA.style.bottom="20px",yA.style.left="20px",yA.style.color="white",yA.style.textShadow="2px 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000",yA.style.padding="10px",yA.style.backgroundColor="rgba(0, 0, 0, 0.1)",document.body.appendChild(yA));const B=Ma();let A="";B.forEach(g=>{A+=g+", "}),A=A.slice(0,-2),yA.textContent=A}const Eg=new V.Sphere(new V.Vector3(0,0,0),1),Pg=new V.Vector3(0,0,0),tQ=new V.Vector3(0,0,0),$t=new V.Vector3(0,1,0),oQ=new V.Vector2,WC=new V.Quaternion,PC=new V.Matrix4;class YQ extends V.Object3D{constructor(A){super();const g=this;if(A.queryParams&&(this.queryParams={...A.queryParams}),this.uuid=jE(),A.tileLoader?this.tileLoader=A.tileLoader:console.error("an instanced tileset must be provided an InstancedTilesetLoader"),this.master=A.master,this.loadOutsideView=A.loadOutsideView,this.cameraOnLoad=A.cameraOnLoad,this.parentTile=A.parentTile,this.distanceBias=Math.max(1e-4,A.distanceBias?A.distanceBias:1),this.childrenTiles=[],this.jsonChildren=[],this.meshContent=new Set,this.static=A.static,this.static&&(this.matrixAutoUpdate=!1,this.matrixWorldAutoUpdate=!1),this.tileContent,this.refinement,this.rootPath,this.geometricError,this.boundingVolume,this.json,this.materialVisibility=!1,this.inFrustum=!0,this.level=A.level?A.level:0,this.hasMeshContent=0,this.hasUnloadedJSONContent=0,this.centerModel=A.centerModel,this.deleted=!1,this.abortController=new AbortController,A.json)this.rootPath=A.json.rootPath?A.json.rootPath:A.rootPath,A.json.children&&(this.jsonChildren=A.json.children),g.setup(A);else if(A.url){this.loadJson=(C,E)=>{const a=_g.dirname(E);g.setup({rootPath:a,json:C,onLoadCallback:A.onLoadCallback})};var I=A.url;if(g.queryParams){var Q="";for(let C in g.queryParams)g.queryParams.hasOwnProperty(C)&&(Q+="&"+C+"="+g.queryParams[C]);I.includes("?")?I+=Q:I+="?"+Q.substring(1)}g.tileLoader.get(g.abortController,I,g.uuid,g)}}async setup(A){const g=this;A.json.root?(g.json=A.json.root,!g.json.children&&g.json.getChildren&&(g.json.children=await g.json.getChildren()),g.jsonChildren=g.json.children,g.json.refinement||(g.json.refinement=A.json.refinement),g.json.geometricError||(g.json.geometricError=A.json.geometricError),g.json.transform||(g.json.transform=A.json.transform),g.json.boundingVolume||(g.json.boundingVolume=A.json.boundingVolume)):(g.json=A.json,!g.json.children&&g.json.getChildren&&(g.json.children=await g.json.getChildren(),g.jsonChildren=g.json.children)),g.rootPath=A.json.rootPath?A.json.rootPath:A.rootPath,g.json.refinement?g.refinement=g.json.refinement:g.refinement=A.parentRefinement,g.json.geometricError?g.geometricError=g.json.geometricError:g.geometricError=A.parentGeometricError;let I=new V.Matrix4;if(g.json.transform&&!g.centerModel&&(I.elements=g.json.transform),g.applyMatrix4(I),g.parentTile&&g.parentTile.matrix&&(g.matrix.premultiply(g.parentTile.matrix),g.matrix.decompose(g.position,g.quaternion,g.scale)),g.matrixWorldNeedsUpdate=!0,g.updateWorldMatrix(!0,!0),g.json.boundingVolume)if(g.json.boundingVolume.box)g.boundingVolume=new cg(g.json.boundingVolume.box);else if(g.json.boundingVolume.region){const C=g.json.boundingVolume.region;g.transformWGS84ToCartesian(C[0],C[1],C[4],Pg),g.transformWGS84ToCartesian(C[2],C[3],C[5],tQ),Pg.lerp(tQ,.5),g.boundingVolume=new V.Sphere(new V.Vector3(Pg.x,Pg.y,Pg.z),Pg.distanceTo(tQ))}else if(g.json.boundingVolume.sphere){const C=g.json.boundingVolume.sphere;g.boundingVolume=new V.Sphere(new V.Vector3(C[0],C[1],C[2]),C[3])}else g.boundingVolume=A.parentBoundingVolume;else g.boundingVolume=A.parentBoundingVolume;function Q(C){C.uri&&C.uri.includes("json")||C.url&&C.url.includes("json")?g.hasUnloadedJSONContent++:g.hasMeshContent++}if(g.json.content?(Q(g.json.content),g.load()):g.json.contents&&(g.json.contents.forEach(C=>Q(C)),g.load()),g.centerModel){const C=new V.Sphere;g.boundingVolume instanceof cg?C.copy(g.boundingVolume.sphere):g.boundingVolume instanceof V.Sphere&&C.copy(g.boundingVolume),this.json.boundingVolume.region&&(g.transformWGS84ToCartesian(.5*(g.json.boundingVolume.region[0]+g.json.boundingVolume.region[2]),.5*(g.json.boundingVolume.region[1]+g.json.boundingVolume.region[3]),.5*(g.json.boundingVolume.region[4]+g.json.boundingVolume.region[5]),Pg),WC.setFromUnitVectors(Pg.normalize(),$t.normalize()),g.master.applyQuaternion(WC),g.master.updateWorldMatrix(!1,!1)),PC.makeTranslation(-C.center.x*g.scale.x,-C.center.y*g.scale.y,-C.center.z*g.scale.z),g.master.matrix.multiply(PC),g.master.matrix.decompose(g.master.position,g.master.quaternion,g.master.scale)}g.isSetup=!0,A.onLoadCallback&&A.onLoadCallback(g)}isAbsolutePathOrURL(A){const g=/^(?:http|https|ftp|tcp|udp):\/\/\S+/.test(A),I=A.startsWith("/")&&!A.startsWith("//");return g||I}assembleURL(A,g){A.endsWith("/")||(A+="/");const I=new URL(A);let Q=I.pathname.split("/").filter(E=>E!==""),C=g.split("/").filter(E=>E!=="");for(let E=1;E<=Q.length&&!(E>=C.length);E++)if(Q.slice(Q.length-E,Q.length).join("/")===C.slice(0,E).join("/")){for(let a=0;a<E;a++)Q.pop();break}for(;C.length>0&&C[0]==="..";)Q.pop(),C.shift();return`${I.protocol}//${I.host}/${[...Q,...C].join("/")}`}extractQueryParams(A,g){const I=new URL(A);for(let[Q,C]of I.searchParams)g[Q]=C;return I.search="",I.toString()}load(){var A=this;function g(I){let Q;I.uri?Q=I.uri:I.url&&(Q=I.url);const C=/^(?:http|https|ftp|tcp|udp):\/\/\S+/;if(C.test(A.rootPath)?C.test(Q)||(Q=A.assembleURL(A.rootPath,Q)):_g.isAbsolute(A.rootPath)&&(Q=A.rootPath+_g.sep+Q),Q=A.extractQueryParams(Q,A.queryParams),A.queryParams){var E="";for(let a in A.queryParams)A.queryParams.hasOwnProperty(a)&&(E+="&"+a+"="+A.queryParams[a]);Q.includes("?")?Q+=E:Q+="?"+E.substring(1)}Q&&(Q.includes(".b3dm")||Q.includes(".glb")||Q.includes(".gltf")?(A.contentURL=Q,A.tileLoader.get(A.abortController,Q,A.uuid,A,A.cameraOnLoad?()=>A.calculateDistanceToCamera(A.cameraOnLoad):()=>0,()=>A.getSiblings(),A.level,!A.json.boundingVolume.region,!!A.json.boundingVolume.region,A.geometricError)):Q.includes(".json")&&A.tileLoader.get(A.abortController,Q,A.uuid,A))}A.deleted||(A.json.content?g(A.json.content):A.json.contents&&A.json.contents.forEach(I=>g(I)))}loadMesh(A){this.deleted||this.meshContent.add(A)}loadJson(A,g){this.deleted||(this.json.children&&(this.jsonChildren=this.json.children),A.rootPath=_g.dirname(g),this.jsonChildren.push(A),this.hasUnloadedJSONContent--)}dispose(){const A=this;A.childrenTiles.forEach(g=>g.dispose()),A.deleted=!0,A.abortController&&A.abortController.abort(),this.parent=null,this.parentTile=null,this.dispatchEvent({type:"removed"})}disposeChildren(){this.childrenTiles.forEach(A=>A.dispose()),this.childrenTiles=[]}_update(A,g){const I=this;function Q(C){if(I.hasMeshContent&&!(I.meshContent.size<I.hasMeshContent)){if(C<0)return I.inFrustum=!1,void I.changeContentVisibility(!!I.loadOutsideView);if(I.inFrustum=!0,I.childrenTiles.length!=0){if(C>=I.master.geometricErrorMultiplier*I.geometricError)I.changeContentVisibility(!0);else if(C<I.master.geometricErrorMultiplier*I.geometricError){let E=!0;I.childrenTiles.every(a=>!!a.isReady()||(E=!1,!1)),E&&I.changeContentVisibility(!1)}}else I.changeContentVisibility(!0)}}I.isSetup&&(I.materialVisibility,I.boundingVolume&&I.geometricError&&(I.metric=I.calculateUpdateMetric(A,g)),I.childrenTiles.forEach(C=>C._update(A,g)),Q(I.metric),function(C){C<0&&I.hasMeshContent||(!I.hasMeshContent&&I.rootPath||C<I.master.geometricErrorMultiplier*I.geometricError&&I.meshContent.size>0)&&I.json&&I.jsonChildren&&I.childrenTiles.length!=I.jsonChildren.length&&I.jsonChildren.forEach(E=>{if(!(E.root||E.children||E.getChildren||E.content||E.contents))return;let a=new YQ({parentTile:I,queryParams:I.queryParams,parentGeometricError:I.geometricError,parentBoundingVolume:I.boundingVolume,parentRefinement:I.refinement,json:E,rootPath:I.rootPath,loadOutsideView:I.loadOutsideView,level:I.level+1,tileLoader:I.tileLoader,cameraOnLoad:A,master:I.master,centerModel:!1});I.childrenTiles.push(a)})}(I.metric),function(C){if(I.hasMeshContent){if(!I.inFrustum)return I.disposeChildren(),void Q(C);C>=I.master.geometricErrorMultiplier*I.geometricError&&(I.disposeChildren(),Q(C))}}(I.metric))}areAllChildrenLoadedAndHidden(){let A=!0;return this.childrenTiles.every(g=>{if(g.hasMeshContent){if(g.childrenTiles.length>0)return A=!1,!1;if(!g.inFrustum)return!0;if(!g.materialVisibility||g.meshesToDisplay!=g.meshesDisplayed)return A=!1,!1}else if(!g.areAllChildrenLoadedAndHidden())return A=!1,!1;return!0}),A}isReady(){if(!this.inFrustum)return!0;if(this.hasUnloadedJSONContent)return!1;if(!this.hasMeshContent||this.meshContent.size==0||!this.materialVisibility){if(this.childrenTiles.length>0){var A=!0;return this.childrenTiles.every(g=>!!g.isReady()||(A=!1,!1)),A}return!1}return!this.hasMeshContent||!(this.meshContent.size<this.hasMeshContent)&&!!this.materialVisibility}changeContentVisibility(A){this.materialVisibility=A}calculateUpdateMetric(A,g){if(this.boundingVolume instanceof cg){if(Eg.copy(this.boundingVolume.sphere),Eg.applyMatrix4(this.matrixWorld),!g.intersectsSphere(Eg))return-1}else{if(!(this.boundingVolume instanceof V.Sphere))return console.error("unsupported shape"),-1;if(Eg.copy(this.boundingVolume),Eg.applyMatrix4(this.matrixWorld),!g.intersectsSphere(Eg))return-1}let I=Math.max(0,A.position.distanceTo(Eg.center)-Eg.radius);if(I=Math.pow(I,this.distanceBias),I==0)return 0;const Q=this.matrixWorld.getMaxScaleOnAxis();this.master._renderSize(oQ);let C=oQ.y,E=A.fov;A.aspect<1&&(E*=A.aspect,C=oQ.x);let a=2*Math.tan(.5*E*.017453292519943295)*I;return 16*window.devicePixelRatio*a/(C*Q)}getSiblings(){const A=this,g=[];if(!A.parentTile)return g;let I=A.parentTile;for(;!I.hasMeshContent&&I.parentTile;)I=I.parentTile;return I.childrenTiles.forEach(Q=>{if(Q&&Q!=A){for(;!Q.hasMeshContent&&Q.childrenTiles[0];)Q=Q.childrenTiles[0];g.push(Q)}}),g}calculateDistanceToCamera(A){return this.boundingVolume instanceof cg?(Eg.copy(this.boundingVolume.sphere),Eg.applyMatrix4(this.matrixWorld)):this.boundingVolume instanceof V.Sphere?(Eg.copy(this.boundingVolume),Eg.applyMatrix4(this.matrixWorld)):console.error("unsupported shape"),Math.max(0,A.position.distanceTo(Eg.center)-Eg.radius)}getWorldMatrix(){return this.matrixWorld}transformWGS84ToCartesian(A,g,I,Q){const C=6378137/Math.sqrt(1-.006694384442042*Math.pow(Math.sin(g),2)),E=Math.cos(g),a=Math.cos(A),i=Math.sin(g),t=C+I,e=t*E*a,o=t*E*Math.sin(A),r=(.993305615557957*C+I)*i;Q.set(e,o,r)}}class Ao extends V.Object3D{constructor(A){super(),A.master=this,A.domWidth&&A.domHeight?this.rendererSize=new V.Vector2(A.domWidth,A.domHeight):this.rendererSize=new V.Vector2(1e3,1e3),this.renderer=A.renderer,this.distanceBias=Math.max(1e-4,A.distanceBias?A.distanceBias:1),this.geometricErrorMultiplier=A.geometricErrorMultiplier?A.geometricErrorMultiplier:1,this.tileset=new YQ(A),A.static&&(this.matrixAutoUpdate=!1),this.tileLoader=A.tileLoader}_renderSize(A){this.renderer?this.renderer.getDrawingBufferSize(A):A.copy(this.rendererSize)}setCanvasSize(A,g){this.rendererSize.set(A,g)}update(A,g){if(g)this.tileset._update(A,g);else{const I=new V.Frustum;I.setFromProjectionMatrix(new V.Matrix4().multiplyMatrices(A.projectionMatrix,A.matrixWorldInverse)),this.tileset._update(A,I)}}setGeometricErrorMultiplier(A){this.geometricErrorMultiplier=A||1}}class go{constructor(A){const g=this;g.scene=A,g.instancedTiles=[],g.instancedMesh,g.reuseableMatrix=new V.Matrix4}addInstance(A){const g=this;A.added=!0,A.listOMesh=g.instancedTiles,g.instancedTiles.push(A),g.instancedMesh&&A.loadMesh(g.instancedMesh)}addToScene(){const A=this;A.instancedMesh.setMatrixAt(0,new V.Matrix4),A.instancedMesh.instanceMatrix.needsUpdate=!0,A.instancedMesh.count=1,A.scene.add(A.instancedMesh),A.instancedMesh.onAfterRender=()=>{delete A.instancedMesh.onAfterRender,A.instancedMesh.displayedOnce=!0}}setObject(A){const g=this;g.instancedMesh=A,g.instancedMesh.matrixAutoUpdate=!1,g.instancedMesh.matrixWorldAutoUpdate=!1,g.scene.children.includes(A)||this.addToScene();for(let I=0;I<g.instancedTiles.length;I++)g.instancedTiles[I].loadMesh(g.instancedMesh)}update(){const A=this;for(let g=A.instancedTiles.length-1;g>=0;g--)A.instancedTiles[g].deleted&&A.instancedTiles.splice(g,1);if(A.instancedMesh){A.instancedMesh.count=0,A.instancedMesh.instancedTiles=[];for(let g=0;g<A.instancedTiles.length;g++)A.instancedTiles[g].meshContent.add(A.instancedMesh),A.instancedTiles[g].materialVisibility&&(A.instancedMesh.count++,A.reuseableMatrix.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),A.reuseableMatrix.multiply(A.instancedTiles[g].matrixWorld),A.reuseableMatrix.multiply(A.instancedMesh.baseMatrix),A.instancedMesh.setMatrixAt(A.instancedMesh.count-1,A.reuseableMatrix),A.instancedMesh.instancedTiles.push(A.instancedTiles[g]));A.instancedMesh.instanceMatrix.needsUpdate=!0,A.instancedMesh.needsUpdate=!0,A.instancedMesh.computeBoundingSphere()}}getCount(){return this.instancedTiles.length}dispose(){const A=this;return!(A.instancedTiles.length>0)&&!!A.instancedMesh&&(A.scene.remove(A.instancedMesh),A.instancedMesh.traverse(g=>{if(g.dispose&&g.dispose(),g.material)if(g.material.length)for(let I=0;I<g.material.length;++I)g.material[I].dispose();else g.material.dispose();g.geometry&&g.geometry.dispose()}),A.instancedMesh.dispose(),!0)}}class Io{constructor(){const A=this;A.count=0,A.json,A.instancedTiles=[]}addInstance(A){this.instancedTiles.push(A),this.json&&A.loadJson(this.json,this.url)}setObject(A,g){const I=this;I.json=A,I.url=g;for(let Q=0;Q<I.instancedTiles.length;Q++)I.instancedTiles[Q].loadJson(I.json,I.url)}getCount(){return this.instancedTiles.length}update(){const A=this;for(let g=A.instancedTiles.length-1;g>=0;g--)A.instancedTiles[g].deleted&&A.instancedTiles.splice(g,1)}dispose(){return!(!this.json||this.instancedTiles.length!=0)}}let CI=0;async function Bo(B){return new Promise(A=>{const g=setInterval(()=>{B.hasDracoLoader&&!B.dracoLoader||B.hasKTX2Loader&&!B.ktx2Loader||(clearInterval(g),A())},10)})}exports.InstancedOGC3DTile=Ao,exports.InstancedTileLoader=class{constructor(B,A){if(this.zUpToYUpMatrix=new V.Matrix4,this.zUpToYUpMatrix.set(1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1),this.maxCachedItems=100,this.maxInstances=1,this.proxy=A.proxy,A&&(this.meshCallback=A.meshCallback,this.pointsCallback=A.pointsCallback,A.maxCachedItems&&(this.maxCachedItems=A.maxCachedItems),A.maxInstances&&(this.maxInstances=A.maxInstances)),this.gltfLoader=new _C,A&&A.dracoLoader)this.gltfLoader.setDRACOLoader(A.dracoLoader),this.hasDracoLoader=!0;else{const g=new gE;g.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),this.gltfLoader.setDRACOLoader(g),this.gltfLoader.hasDracoLoader=!0}if(A&&A.ktx2Loader)this.gltfLoader.setKTX2Loader(A.ktx2Loader),this.hasKTX2Loader=!0;else if(A&&A.renderer){const g=new hg;g.setTranscoderPath("https://storage.googleapis.com/ogc-3d-tiles/basis/").detectSupport(A.renderer),this.gltfLoader.setKTX2Loader(g),this.gltfLoader.hasKTX2Loader=!0}this.gltfLoader.setMeshoptDecoder(HE),this.hasMeshOptDecoder=!0,this.b3dmDecoder=new XC(this.gltfLoader),this.cache=new VC,this.scene=B,this.ready=[],this.downloads=[],this.nextReady=[],this.nextDownloads=[]}update(){const B=this;B._checkSize(),B.cache._data.forEach(A=>{A.update()}),CI<8&&B._download(),B._loadBatch()}_download(){const B=this;if(B.nextDownloads.length!=0||(B._getNextDownloads(),B.nextDownloads.length!=0))for(;B.nextDownloads.length>0;){const g=B.nextDownloads.shift();if(g){if(g.path.includes(".b3dm")&&(A=B.proxy?()=>fetch(B.proxy,{method:"POST",body:g.path}):()=>fetch(g.path),CI++,A().then(I=>{if(!I.ok)throw console.error("could not load tile with path : "+g.path),new Error(`couldn't load "${g.path}". Request failed with status ${I.status} : ${I.statusText}`);return I.arrayBuffer()}).then(I=>this.b3dmDecoder.parseB3DMInstanced(I,Q=>{B.meshCallback(Q,g.geometricError)},B.maxInstances,g.sceneZupToYup,g.meshZupToYup)).then(I=>{I.frustumCulled=!1,g.tile.setObject(I),B.ready.unshift(g)}).catch(I=>console.error(I)).finally(()=>{CI--})),g.path.includes(".glb")||g.path.includes(".gltf"))A=B.proxy?()=>fetch(B.proxy,{method:"POST",body:g.path}):()=>fetch(g.path),CI++,A().then(I=>{if(!I.ok)throw new Error("missing content");return I.arrayBuffer()}).then(async I=>{await Bo(this.gltfLoader),this.gltfLoader.parse(I,null,Q=>{let C;Q.scene.asset=Q.asset,g.sceneZupToYup&&Q.scene.applyMatrix4(this.zUpToYUpMatrix),Q.scene.traverse(E=>{E.geometricError=g.geometricError,E.isMesh&&(g.meshZupToYup&&E.applyMatrix4(this.zUpToYUpMatrix),B.meshCallback&&B.meshCallback(E,E.geometricError)),E.isPoints&&console.error("instanced point cloud is not supported")}),Q.scene.updateWorldMatrix(!1,!0),Q.scene.traverse(E=>{E.isMesh&&(C=new V.InstancedMesh(E.geometry,E.material,B.maxInstances),C.baseMatrix=E.matrixWorld)}),B.ready.unshift(g),C?(C.frustumCulled=!1,g.tile.setObject(C)):Q.scene.traverse(E=>{E.dispose&&E.dispose(),E.material&&E.material.dispose()})})},I=>{console.error("could not load tile : "+g.path)}).finally(()=>{CI--});else if(g.path.includes(".json")){var A;A=B.proxy?()=>fetch(B.proxy,{method:"POST",body:g.path}):()=>fetch(g.path),CI++,A().then(I=>{if(!I.ok)throw console.error("could not load tile with path : "+g.path),new Error(`couldn't load "${g.path}". Request failed with status ${I.status} : ${I.statusText}`);return I.json()}).then(I=>GQ(I,g.path)).then(I=>{g.tile.setObject(I,g.path),B.ready.unshift(g)}).catch(I=>console.error(I)).finally(()=>{CI--})}}}}_loadBatch(){return this.nextReady.length==0&&(this._getNextReady(),this.nextReady.length==0)?0:this.nextReady.shift()?1:0}_getNextReady(){let B=Number.MAX_VALUE,A=-1;for(let g=this.ready.length-1;g>=0;g--)this.ready[g].distanceFunction||this.nextReady.push(this.ready.splice(g,1)[0]);if(!(this.nextReady.length>0)){for(let g=this.ready.length-1;g>=0;g--){const I=this.ready[g].distanceFunction()*this.ready[g].level;I<B&&(B=I,A=g)}if(A>=0){const g=this.ready.splice(A,1).pop();this.nextReady.push(g);const I=g.getSiblings();for(let Q=this.ready.length-1;Q>=0;Q--)I.includes(this.ready[Q].uuid)&&this.nextready.push(this.ready.splice(Q,1).pop())}}}get(B,A,g,I,Q,C,E,a,i,t){const e=this,o=function(n){for(var s=n.split("/"),c=[],D=0,b=0;b<s.length;b++){var h=s[b];h!=="."&&h!==""&&h!==".."?c[D++]=h:h===".."&&D>0&&D--}if(D===0)return"/";var w="";for(b=0;b<D;b++)w+="/"+c[b];return w}(A);if(!(A.includes(".b3dm")||A.includes(".json")||A.includes(".glb")||A.includes(".gltf")))return void console.error("the 3DTiles cache can only be used to load B3DM, gltf and json data");const r=e.cache.get(o);if(r)r.addInstance(I);else if(A.includes(".b3dm")||A.includes(".glb")||A.includes(".gltf")){const n=new go(e.scene);n.addInstance(I),e.cache.put(o,n);const s=new AbortController;B.signal.addEventListener("abort",()=>{n.getCount()==0&&s.abort()}),this.downloads.push({abortController:s,tile:n,key:o,path:A,distanceFunction:Q,getSiblings:C,level:E,uuid:g,sceneZupToYup:a,meshZupToYup:i,geometricError:t,shouldDoDownload:()=>!0})}else if(A.includes(".json")){const n=new Io;n.addInstance(I),e.cache.put(o,n);const s=new AbortController;B.signal.addEventListener("abort",()=>{n.getCount()==0&&s.abort()}),this.downloads.push({abortController:s,tile:n,key:o,path:A,distanceFunction:Q,getSiblings:C,level:E,shouldDoDownload:()=>!0})}}_getNextDownloads(){let B=Number.MAX_VALUE,A=-1;for(let g=this.downloads.length-1;g>=0;g--){const I=this.downloads[g];I.shouldDoDownload()?I.distanceFunction||this.nextDownloads.push(this.downloads.splice(g,1)[0]):this.downloads.splice(g,1)}if(!(this.nextDownloads.length>0)){for(let g=this.downloads.length-1;g>=0;g--){const I=this.downloads[g],Q=I.distanceFunction()*I.level;Q<B&&(B=Q,A=g)}if(A>=0){const g=this.downloads.splice(A,1).pop();this.nextDownloads.push(g);const I=g.getSiblings();for(let Q=this.downloads.length-1;Q>=0;Q--)I.includes(this.downloads[Q].uuid)&&this.nextDownloads.push(this.downloads.splice(Q,1).pop())}}}_checkSize(){const B=this;let A=0;for(;B.cache.size()>B.maxCachedItems&&A<B.cache.size();){A++;const g=B.cache.head();B.cache.remove(g.key),g.value.dispose()||B.cache.put(g.key,g.value)}}},exports.OBB=cg,exports.OGC3DTile=JQ,exports.OcclusionCullingService=class{constructor(){this.cullMap=[],this.cullMaterial=new V.MeshBasicMaterial({vertexColors:!0}),this.cullMaterial.side=V.FrontSide,this.cullTarget=this._createCullTarget(),this.cullPixels=new Uint8Array(4*this.cullTarget.width*this.cullTarget.height)}setSide(B){this.cullMaterial.side=B}_createCullTarget(){const B=new V.WebGLRenderTarget(Math.floor(.05*window.innerWidth),Math.floor(.05*window.innerHeight));return B.texture.format=V.RGBAFormat,B.texture.colorSpace=V.LinearSRGBColorSpace,B.texture.minFilter=V.NearestFilter,B.texture.magFilter=V.NearestFilter,B.texture.generateMipmaps=!1,B.stencilBuffer=!1,B.depthBuffer=!0,B.depthTexture=new V.DepthTexture,B.depthTexture.format=V.DepthFormat,B.depthTexture.type=V.UnsignedShortType,B}update(B,A,g){let I=A.getRenderTarget(),Q=B.overrideMaterial;B.overrideMaterial=this.cullMaterial,A.setRenderTarget(this.cullTarget),A.render(B,g),B.overrideMaterial=Q,A.setRenderTarget(I),A.readRenderTargetPixels(this.cullTarget,0,0,this.cullTarget.width,this.cullTarget.height,this.cullPixels),this.cullMap=[];for(let C=0;C<this.cullPixels.length;C+=4){const E=V.MathUtils.clamp(this.cullPixels[C],0,255)<<16^V.MathUtils.clamp(this.cullPixels[C+1],0,255)<<8^V.MathUtils.clamp(this.cullPixels[C+2],0,255);this.cullMap[E]=!0}}hasID(B){return this.cullMap[B]}},exports.SplatsMesh=fa,exports.TileLoader=KE,exports.getOGC3DTilesCopyrightInfo=Ma,exports.splatsFragmentShader=ya,exports.splatsVertexShader=Fa;
1398
1398
  //# sourceMappingURL=threedtiles.cjs.js.map