@jdultra/threedtiles 14.0.4 → 14.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/splats/SplatsMesh.d.ts +2 -0
- package/dist/threedtiles.cjs.js +10 -6
- package/dist/threedtiles.cjs.js.map +1 -1
- package/dist/threedtiles.es.js +14 -4
- package/dist/threedtiles.es.js.map +1 -1
- package/dist/threedtiles.umd.js +10 -6
- package/dist/threedtiles.umd.js.map +1 -1
- package/dist/tileset/OGC3DTile.d.ts +6 -0
- package/package.json +1 -1
|
@@ -30,6 +30,8 @@ export class SplatsMesh extends Mesh<import("three").BufferGeometry<import("thre
|
|
|
30
30
|
*/
|
|
31
31
|
setQuality(quality: number): void;
|
|
32
32
|
setSplatsCPUCulling(splatsCPUCuling: any): void;
|
|
33
|
+
setDepthBias(depthBias: any): void;
|
|
34
|
+
depthBias: any;
|
|
33
35
|
updateShaderParams(camera: any): void;
|
|
34
36
|
dispose(): void;
|
|
35
37
|
copyTex2D(src: any, dst: any, scissorBox: any, layer: any): void;
|
package/dist/threedtiles.cjs.js
CHANGED
|
@@ -1124,7 +1124,7 @@ self.onmessage = function(I) {
|
|
|
1124
1124
|
}
|
|
1125
1125
|
};
|
|
1126
1126
|
//# sourceMappingURL=PointsManager.worker-dH1fNyu8.js.map
|
|
1127
|
-
`,qC=typeof self<"u"&&self.Blob&&new Blob(["URL.revokeObjectURL(import.meta.url);",ua],{type:"text/javascript;charset=utf-8"});function Vt(B){let A;try{if(A=qC&&(self.URL||self.webkitURL).createObjectURL(qC),!A)throw"";const g=new Worker(A,{type:"module",name:B?.name});return g.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(A)}),g}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(ua),{type:"module",name:B?.name})}}new d.Vector3,new d.Vector3;const la=new d.Matrix3;la.set(1,0,0,0,0,1,0,-1,0);const zt=new d.Matrix4().set(1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1);function eQ(B,A){return(d.DataUtils.toHalfFloat(B)|d.DataUtils.toHalfFloat(A)<<16)>>>0}class fa extends d.Mesh{constructor(A,g,I){const C=Math.min(Math.ceil(4)*1024,Math.pow(1024,2));let E=1*Math.pow(1024,2);E=Math.floor(E/C)*C;const a=new d.WebGL3DRenderTarget(1024,1024,1,{magFilter:d.NearestFilter,minFilter:d.NearestFilter,type:d.UnsignedIntType,format:d.RGBAIntegerFormat,anisotropy:0,depthBuffer:!1,resolveDepthBuffer:!1});a.texture.type=d.UnsignedIntType,a.texture.format=d.RGBAIntegerFormat,a.texture.internalFormat="RGBA32UI",A.initRenderTarget(a);const i=new d.WebGL3DRenderTarget(1024,1024,1,{magFilter:d.NearestFilter,minFilter:d.NearestFilter,anisotropy:0,type:d.UnsignedIntType,format:d.RGBAIntegerFormat,depthBuffer:!1,resolveDepthBuffer:!1});i.texture.type=d.UnsignedIntType,i.texture.format=d.RGBAIntegerFormat,i.texture.internalFormat="RGBA32UI",A.initRenderTarget(i);const t=new d.ShaderMaterial({glslVersion:d.GLSL3,uniforms:{textureSize:{value:1024},numSlices:{value:1},covarianceTexture:{value:i.texture},positionColorTexture:{value:a.texture},zUpToYUpMatrix3x3:{value:la},sizeMultiplier:{value:1},cropRadius:{value:Number.MAX_VALUE},viewportPixelSize:{value:new d.Vector2},k:{value:2},beta_k:{value:2},minSplatPixelSize:{value:0},minOpacity:{value:.01},culling:{value:!1},antialiasingFactor:{value:2}},vertexShader:Fa(),fragmentShader:I||ya(),transparent:!0,side:d.FrontSide,depthTest:!0,depthWrite:!1,blending:d.NormalBlending}),e=new d.InstancedBufferGeometry,o=new Float32Array([-.5,.5,0,.5,.5,0,-.5,-.5,0,.5,-.5,0]);e.setIndex([0,2,1,2,3,1]),e.setAttribute("position",new d.BufferAttribute(o,3));const r=new Uint32Array(E),n=new d.InstancedBufferAttribute(r,1,!1);n.needsUpdate=!0,n.setUsage(d.DynamicDrawUsage),e.setAttribute("order",n),e.instanceCount=0,super(e,t),this.matrixAutoUpdate=!1,this.numBatches=0,this.numVisibleBatches=0,this.orderAttribute=n,this.textureSize=1024,this.numTextures=1,this.batchSize=C,this.maxSplats=E,this.numSplatsRendered=0,this.positionColorRenderTarget=a,this.covarianceRenderTarget=i,this.renderer=A,this.sortID=0,this.freeAddresses=new OI;for(let c=0;c<this.maxSplats;c+=C)this.freeAddresses.add(c);this.worker=new Vt,this.sortListeners=[],this.worker.onmessage=c=>{const D=new Uint32Array(c.data.order);if(this.numSplatsRendered=D.length,D.length>this.orderAttribute.count){const b=new d.InstancedBufferGeometry,h=new Float32Array([-.5,.5,0,.5,.5,0,-.5,-.5,0,.5,-.5,0]),w=[0,2,1,2,3,1];b.setIndex(w),b.setAttribute("position",new d.BufferAttribute(h,3));const f=new Uint32Array(this.maxSplats),p=new d.InstancedBufferAttribute(f,1,!1);p.needsUpdate=!0,p.setUsage(d.DynamicDrawUsage),b.setAttribute("order",p),b.instanceCount=0,this.geometry.dispose(),this.geometry=b,this.orderAttribute=p}this.orderAttribute.clearUpdateRanges(),this.orderAttribute.set(D),this.orderAttribute.addUpdateRange(0,D.length),this.orderAttribute.needsUpdate=!0,this.geometry.instanceCount=c.data.count,this.geometry.needsUpdate=!0;for(let b=this.sortListeners.length-1;b>=0;b--)this.sortListeners[b](c.data.id)&&this.sortListeners.splice(b,1)},this.cameraPosition=new d.Vector3(0,0,0),this.viewProjModel,this.rotateOnAxis(new d.Vector3(1,0,0),.5*Math.PI),this.frustumCulled=!1,this.copyMaterial2D=new d.ShaderMaterial({glslVersion:d.GLSL3,uniforms:{sourceTexture:{}},vertexShader:vC(),fragmentShader:`
|
|
1127
|
+
`,qC=typeof self<"u"&&self.Blob&&new Blob(["URL.revokeObjectURL(import.meta.url);",ua],{type:"text/javascript;charset=utf-8"});function Vt(B){let A;try{if(A=qC&&(self.URL||self.webkitURL).createObjectURL(qC),!A)throw"";const g=new Worker(A,{type:"module",name:B?.name});return g.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(A)}),g}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(ua),{type:"module",name:B?.name})}}new d.Vector3,new d.Vector3;const la=new d.Matrix3;la.set(1,0,0,0,0,1,0,-1,0);const zt=new d.Matrix4().set(1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1);function eQ(B,A){return(d.DataUtils.toHalfFloat(B)|d.DataUtils.toHalfFloat(A)<<16)>>>0}class fa extends d.Mesh{constructor(A,g,I){const C=Math.min(Math.ceil(4)*1024,Math.pow(1024,2));let E=1*Math.pow(1024,2);E=Math.floor(E/C)*C;const a=new d.WebGL3DRenderTarget(1024,1024,1,{magFilter:d.NearestFilter,minFilter:d.NearestFilter,type:d.UnsignedIntType,format:d.RGBAIntegerFormat,anisotropy:0,depthBuffer:!1,resolveDepthBuffer:!1});a.texture.type=d.UnsignedIntType,a.texture.format=d.RGBAIntegerFormat,a.texture.internalFormat="RGBA32UI",A.initRenderTarget(a);const i=new d.WebGL3DRenderTarget(1024,1024,1,{magFilter:d.NearestFilter,minFilter:d.NearestFilter,anisotropy:0,type:d.UnsignedIntType,format:d.RGBAIntegerFormat,depthBuffer:!1,resolveDepthBuffer:!1});i.texture.type=d.UnsignedIntType,i.texture.format=d.RGBAIntegerFormat,i.texture.internalFormat="RGBA32UI",A.initRenderTarget(i);const t=new d.ShaderMaterial({glslVersion:d.GLSL3,uniforms:{textureSize:{value:1024},numSlices:{value:1},covarianceTexture:{value:i.texture},positionColorTexture:{value:a.texture},zUpToYUpMatrix3x3:{value:la},sizeMultiplier:{value:1},cropRadius:{value:Number.MAX_VALUE},viewportPixelSize:{value:new d.Vector2},k:{value:2},beta_k:{value:2},minSplatPixelSize:{value:0},minOpacity:{value:.01},culling:{value:!1},antialiasingFactor:{value:2},depthBias:{value:0}},vertexShader:Fa(),fragmentShader:I||ya(),transparent:!0,side:d.FrontSide,depthTest:!0,depthWrite:!1,blending:d.NormalBlending}),e=new d.InstancedBufferGeometry,o=new Float32Array([-.5,.5,0,.5,.5,0,-.5,-.5,0,.5,-.5,0]);e.setIndex([0,2,1,2,3,1]),e.setAttribute("position",new d.BufferAttribute(o,3));const r=new Uint32Array(E),n=new d.InstancedBufferAttribute(r,1,!1);n.needsUpdate=!0,n.setUsage(d.DynamicDrawUsage),e.setAttribute("order",n),e.instanceCount=0,super(e,t),this.matrixAutoUpdate=!1,this.numBatches=0,this.numVisibleBatches=0,this.orderAttribute=n,this.textureSize=1024,this.numTextures=1,this.batchSize=C,this.maxSplats=E,this.numSplatsRendered=0,this.positionColorRenderTarget=a,this.covarianceRenderTarget=i,this.renderer=A,this.sortID=0,this.freeAddresses=new OI;for(let c=0;c<this.maxSplats;c+=C)this.freeAddresses.add(c);this.worker=new Vt,this.sortListeners=[],this.worker.onmessage=c=>{const D=new Uint32Array(c.data.order);if(this.numSplatsRendered=D.length,D.length>this.orderAttribute.count){const b=new d.InstancedBufferGeometry,h=new Float32Array([-.5,.5,0,.5,.5,0,-.5,-.5,0,.5,-.5,0]),w=[0,2,1,2,3,1];b.setIndex(w),b.setAttribute("position",new d.BufferAttribute(h,3));const f=new Uint32Array(this.maxSplats),p=new d.InstancedBufferAttribute(f,1,!1);p.needsUpdate=!0,p.setUsage(d.DynamicDrawUsage),b.setAttribute("order",p),b.instanceCount=0,this.geometry.dispose(),this.geometry=b,this.orderAttribute=p}this.orderAttribute.clearUpdateRanges(),this.orderAttribute.set(D),this.orderAttribute.addUpdateRange(0,D.length),this.orderAttribute.needsUpdate=!0,this.geometry.instanceCount=c.data.count,this.geometry.needsUpdate=!0;for(let b=this.sortListeners.length-1;b>=0;b--)this.sortListeners[b](c.data.id)&&this.sortListeners.splice(b,1)},this.cameraPosition=new d.Vector3(0,0,0),this.viewProjModel,this.rotateOnAxis(new d.Vector3(1,0,0),.5*Math.PI),this.frustumCulled=!1,this.copyMaterial2D=new d.ShaderMaterial({glslVersion:d.GLSL3,uniforms:{sourceTexture:{}},vertexShader:vC(),fragmentShader:`
|
|
1128
1128
|
precision highp float;
|
|
1129
1129
|
precision highp int;
|
|
1130
1130
|
precision highp usampler2D;
|
|
@@ -1149,7 +1149,7 @@ in vec2 vUv;
|
|
|
1149
1149
|
|
|
1150
1150
|
void main() {
|
|
1151
1151
|
fragColor = texture( sourceTexture, vec3(vUv, w) );
|
|
1152
|
-
}`,transparent:!1,side:d.FrontSide,depthTest:!1,depthWrite:!1}),this.copyCamera=new d.OrthographicCamera(-.5,.5,.5,-.5,.1,10),this.copyCamera.position.z=1,this.copyScene=new d.Scene;const s=new d.PlaneGeometry(1,1);this.copyQuad=new d.Mesh(s,this.copyMaterial2D),this.copyScene.add(this.copyQuad),this.copyScene.matrixAutoUpdate=!1,this.copyQuad.matrixAutoUpdate=!1,this.splatsCPUCuling=!1}setQuality(A){const g=2+2*(A=Math.max(0,Math.min(1,1-A)));this.material.uniforms.k.value=g,this.material.uniforms.beta_k.value=Math.pow(4*Wt(2/g)/g,g/2),this.material.uniforms.minSplatPixelSize.value=5*A,this.material.uniforms.minOpacity.value=.01}setSplatsCPUCulling(A){this.splatsCPUCuling=A,this.material.uniforms.culling.value=A}updateShaderParams(A){A.projectionMatrix.elements,this.renderer.getSize(this.material.uniforms.viewportPixelSize.value);const g=this.renderer.getPixelRatio();this.material.uniforms.viewportPixelSize.value.multiplyScalar(g),this.material.uniforms.antialiasingFactor.value=2}dispose(){this.material.dispose(),this.copyMaterial2D.dispose(),this.copyMaterial3D.dispose(),this.covarianceRenderTarget.dispose(),this.positionColorRenderTarget.dispose(),this.worker.terminate(),this.worker=null,this.orderAttribute.array=void 0,this.geometry.dispose()}copyTex2D(A,g,I,Q){this.copyMaterial2D.uniforms.sourceTexture.value=A;const C=this.renderer.autoClear,E=this.renderer.getRenderTarget();this.renderer.autoClear=!1;const a=I[2]-I[0],i=I[3]-I[1];g.viewport.set(I[0],I[1],a,i),this.renderer.setRenderTarget(g,Q),this.renderer.render(this.copyScene,this.copyCamera),this.renderer.setRenderTarget(E),this.renderer.autoClear=C}copyTex3D(A,g,I){this.copyMaterial3D.uniforms.sourceTexture.value=A;const Q=this.renderer.autoClear,C=this.renderer.getRenderTarget();this.renderer.autoClear=!1,this.copyQuad.material=this.copyMaterial3D;for(let E=0;E<I;E++)this.renderer.setRenderTarget(g,E),this.copyMaterial3D.uniforms.w.value=(E+.5)/I,this.renderer.render(this.copyScene,this.copyCamera);this.copyQuad.material=this.copyMaterial2D,this.renderer.setRenderTarget(C),this.renderer.autoClear=Q}setSplatsSizeMultiplier(A){this.material.uniforms.sizeMultiplier.value=A}setSplatsCropRadius(A){this.material.uniforms.cropRadius.value=A}sort(A,g){this.worker&&(A?this.cameraPosition&&A.equals(this.cameraPosition)||(this.cameraPosition.copy(A),g?(this.viewProjModel||(this.viewProjModel=new d.Matrix4),this.viewProjModel.copy(g),this.viewProjModel.multiply(zt)):this.viewProjModel=void 0,this.worker.postMessage({method:"sort",xyz:[this.cameraPosition.x,this.cameraPosition.z,-this.cameraPosition.y],vpm:this.viewProjModel&&this.splatsCPUCuling?this.viewProjModel.toArray():void 0,id:this.sortID++})):this.worker.postMessage({method:"sort",xyz:[this.cameraPosition.x,this.cameraPosition.z,-this.cameraPosition.y],vpm:this.viewProjModel&&this.splatsCPUCuling?this.viewProjModel.toArray():void 0,id:this.sortID++}))}raycast(A,g){}addSplatsTile(A,g,I,Q){if(!this.worker)return;const C=this,E=A.data?A.data.array:A.array,a=A.data&&A.data.isInterleavedBuffer?A.data.stride:3,i=A.data&&A.data.isInterleavedBuffer?A.offset:0,t=Math.ceil(E.length/(this.batchSize*a)),e=[],o=[];let r=()=>{};const n=new Float32Array(E.length/a*3),s=new Uint32Array(n.buffer,n.byteOffset,n.length);for(let D=0;D<E.length/3;D++)n[3*D]=E[D*a+i],n[3*D+1]=E[D*a+i+1],n[3*D+2]=E[D*a+i+2];r=(D,b,h)=>{const w=h*h,f=Math.pow(C.material.uniforms.cropRadius.value,2),p=new d.Matrix3,R=new d.Vector3,U=new d.Vector3,G=new d.Vector3,k=new d.Vector3,J=n.length/3;for(let m=0;m<J;m++){if(R.set(n[3*m],-n[3*m+2],n[3*m+1]),R.lengthSq()>f||D.distanceSqToPoint(R)>w)continue;Xt(I,Q,m,p);const O=U.copy(R).sub(D.origin).dot(D.direction);if(O<0)continue;k.copy(D.direction).multiplyScalar(O).add(D.origin);const X=U.copy(k).sub(R);Zt(p,X,G);const IA=X.dot(G),AA=g.getW(m)*Math.exp(-.5*IA);AA>.01&&b.push({distance:O,point:k.clone(),opacity:AA,type:"splat",object:this})}},t>this.freeAddresses.size&&this.growTextures();for(let D=0;D<t;D++){const b=this.freeAddresses.poll();isNaN(b)&&console.log("insuficient texture size to store splats info"),e.push(b),o.push(3*b);const h=D*this.batchSize;this.addSplatsBatch(h,b,s,g,I,Q)}C.worker.postMessage({method:"addBatches",insertionIndexes:o,positions:E.buffer,offset:i,stride:a,batchSize:C.batchSize},[E.buffer]);let c=!1;return{hide:()=>{c==1&&C.worker&&(C.numVisibleBatches--,c=!1,C.worker.postMessage({method:"hideBatches",insertionIndexes:o,xyz:[C.cameraPosition.x,C.cameraPosition.z,-C.cameraPosition.y],vpm:this.viewProjModel&&this.splatsCPUCuling?this.viewProjModel.toArray():void 0,id:C.sortID++}))},show:D=>{if(c==0&&C.worker){C.numVisibleBatches--,c=!0;const b=C.sortID,h=w=>w>=b&&(D(),!0);C.sortListeners.push(h),C.worker.postMessage({method:"showBatches",insertionIndexes:o,xyz:[C.cameraPosition.x,C.cameraPosition.z,-C.cameraPosition.y],vpm:this.viewProjModel&&this.splatsCPUCuling?this.viewProjModel.toArray():void 0,id:C.sortID++})}},remove:()=>{C.worker&&(r=void 0,C.worker.postMessage({method:"removeBatches",insertionIndexes:o,xyz:[C.cameraPosition.x,C.cameraPosition.z,-C.cameraPosition.y],vpm:this.viewProjModel&&this.splatsCPUCuling?this.viewProjModel.toArray():void 0,id:C.sortID++}),e.forEach(D=>C.freeAddresses.add(D)))},sort:this.sort,raycast:r,isSplatsBatch:!0}}addSplatsBatch(A,g,I,Q,C,E){const a=new Uint32Array(4*this.batchSize),i=new Uint32Array(4*this.batchSize);for(let s=g;s<g+this.batchSize;s++){const c=s-g,D=4*c,b=A+c,h=3*(A+c);if(b>=I.count)break;a[D]=I[h],a[D+1]=I[h+1],a[D+2]=I[h+2];const w=0|Math.floor(255*Q.getX(b)+.5),f=0|Math.floor(255*Q.getY(b)+.5),p=0|Math.floor(255*Q.getZ(b)+.5),R=0|Math.floor(255*Q.getW(b)+.5);a[D+3]=w|f<<8|p<<16|R<<24,i[D]=eQ(C.getX(b),C.getY(b)),i[D+1]=eQ(C.getZ(b),E.getX(b)),i[D+2]=eQ(E.getY(b),E.getZ(b))}const t=Math.floor(g/Math.pow(this.textureSize,2)),e=Math.ceil(this.batchSize/this.textureSize),o=[0,g/this.textureSize-t*this.textureSize,this.textureSize];o.push(o[1]+e);const r=new d.DataTexture(a,this.textureSize,e,d.RGBAIntegerFormat,d.UnsignedIntType);r.internalFormat="RGBA32UI",r.generateMipmaps=!1,r.magFilter=d.NearestFilter,r.minFilter=d.NearestFilter,r.anisotropy=0,r.needsUpdate=!0,this.renderer.initTexture(r),this.copyTex2D(r,this.positionColorRenderTarget,o,t),r.dispose();const n=new d.DataTexture(i,this.textureSize,e,d.RGBAIntegerFormat,d.UnsignedIntType);n.internalFormat="RGBA32UI",n.generateMipmaps=!1,n.magFilter=d.NearestFilter,n.minFilter=d.NearestFilter,n.anisotropy=0,n.needsUpdate=!0,this.renderer.initTexture(n),this.copyTex2D(n,this.covarianceRenderTarget,o,t),n.dispose()}growTextures(){for(let Q=this.maxSplats;Q<this.maxSplats+this.textureSize*this.textureSize;Q+=this.batchSize)this.freeAddresses.add(Q);this.maxSplats+=this.textureSize*this.textureSize;const A=this.numTextures+1,g=new d.WebGL3DRenderTarget(this.textureSize,this.textureSize,A,{magFilter:d.NearestFilter,minFilter:d.NearestFilter,type:d.UnsignedIntType,format:d.RGBAIntegerFormat,anisotropy:0,depthBuffer:!1,resolveDepthBuffer:!1});g.texture.type=d.UnsignedIntType,g.texture.internalFormat="RGBA32UI",g.texture.format=d.RGBAIntegerFormat,this.renderer.initRenderTarget(g),this.copyTex3D(this.positionColorRenderTarget.texture,g,this.numTextures),this.positionColorRenderTarget.dispose(),this.positionColorRenderTarget=g,this.material.uniforms.positionColorTexture.value=this.positionColorRenderTarget.texture;const I=new d.WebGL3DRenderTarget(this.textureSize,this.textureSize,A,{magFilter:d.NearestFilter,minFilter:d.NearestFilter,anisotropy:0,type:d.UnsignedIntType,format:d.RGBAIntegerFormat,depthBuffer:!1,resolveDepthBuffer:!1});I.texture.type=d.UnsignedIntType,I.texture.internalFormat="RGBA32UI",I.texture.format=d.RGBAIntegerFormat,this.renderer.initRenderTarget(I),this.copyTex3D(this.covarianceRenderTarget.texture,I,this.numTextures),this.covarianceRenderTarget.dispose(),this.covarianceRenderTarget=I,this.material.uniforms.covarianceTexture.value=this.covarianceRenderTarget.texture,this.numTextures=A,this.material.uniforms.numSlices.value=this.numTextures}}function Fa(){return`
|
|
1152
|
+
}`,transparent:!1,side:d.FrontSide,depthTest:!1,depthWrite:!1}),this.copyCamera=new d.OrthographicCamera(-.5,.5,.5,-.5,.1,10),this.copyCamera.position.z=1,this.copyScene=new d.Scene;const s=new d.PlaneGeometry(1,1);this.copyQuad=new d.Mesh(s,this.copyMaterial2D),this.copyScene.add(this.copyQuad),this.copyScene.matrixAutoUpdate=!1,this.copyQuad.matrixAutoUpdate=!1,this.splatsCPUCuling=!1}setQuality(A){const g=2+2*(A=Math.max(0,Math.min(1,1-A)));this.material.uniforms.k.value=g,this.material.uniforms.beta_k.value=Math.pow(4*Wt(2/g)/g,g/2),this.material.uniforms.minSplatPixelSize.value=5*A,this.material.uniforms.minOpacity.value=.01}setSplatsCPUCulling(A){this.splatsCPUCuling=A,this.material.uniforms.culling.value=A}setDepthBias(A){this.depthBias=A,this.material.uniforms.depthBias.value=this.depthBias}updateShaderParams(A){A.projectionMatrix.elements,this.renderer.getSize(this.material.uniforms.viewportPixelSize.value);const g=this.renderer.getPixelRatio();this.material.uniforms.viewportPixelSize.value.multiplyScalar(g),this.material.uniforms.antialiasingFactor.value=2}dispose(){this.material.dispose(),this.copyMaterial2D.dispose(),this.copyMaterial3D.dispose(),this.covarianceRenderTarget.dispose(),this.positionColorRenderTarget.dispose(),this.worker.terminate(),this.worker=null,this.orderAttribute.array=void 0,this.geometry.dispose()}copyTex2D(A,g,I,Q){this.copyMaterial2D.uniforms.sourceTexture.value=A;const C=this.renderer.autoClear,E=this.renderer.getRenderTarget();this.renderer.autoClear=!1;const a=I[2]-I[0],i=I[3]-I[1];g.viewport.set(I[0],I[1],a,i),this.renderer.setRenderTarget(g,Q),this.renderer.render(this.copyScene,this.copyCamera),this.renderer.setRenderTarget(E),this.renderer.autoClear=C}copyTex3D(A,g,I){this.copyMaterial3D.uniforms.sourceTexture.value=A;const Q=this.renderer.autoClear,C=this.renderer.getRenderTarget();this.renderer.autoClear=!1,this.copyQuad.material=this.copyMaterial3D;for(let E=0;E<I;E++)this.renderer.setRenderTarget(g,E),this.copyMaterial3D.uniforms.w.value=(E+.5)/I,this.renderer.render(this.copyScene,this.copyCamera);this.copyQuad.material=this.copyMaterial2D,this.renderer.setRenderTarget(C),this.renderer.autoClear=Q}setSplatsSizeMultiplier(A){this.material.uniforms.sizeMultiplier.value=A}setSplatsCropRadius(A){this.material.uniforms.cropRadius.value=A}sort(A,g){this.worker&&(A?this.cameraPosition&&A.equals(this.cameraPosition)||(this.cameraPosition.copy(A),g?(this.viewProjModel||(this.viewProjModel=new d.Matrix4),this.viewProjModel.copy(g),this.viewProjModel.multiply(zt)):this.viewProjModel=void 0,this.worker.postMessage({method:"sort",xyz:[this.cameraPosition.x,this.cameraPosition.z,-this.cameraPosition.y],vpm:this.viewProjModel&&this.splatsCPUCuling?this.viewProjModel.toArray():void 0,id:this.sortID++})):this.worker.postMessage({method:"sort",xyz:[this.cameraPosition.x,this.cameraPosition.z,-this.cameraPosition.y],vpm:this.viewProjModel&&this.splatsCPUCuling?this.viewProjModel.toArray():void 0,id:this.sortID++}))}raycast(A,g){}addSplatsTile(A,g,I,Q){if(!this.worker)return;const C=this,E=A.data?A.data.array:A.array,a=A.data&&A.data.isInterleavedBuffer?A.data.stride:3,i=A.data&&A.data.isInterleavedBuffer?A.offset:0,t=Math.ceil(E.length/(this.batchSize*a)),e=[],o=[];let r=()=>{};const n=new Float32Array(E.length/a*3),s=new Uint32Array(n.buffer,n.byteOffset,n.length);for(let D=0;D<E.length/3;D++)n[3*D]=E[D*a+i],n[3*D+1]=E[D*a+i+1],n[3*D+2]=E[D*a+i+2];r=(D,b,h)=>{const w=h*h,f=Math.pow(C.material.uniforms.cropRadius.value,2),p=new d.Matrix3,R=new d.Vector3,U=new d.Vector3,G=new d.Vector3,k=new d.Vector3,J=n.length/3;for(let m=0;m<J;m++){if(R.set(n[3*m],-n[3*m+2],n[3*m+1]),R.lengthSq()>f||D.distanceSqToPoint(R)>w)continue;Xt(I,Q,m,p);const O=U.copy(R).sub(D.origin).dot(D.direction);if(O<0)continue;k.copy(D.direction).multiplyScalar(O).add(D.origin);const X=U.copy(k).sub(R);Zt(p,X,G);const IA=X.dot(G),AA=g.getW(m)*Math.exp(-.5*IA);AA>.01&&b.push({distance:O,point:k.clone(),opacity:AA,type:"splat",object:this})}},t>this.freeAddresses.size&&this.growTextures();for(let D=0;D<t;D++){const b=this.freeAddresses.poll();isNaN(b)&&console.log("insuficient texture size to store splats info"),e.push(b),o.push(3*b);const h=D*this.batchSize;this.addSplatsBatch(h,b,s,g,I,Q)}C.worker.postMessage({method:"addBatches",insertionIndexes:o,positions:E.buffer,offset:i,stride:a,batchSize:C.batchSize},[E.buffer]);let c=!1;return{hide:()=>{c==1&&C.worker&&(C.numVisibleBatches--,c=!1,C.worker.postMessage({method:"hideBatches",insertionIndexes:o,xyz:[C.cameraPosition.x,C.cameraPosition.z,-C.cameraPosition.y],vpm:this.viewProjModel&&this.splatsCPUCuling?this.viewProjModel.toArray():void 0,id:C.sortID++}))},show:D=>{if(c==0&&C.worker){C.numVisibleBatches--,c=!0;const b=C.sortID,h=w=>w>=b&&(D(),!0);C.sortListeners.push(h),C.worker.postMessage({method:"showBatches",insertionIndexes:o,xyz:[C.cameraPosition.x,C.cameraPosition.z,-C.cameraPosition.y],vpm:this.viewProjModel&&this.splatsCPUCuling?this.viewProjModel.toArray():void 0,id:C.sortID++})}},remove:()=>{C.worker&&(r=void 0,C.worker.postMessage({method:"removeBatches",insertionIndexes:o,xyz:[C.cameraPosition.x,C.cameraPosition.z,-C.cameraPosition.y],vpm:this.viewProjModel&&this.splatsCPUCuling?this.viewProjModel.toArray():void 0,id:C.sortID++}),e.forEach(D=>C.freeAddresses.add(D)))},sort:this.sort,raycast:r,isSplatsBatch:!0}}addSplatsBatch(A,g,I,Q,C,E){const a=new Uint32Array(4*this.batchSize),i=new Uint32Array(4*this.batchSize);for(let s=g;s<g+this.batchSize;s++){const c=s-g,D=4*c,b=A+c,h=3*(A+c);if(b>=I.count)break;a[D]=I[h],a[D+1]=I[h+1],a[D+2]=I[h+2];const w=0|Math.floor(255*Q.getX(b)+.5),f=0|Math.floor(255*Q.getY(b)+.5),p=0|Math.floor(255*Q.getZ(b)+.5),R=0|Math.floor(255*Q.getW(b)+.5);a[D+3]=w|f<<8|p<<16|R<<24,i[D]=eQ(C.getX(b),C.getY(b)),i[D+1]=eQ(C.getZ(b),E.getX(b)),i[D+2]=eQ(E.getY(b),E.getZ(b))}const t=Math.floor(g/Math.pow(this.textureSize,2)),e=Math.ceil(this.batchSize/this.textureSize),o=[0,g/this.textureSize-t*this.textureSize,this.textureSize];o.push(o[1]+e);const r=new d.DataTexture(a,this.textureSize,e,d.RGBAIntegerFormat,d.UnsignedIntType);r.internalFormat="RGBA32UI",r.generateMipmaps=!1,r.magFilter=d.NearestFilter,r.minFilter=d.NearestFilter,r.anisotropy=0,r.needsUpdate=!0,this.renderer.initTexture(r),this.copyTex2D(r,this.positionColorRenderTarget,o,t),r.dispose();const n=new d.DataTexture(i,this.textureSize,e,d.RGBAIntegerFormat,d.UnsignedIntType);n.internalFormat="RGBA32UI",n.generateMipmaps=!1,n.magFilter=d.NearestFilter,n.minFilter=d.NearestFilter,n.anisotropy=0,n.needsUpdate=!0,this.renderer.initTexture(n),this.copyTex2D(n,this.covarianceRenderTarget,o,t),n.dispose()}growTextures(){for(let Q=this.maxSplats;Q<this.maxSplats+this.textureSize*this.textureSize;Q+=this.batchSize)this.freeAddresses.add(Q);this.maxSplats+=this.textureSize*this.textureSize;const A=this.numTextures+1,g=new d.WebGL3DRenderTarget(this.textureSize,this.textureSize,A,{magFilter:d.NearestFilter,minFilter:d.NearestFilter,type:d.UnsignedIntType,format:d.RGBAIntegerFormat,anisotropy:0,depthBuffer:!1,resolveDepthBuffer:!1});g.texture.type=d.UnsignedIntType,g.texture.internalFormat="RGBA32UI",g.texture.format=d.RGBAIntegerFormat,this.renderer.initRenderTarget(g),this.copyTex3D(this.positionColorRenderTarget.texture,g,this.numTextures),this.positionColorRenderTarget.dispose(),this.positionColorRenderTarget=g,this.material.uniforms.positionColorTexture.value=this.positionColorRenderTarget.texture;const I=new d.WebGL3DRenderTarget(this.textureSize,this.textureSize,A,{magFilter:d.NearestFilter,minFilter:d.NearestFilter,anisotropy:0,type:d.UnsignedIntType,format:d.RGBAIntegerFormat,depthBuffer:!1,resolveDepthBuffer:!1});I.texture.type=d.UnsignedIntType,I.texture.internalFormat="RGBA32UI",I.texture.format=d.RGBAIntegerFormat,this.renderer.initRenderTarget(I),this.copyTex3D(this.covarianceRenderTarget.texture,I,this.numTextures),this.covarianceRenderTarget.dispose(),this.covarianceRenderTarget=I,this.material.uniforms.covarianceTexture.value=this.covarianceRenderTarget.texture,this.numTextures=A,this.material.uniforms.numSlices.value=this.numTextures}}function Fa(){return`
|
|
1153
1153
|
precision highp float;
|
|
1154
1154
|
precision highp int;
|
|
1155
1155
|
precision highp usampler3D;
|
|
@@ -1180,6 +1180,7 @@ uniform float minOpacity;
|
|
|
1180
1180
|
uniform bool culling;
|
|
1181
1181
|
uniform float antialiasingFactor;
|
|
1182
1182
|
uniform float cropRadius;
|
|
1183
|
+
uniform float depthBias; // depth bias in meters
|
|
1183
1184
|
|
|
1184
1185
|
|
|
1185
1186
|
void getVertexData(out vec3 position, out mat3 covariance) {
|
|
@@ -1315,7 +1316,10 @@ void main() {
|
|
|
1315
1316
|
|
|
1316
1317
|
|
|
1317
1318
|
splatPositionWorld = (modelMatrix * vec4(splatPositionModel, 1.0)).xyz;
|
|
1318
|
-
vec4
|
|
1319
|
+
vec4 splatProjectionView = viewMatrix * vec4(splatPositionWorld, 1.0);
|
|
1320
|
+
vec4 splatPositionProjected = projectionMatrix * splatProjectionView;
|
|
1321
|
+
splatProjectionView.z += depthBias;
|
|
1322
|
+
vec4 splatPositionProjectedWithBias = projectionMatrix * splatProjectionView;
|
|
1319
1323
|
|
|
1320
1324
|
if(culling){
|
|
1321
1325
|
float clip = 1.2 * splatPositionProjected.w;
|
|
@@ -1340,9 +1344,9 @@ void main() {
|
|
|
1340
1344
|
|
|
1341
1345
|
#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
1342
1346
|
float isPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
1343
|
-
splatDepth = isPerspective == 0.0 ?
|
|
1347
|
+
splatDepth = isPerspective == 0.0 ? splatPositionProjectedWithBias.z : log2( 1.0 + splatPositionProjectedWithBias.w ) * logDepthBufFC * 0.5;
|
|
1344
1348
|
#else
|
|
1345
|
-
splatDepth = (
|
|
1349
|
+
splatDepth = (splatPositionProjectedWithBias.z / splatPositionProjectedWithBias.w)* 0.5 + 0.5;
|
|
1346
1350
|
#endif
|
|
1347
1351
|
|
|
1348
1352
|
|
|
@@ -1386,5 +1390,5 @@ out vec2 vUv;
|
|
|
1386
1390
|
void main() {
|
|
1387
1391
|
vUv = uv;
|
|
1388
1392
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
1389
|
-
}`}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 Og=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:Zg.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)}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],Og),g._transformWGS84ToCartesian(Q[2],Q[3],Q[5],lI),Og.lerp(lI,.5),g.boundingVolume=new V.Sphere(new V.Vector3(Og.x,Og.y,Og.z),Og.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]),Og),TC.setFromUnitVectors(Og.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)):Zg.isAbsolute(I.rootPath)&&(t=I.rootPath+Zg.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=Zg.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(){if(this.metric!=null)if(this.hasMeshContent&&this.shouldBeVisible&&this.materialVisibility){if(self.splatsMesh&&!self.splatsReady)return;this._disposeChildren()}else this.childrenTiles.forEach(A=>{A._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&&this.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),Wg=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=Zg.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],Wg),g.transformWGS84ToCartesian(C[2],C[3],C[5],tQ),Wg.lerp(tQ,.5),g.boundingVolume=new V.Sphere(new V.Vector3(Wg.x,Wg.y,Wg.z),Wg.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]),Wg),WC.setFromUnitVectors(Wg.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)):Zg.isAbsolute(A.rootPath)&&(Q=A.rootPath+Zg.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=Zg.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;
|
|
1393
|
+
}`}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 Og=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:Zg.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],Og),g._transformWGS84ToCartesian(Q[2],Q[3],Q[5],lI),Og.lerp(lI,.5),g.boundingVolume=new V.Sphere(new V.Vector3(Og.x,Og.y,Og.z),Og.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]),Og),TC.setFromUnitVectors(Og.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)):Zg.isAbsolute(I.rootPath)&&(t=I.rootPath+Zg.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=Zg.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(){if(this.metric!=null)if(this.hasMeshContent&&this.shouldBeVisible&&this.materialVisibility){if(self.splatsMesh&&!self.splatsReady)return;this._disposeChildren()}else this.childrenTiles.forEach(A=>{A._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&&this.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),Wg=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=Zg.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],Wg),g.transformWGS84ToCartesian(C[2],C[3],C[5],tQ),Wg.lerp(tQ,.5),g.boundingVolume=new V.Sphere(new V.Vector3(Wg.x,Wg.y,Wg.z),Wg.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]),Wg),WC.setFromUnitVectors(Wg.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)):Zg.isAbsolute(A.rootPath)&&(Q=A.rootPath+Zg.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=Zg.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;
|
|
1390
1394
|
//# sourceMappingURL=threedtiles.cjs.js.map
|