minecraft-renderer 0.1.24 → 0.1.25
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/minecraft-renderer.js +2 -2
- package/dist/threeWorker.js +2 -2
- package/package.json +1 -1
- package/src/three/cameraShake.ts +1 -1
- package/src/three/modules/rain.ts +5 -5
- package/src/three/modules/sciFiWorldReveal.ts +2 -2
- package/src/three/modules/starfield.ts +1 -1
- package/src/three/rendererModuleSystem.ts +1 -1
- package/src/three/worldRendererThree.ts +7 -2
|
@@ -21767,7 +21767,7 @@ void main() {
|
|
|
21767
21767
|
vec4 texColor = texture2D(texture, gl_PointCoord);
|
|
21768
21768
|
gl_FragColor = vColor * texColor;
|
|
21769
21769
|
}
|
|
21770
|
-
`,$e={textureSize:128,gravity:new ce.Vector3(0,-.005,0),friction:.998,defaultParticleSize:300,maxActiveFireworks:5},dl=l=>{let t=l*3;return{x:t,y:t+1,z:t+2}},pl=l=>{let t=l*4;return{r:t,g:t+1,b:t+2,a:t+3}},Fo=(l=0,e=0)=>Math.floor(Math.random()*(l+1-e))+e,$h=(l,e,t,o)=>{l.save();let r=l.createRadialGradient(e,e,0,e,e,e);r.addColorStop(0,"rgba(255,255,255,1.0)"),r.addColorStop(.5,"rgba(255,255,255,0.5)"),r.addColorStop(1,"rgba(255,255,255,0)"),l.fillStyle=r,l.fillRect(0,0,t,o),l.restore()},Zh=()=>{let l=$e.textureSize,e=Fe(l,l),t=e.getContext("2d"),o=l/2;$h(t,o,e.width,e.height);let r=new ce.Texture(e);return r.needsUpdate=!0,r},Kh=(l,e,t,o,r=$e.defaultParticleSize)=>{let a=new ce.BufferGeometry,s=[],n=[],i=[],c=[],_=[],u=Math.random()>.3?"single":"multiple",b=Fo(100,20)*.01,h=()=>Fo(100,1)*.01,k="red",f=Math.random();f>.66?k="red":f>.33?k="green":k="blue";for(let v=0;v<l;v++){let x=new ce.Vector3(0,0,0);if(s.push(x.x,x.y,x.z),n.push(e[v].x,e[v].y,e[v].z),t==="seed"){let R=e[v].y**2*.04;v===0&&(R*=1.1),c.push(R),_.push(R*.017),i.push(1,1,1,1)}else if(t==="trail"){let R=Math.random()*.1+.1;c.push(R),_.push(R*.017),i.push(1,1,1,1)}else{let R=Fo(r,10)*.001;if(c.push(R),_.push(R*.017),u==="multiple")i.push(h(),h(),h(),1);else switch(k){case"red":i.push(b,.1,.1,1);break;case"green":i.push(.1,b,.1,1);break;case"blue":i.push(.1,.1,b,1);break}}}a.setAttribute("position",new ce.Float32BufferAttribute(s,3)),a.setAttribute("velocity",new ce.Float32BufferAttribute(n,3)),a.setAttribute("color",new ce.Float32BufferAttribute(i,4)),a.setAttribute("adjustSize",new ce.Float32BufferAttribute(c,1)),a.setAttribute("mass",new ce.Float32BufferAttribute(_,1));let y=new ce.RawShaderMaterial({uniforms:{size:{value:$e.textureSize},texture:{value:o}},transparent:!0,depthWrite:!1,blending:ce.AdditiveBlending,vertexShader:Vh,fragmentShader:Yh});return new ce.Points(a,y)},ml=class{constructor(e,t,o,r,a){p(this,"particleNum");p(this,"timerStartFading");p(this,"mesh");this.particleNum=e,this.timerStartFading=10,this.mesh=Kh(e,t,o,r,a)}update(e){this.timerStartFading>0&&(this.timerStartFading-=.3);let t=this.mesh.geometry.attributes.position,o=this.mesh.geometry.attributes.velocity,r=this.mesh.geometry.attributes.color,a=this.mesh.geometry.attributes.mass,s=()=>Math.random()>.5?.98:.96,n=i=>Math.random()>.5?0:(1-i)*.1;for(let i=0;i<this.particleNum;i++){let{x:c,y:_,z:u}=dl(i);o.array[_]+=e.y-a.array[i],o.array[c]*=$e.friction,o.array[u]*=$e.friction,o.array[_]*=$e.friction,t.array[c]+=o.array[c],t.array[_]+=o.array[_],t.array[u]+=o.array[u];let{a:b}=pl(i);this.timerStartFading<=0&&(r.array[b]*=s()-n(r.array[b]),r.array[b]<.001&&(r.array[b]=0))}t.needsUpdate=!0,o.needsUpdate=!0,r.needsUpdate=!0}disposeAll(){this.mesh.geometry.dispose(),this.mesh.material.dispose()}},rn=class extends ml{constructor(e,t,o){super(e,t,"seed",o)}update(e){let t=this.mesh.geometry.attributes.position,o=this.mesh.geometry.attributes.velocity,r=this.mesh.geometry.attributes.color,a=this.mesh.geometry.attributes.mass,s=()=>Math.random()>.3?.99:.96,n=u=>Math.random()>.3?0:(1-u)*.1,i=()=>Math.random()>.5?.05:-.05,c=()=>Math.random()>.1,_=$e.friction*.98;for(let u=0;u<this.particleNum;u++){let{x:b,y:h,z:k}=dl(u);o.array[h]+=e.y-a.array[u],o.array[b]*=_,o.array[k]*=_,o.array[h]*=_,t.array[b]+=o.array[b],t.array[h]+=o.array[h],t.array[k]+=o.array[k],c()&&(t.array[b]+=i()),c()&&(t.array[k]+=i());let{a:f}=pl(u);r.array[f]*=s()-n(r.array[f]),r.array[f]<.001&&(r.array[f]=0)}t.needsUpdate=!0,o.needsUpdate=!0,r.needsUpdate=!0}},ln=class extends ml{constructor(e,t,o){super(e,t,"trail",o)}update(e){let t=this.mesh.geometry.attributes.position,o=this.mesh.geometry.attributes.velocity,r=this.mesh.geometry.attributes.color,a=this.mesh.geometry.attributes.mass,s=()=>Math.random()>.3?.98:.95,n=()=>Math.random()>.5?.05:-.05,i=()=>Math.random()>.2;for(let c=0;c<this.particleNum;c++){let{x:_,y:u,z:b}=dl(c);o.array[u]+=e.y-a.array[c],o.array[_]*=$e.friction,o.array[b]*=$e.friction,o.array[u]*=$e.friction,t.array[_]+=o.array[_],t.array[u]+=o.array[u],t.array[b]+=o.array[b],i()&&(t.array[_]+=n()),i()&&(t.array[b]+=n());let{a:h}=pl(c);r.array[h]*=s(),r.array[h]<.001&&(r.array[h]=0)}t.needsUpdate=!0,o.needsUpdate=!0,r.needsUpdate=!0}},bl=class{constructor(e,t=$e.defaultParticleSize,o){p(this,"meshGroup");p(this,"isExplode");p(this,"petalsNum");p(this,"life");p(this,"seed");p(this,"flowerSizeRate");p(this,"flower");p(this,"texture");p(this,"particleSize");this.meshGroup=new ce.Group,this.isExplode=!1,this.texture=e,this.particleSize=t;let r=400,a=150;this.petalsNum=Fo(r,a),this.life=150,this.seed=this.getSeed(o),this.meshGroup.add(this.seed.mesh),this.flowerSizeRate=ce.MathUtils.mapLinear(this.petalsNum,a,r,.4,.7)}getSeed(e){let o=[];for(let a=0;a<40;a++){let n=a===0?Math.random()*2.5+.9:Math.random()*2+.4,i=0;o.push(new ce.Vector3(0,n,i))}let r=new rn(40,o,this.texture);if(e)r.mesh.position.set(e.x,e.y,e.z);else{let a=Math.random()*80-40,s=-50,n=Math.random()*80-40;r.mesh.position.set(a,s,n)}return r}explode(e){this.isExplode=!0,this.flower=this.getFlower(e),this.meshGroup.add(this.flower.mesh),this.meshGroup.remove(this.seed.mesh),this.seed.disposeAll()}getFlower(e){let t=this.petalsNum,o=[],r;if(Math.random()>.5)for(let n=0;n<t;n++){r=Fo(120,60)*.01;let i=ce.MathUtils.degToRad(Math.random()*180),c=ce.MathUtils.degToRad(Math.random()*360),_=Math.sin(i)*Math.cos(c)*r,u=Math.sin(i)*Math.sin(c)*r,b=Math.cos(i)*r,h=new ce.Vector3(_,u,b);h.multiplyScalar(this.flowerSizeRate),o.push(h)}else{let n=180/t,i=360*(Math.random()*20+1)/t,c=i,_=i;r=Fo(120,60)*.01;for(let u=0;u<t;u++){let b=Math.sin(ce.MathUtils.degToRad(n*u)),h=Math.cos(ce.MathUtils.degToRad(n*u))*r,k=Math.cos(ce.MathUtils.degToRad(c*u))*b*r,f=Math.sin(ce.MathUtils.degToRad(_*u))*b*r,y=new ce.Vector3(k,f,h);y.multiplyScalar(this.flowerSizeRate),o.push(y)}}let s=new ml(t,o,"default",this.texture,this.particleSize);return s.mesh.position.set(e.x,e.y,e.z),s}update(e){this.isExplode?(this.flower.update(e),this.life>0&&(this.life-=1)):this.drawTail()}drawTail(){this.seed.update($e.gravity);let e=this.seed.mesh.geometry.attributes.position,t=this.seed.mesh.geometry.attributes.velocity,o=0;for(let u=0,b=t.array.length;u<b;u++){let h=t.array[u];u%3===1&&h>0&&o++}if(!(o===0))return;let{x:a,y:s,z:n}=this.seed.mesh.position,i=new ce.Vector3(a,s,n),c=0,_;for(let u=0,b=e.array.length;u<b;u++){let h=e.array[u];u%3===1&&h>c&&(c=h,_=new ce.Vector3(e.array[u-1],h,e.array[u+2]))}_&&(i.add(_),this.explode(i))}},Rr=class extends bl{constructor(t,o=$e.defaultParticleSize,r){super(t,o,r);p(this,"tailMeshGroup");p(this,"tails");let a=150,s=100;this.petalsNum=Fo(a,s),this.flowerSizeRate=ce.MathUtils.mapLinear(this.petalsNum,s,a,.4,.7),this.tailMeshGroup=new ce.Group,this.tails=[]}explode(t){this.isExplode=!0,this.flower=this.getFlower(t),this.tails=this.getTail(),this.meshGroup.add(this.flower.mesh),this.meshGroup.add(this.tailMeshGroup)}getTail(){let t=[],r=this.flower.mesh.geometry.attributes.color;for(let a=0;a<this.petalsNum;a++){let s=[];for(let O=0;O<20;O++)s.push(new ce.Vector3(0,0,0));let n=new ln(20,s,this.texture),{r:i,g:c,b:_,a:u}=pl(a),b=r.array[i],h=r.array[c],k=r.array[_],f=r.array[u],y=n.mesh.geometry.attributes.position,v=n.mesh.geometry.attributes.color;for(let O=0;O<y.count;O++){let T=pl(O);v.array[T.r]=b,v.array[T.g]=h,v.array[T.b]=k,v.array[T.a]=f}let{x,y:R,z:M}=this.flower.mesh.position;n.mesh.position.set(x,R,M),t.push(n),this.tailMeshGroup.add(n.mesh)}return t}update(t){if(this.isExplode){this.flower.update(t);let o=this.flower.mesh.geometry.attributes.position;for(let r=0,a=this.tails.length;r<a;r++){let s=this.tails[r];s.update(t);let{x:n,y:i,z:c}=dl(r),_=new ce.Vector3(o.array[n],o.array[i],o.array[c]),u=s.mesh.geometry.attributes.position,b=s.mesh.geometry.attributes.velocity;for(let h=0;h<u.count;h++){let k=dl(h),f=new ce.Vector3,y=new ce.Vector3(u.array[k.x],u.array[k.y],u.array[k.z]),v=new ce.Vector3(b.array[k.x],b.array[k.y],b.array[k.z]);f.subVectors(_,y);let x=f.sub(v);x.normalize(),x.multiplyScalar(Math.random()*3e-4*this.life),b.array[k.x]+=x.x,b.array[k.y]+=x.y,b.array[k.z]+=x.z}b.needsUpdate=!0}this.life>0&&(this.life-=1.2)}else this.drawTail()}},Ia=class{constructor(e,t){p(this,"fireworksInstances");p(this,"scene");p(this,"texture");p(this,"particleSize");p(this,"maxFireworks");this.fireworksInstances=[],this.scene=e,this.texture=Zh(),this.particleSize=t?.defaultParticleSize??$e.defaultParticleSize,this.maxFireworks=t?.maxActiveFireworks??$e.maxActiveFireworks}launchFirework(e){if(this.fireworksInstances.length>=this.maxFireworks)return;let t=e?.particleSize??this.particleSize,o=e?.position,r;e?.forceRich?r=new Rr(this.texture,t,o):e?.forceBasic?r=new bl(this.texture,t,o):r=Math.random()>.5?new bl(this.texture,t,o):new Rr(this.texture,t,o),this.fireworksInstances.push(r),this.scene.add(r.meshGroup)}update(){let e=[];for(let t=this.fireworksInstances.length-1;t>=0;t--){let o=this.fireworksInstances[t];o.update($e.gravity),o.isExplode&&e.push(t)}for(let t=0,o=e.length;t<o;t++){let r=e[t],a=this.fireworksInstances[r];if(a&&(a.meshGroup.remove(a.seed.mesh),a.seed.disposeAll(),a.life<=0)){if(this.scene.remove(a.meshGroup),a instanceof Rr&&a.tailMeshGroup)for(let s of a.tails)s.disposeAll();a.flower?.disposeAll(),this.fireworksInstances.splice(r,1)}}}clear(){for(let e of this.fireworksInstances)if(this.scene.remove(e.meshGroup),e.seed.disposeAll(),e.flower&&e.flower.disposeAll(),e instanceof Rr)for(let t of e.tails)t.disposeAll();this.fireworksInstances=[]}dispose(){this.clear(),this.texture.dispose()}};sn();I();A();E();z();import*as Te from"three";import{Vec3 as hl}from"vec3";import _n from"prismarine-nbt";I();A();E();z();import*as Xe from"three";var nn=20,cn=40,ek={white_banner:15,orange_banner:14,magenta_banner:13,light_blue_banner:12,yellow_banner:11,lime_banner:10,pink_banner:9,gray_banner:8,light_gray_banner:7,cyan_banner:6,purple_banner:5,blue_banner:4,brown_banner:3,green_banner:2,red_banner:1,black_banner:0},Aa={0:"#1d1d21",1:"#b02e26",2:"#5e7c16",3:"#835432",4:"#3c44aa",5:"#8932b8",6:"#169c9c",7:"#9d9d97",8:"#474f52",9:"#f38baa",10:"#80c71f",11:"#fed83d",12:"#3ab3da",13:"#c74ebd",14:"#f9801d",15:"#f9fffe"};function tk(l){let e=l.replace("_wall_banner","_banner");return ek[e]??15}var ok=(l,e,t,o,r,a,s)=>{switch(l.fillStyle=t,e){case"bs":l.fillRect(o,r,a,s);break;case"ls":l.fillRect(o,r,a/3,s);break;case"rs":l.fillRect(o+a*2/3,r,a/3,s);break;case"ts":l.fillRect(o,r,a,s/3);break;case"ms":l.fillRect(o,r+s/3,a,s/3);break;case"drs":l.fillRect(o,r,a/2,s/2);break;case"dls":l.fillRect(o+a/2,r,a/2,s/2);break;case"ss":for(let n=0;n<a;n+=2)l.fillRect(o+n,r,1,s);break;case"cr":l.fillRect(o,r+s/3,a,s/3),l.fillRect(o+a/3,r,a/3,s);break;case"sc":l.fillRect(o,r+s/2-1,a,2),l.fillRect(o+a/2-1,r,2,s);break;default:l.fillRect(o,r,a,s)}};function rk(l,e){if(!e||e.length===0)return`banner_${l}_empty`;let t=e.map(o=>`${o.Pattern??"bs"}_${o.Color??0}`).join(",");return`banner_${l}_${t}`}var lk=(l,e,t=(o,r)=>Fe(o,r))=>{let r=t(nn*1,cn*1),a=r.getContext("2d");if(!a)return;a.imageSmoothingEnabled=!1;let s=Aa[l]||Aa[15];if(a.fillStyle=s,a.fillRect(0,0,nn*1,cn*1),e?.Patterns&&e.Patterns.length>0)for(let n of e.Patterns){let i=n.Color??0,c=n.Pattern??"bs",_=Aa[i]||Aa[0];ok(a,c,_,0,0,nn*1,cn*1)}return r},za=new Map;function Vu(l,e,t){let o=tk(e),r=rk(o,t?.Patterns),a=za.get(r);if(a)return a.refCount++,a.texture;let s=lk(o,t);if(!s)return;let n=new Xe.Texture(s);return n.magFilter=Xe.NearestFilter,n.minFilter=Xe.NearestFilter,n.needsUpdate=!0,za.set(r,{texture:n,refCount:1}),n}function Ea(l){for(let[e,t]of za.entries())if(t.texture===l){t.refCount--,t.refCount<=0&&(t.texture.dispose(),za.delete(e));return}}function Yu(l,e,t,o){let n,i,c;t?(n=(-14.6+13.4)/2/16-.5,i=1-14.75/16-.5,c=1/2):(n=(1.4+29.4)/2/16,i=1-7.25/16-.5,c=0);let _=new Xe.Mesh(new Xe.PlaneGeometry(.85,1.75),new Xe.MeshBasicMaterial({map:o,transparent:!0}));_.renderOrder=999;let u=.5/16,b=.25/16;t?_.position.set(0,n,i+b+.004):_.position.set(0,n,i+u/2+.004);let h=new Xe.Group;return h.rotation.set(0,-Xe.MathUtils.degToRad(e*(t?90:45/2)),0),h.add(_),h.bannerTexture=o,h.position.set(l.x+.5,l.y+c,l.z+.5),h}var Ma=class{constructor(e,t,o,r){this.worldRenderer=e;this.scene=t;this.material=o;this.displayOptions=r;p(this,"sectionObjects",{});p(this,"waitingChunksToDisplay",{});p(this,"estimatedMemoryUsage",0)}handleWorkerGeometryMessage(e){var f;let t=this.sectionObjects[e.key];t&&(this.removeSectionMemoryUsage(t),t.traverse(y=>{y.bannerTexture&&Ea(y.bannerTexture)}),this.scene.remove(t),nt(t),delete this.sectionObjects[e.key]);let o=e.key.split(",");if(!this.worldRenderer.loadedChunks[o[0]+","+o[2]]||!e.geometry.positions.length||!this.worldRenderer.active)return;let r=new Te.BufferGeometry,a=new Te.BufferAttribute(e.geometry.positions,3),s=new Te.BufferAttribute(e.geometry.normals,3),n=new Te.BufferAttribute(e.geometry.colors,3),i=new Te.BufferAttribute(e.geometry.uvs,2),c=new Te.BufferAttribute(e.geometry.indices,1);r.setAttribute("position",a),r.setAttribute("normal",s),r.setAttribute("color",n),r.setAttribute("uv",i),r.index=c,this.addSectionMemoryUsage(r);let _=new Te.Mesh(r,this.material);_.position.set(e.geometry.sx,e.geometry.sy,e.geometry.sz),_.name="mesh",t=new Te.Group,t.add(_);let u=e.geometry.sectionEndY-e.geometry.sectionStartY,b=16,h=new Te.Mesh(new Te.BoxGeometry(b,u,b),new Te.MeshBasicMaterial({color:0,transparent:!0,opacity:0}));h.position.set(e.geometry.sx,e.geometry.sy,e.geometry.sz);let k=new Te.BoxHelper(h,16776960);if(k.name="helper",t.add(k),t.name="chunk",t.tilesCount=e.geometry.positions.length/3/4,t.blocksCount=e.geometry.blocksCount,this.displayOptions.inWorldRenderingConfig.showChunkBorders||(k.visible=!1),Object.keys(e.geometry.signs).length)for(let[y,{isWall:v,isHanging:x,rotation:R}]of Object.entries(e.geometry.signs)){let M=this.worldRenderer.blockEntities[y];if(!M)continue;let[O,T,S]=y.split(","),P=this.worldRenderer.renderSign(new hl(+O,+T,+S),R,v,x,_n.simplify(M));P&&t.add(P)}if(Object.keys(e.geometry.heads).length)for(let[y,{isWall:v,rotation:x}]of Object.entries(e.geometry.heads)){let R=this.worldRenderer.blockEntities[y];if(!R)continue;let[M,O,T]=y.split(","),S=this.worldRenderer.renderHead(new hl(+M,+O,+T),x,v,_n.simplify(R));S&&t.add(S)}if(Object.keys(e.geometry.banners).length)for(let[y,{isWall:v,rotation:x,blockName:R}]of Object.entries(e.geometry.banners)){let M=this.worldRenderer.blockEntities[y];if(!M)continue;let[O,T,S]=y.split(","),P=Vu(this.worldRenderer,R,_n.simplify(M));if(!P)continue;let L=Yu(new hl(+O,+T,+S),x,v,P);t.add(L)}if(this.sectionObjects[e.key]=t,this.displayOptions.inWorldRenderingConfig._renderByChunks){t.visible=!1;let y=`${o[0]},${o[2]}`;(f=this.waitingChunksToDisplay)[y]??(f[y]=[]),this.waitingChunksToDisplay[y].push(e.key),this.worldRenderer.finishedChunks[y]&&this.finishChunk(y)}this.worldRenderer.updatePosDataChunk(e.key),t.matrixAutoUpdate=!1,_.onAfterRender=(y,v,x,R,M,O)=>{},this.scene.add(t)}finishChunk(e){for(let t of this.waitingChunksToDisplay[e]??[])this.sectionObjects[t].visible=!0;delete this.waitingChunksToDisplay[e]}estimateGeometryMemoryUsage(e){let t=0,{attributes:o}=e;for(let[r,a]of Object.entries(o))if(a?.array){let s=a.array.BYTES_PER_ELEMENT;t+=a.array.length*s}if(e.index?.array){let r=e.index.array.BYTES_PER_ELEMENT;t+=e.index.array.length*r}return t}addSectionMemoryUsage(e){let t=this.estimateGeometryMemoryUsage(e);this.estimatedMemoryUsage+=t}removeSectionMemoryUsage(e){let t=e.children.find(o=>o.name==="mesh");if(t?.geometry){let o=this.estimateGeometryMemoryUsage(t.geometry);this.estimatedMemoryUsage-=o,this.estimatedMemoryUsage=Math.max(0,this.estimatedMemoryUsage)}}getEstimatedMemoryUsage(){let e=this.estimatedMemoryUsage,o=`${(e/(1024*1024)).toFixed(2)} MB`;return{bytes:e,readable:o}}resetWorld(){for(let e of Object.values(this.sectionObjects))this.removeSectionMemoryUsage(e),this.scene.remove(e);this.sectionObjects={},this.waitingChunksToDisplay={},this.estimatedMemoryUsage=0}removeColumn(e,t){let o=this.worldRenderer.getSectionHeight(),r=this.worldRenderer.worldMinYRender;if(Ho){let a=r;this.worldRenderer.setSectionDirty(new hl(e,a,t),!1);let s=`${e},${a},${t}`,n=this.sectionObjects[s];n&&(this.removeSectionMemoryUsage(n),n.traverse(i=>{i.bannerTexture&&Ea(i.bannerTexture)}),this.scene.remove(n),nt(n)),delete this.sectionObjects[s]}else for(let a=r;a<this.worldRenderer.worldSizeParams.worldHeight;a+=o){this.worldRenderer.setSectionDirty(new hl(e,a,t),!1);let s=`${e},${a},${t}`,n=this.sectionObjects[s];n&&(this.removeSectionMemoryUsage(n),n.traverse(i=>{i.bannerTexture&&Ea(i.bannerTexture)}),this.scene.remove(n),nt(n)),delete this.sectionObjects[s]}}};I();A();E();z();I();A();E();z();import*as Ze from"three";var un=2e3,$u=32,Zu=32,Ra=.2,Ku=.4,Oa=.02,ak=-5,dn=class{constructor(e){this.worldRenderer=e;p(this,"instancedMesh");p(this,"geometry");p(this,"material");p(this,"particles",[]);p(this,"enabled",!1);p(this,"dummy",new Ze.Matrix4);p(this,"tempPosition",new Ze.Vector3);p(this,"tempQuaternion",new Ze.Quaternion);p(this,"tempScale",new Ze.Vector3);p(this,"render",()=>{if(!this.enabled||!this.instancedMesh)return;let e=this.worldRenderer.getCameraPosition();this.instancedMesh.position.copy(e);let t=this.worldRenderer.reactiveState.world.heightmaps,{dummy:o,tempPosition:r,tempQuaternion:a,tempScale:s}=this,n=NaN,i=NaN,c;for(let _=0;_<un;_++){let u=this.particles[_];this.instancedMesh.getMatrixAt(_,o),o.decompose(r,a,s),r.add(u.velocity);let b=r.y,h=Math.sqrt(r.x*r.x+r.z*r.z),k=e.x+r.x,f=e.y+r.y,y=e.z+r.z,v=Math.floor(k/16),x=Math.floor(y/16);(v!==n||x!==i)&&(c=t.get(`${v},${x}`),n=v,i=x);let R=(Math.floor(k)%16+16)%16,M=(Math.floor(y)%16+16)%16,O=c?.[M*16+R];if(h>$u||O!==void 0&&O!==-32768&&f<=O+1+u.despawnOffset||b<ak){this.respawnParticle(r);let S=Ra+Math.random()*(Ku-Ra);u.velocity.set((Math.random()-.5)*Oa,-S,(Math.random()-.5)*Oa),u.despawnOffset=Math.random()*.5}o.compose(r,a,s),this.instancedMesh.setMatrixAt(_,o)}this.instancedMesh.instanceMatrix.needsUpdate=!0})}enable(){this.enabled||(this.enabled=!0,this.instancedMesh?this.instancedMesh.visible=!0:this.createRain())}disable(){this.enabled&&(this.enabled=!1,this.instancedMesh&&(this.instancedMesh.visible=!1))}autoEnableCheck(){return this.worldRenderer.worldRendererConfig.isRaining===!0}dispose(){this.instancedMesh&&this.worldRenderer.scene.remove(this.instancedMesh),this.geometry?.dispose(),this.material?.dispose(),this.instancedMesh=void 0,this.geometry=void 0,this.material=void 0,this.particles=[]}createRain(){this.geometry=new Ze.BoxGeometry(.03,.3,.03),this.material=new Ze.MeshBasicMaterial({color:4482713,transparent:!0,opacity:.6}),this.instancedMesh=new Ze.InstancedMesh(this.geometry,this.material,un),this.instancedMesh.name="rain-particles";let e=new Ze.Matrix4,t=new Ze.Vector3;for(let o=0;o<un;o++){this.respawnParticle(t),t.y=Math.random()*Zu,e.setPosition(t),this.instancedMesh.setMatrixAt(o,e);let r=Ra+Math.random()*(Ku-Ra);this.particles.push({velocity:new Ze.Vector3((Math.random()-.5)*Oa,-r,(Math.random()-.5)*Oa),age:0,despawnOffset:Math.random()*.5})}this.instancedMesh.instanceMatrix.needsUpdate=!0,this.worldRenderer.scene.add(this.instancedMesh)}respawnParticle(e){let t=Math.random()*Math.PI*2,o=Math.random()*$u;e.set(Math.cos(t)*o,Zu,Math.sin(t)*o)}},Ju={id:"rain",controller:dn,enabledDefault:!1,requiresHeightmap:!0};I();A();E();z();import*as Pe from"three";var Xu=new Pe.Color(13/255,234/255,238/255),sk=9;var nk=350,ik=650;var ck=120,_k=280,pn=class{constructor(e){this.worldRenderer=e;p(this,"pendingGeometries",new Map);p(this,"revealingSections",new Map);p(this,"finishedChunkCount",0);p(this,"revealTriggered",!1);p(this,"revealStartTime",0);p(this,"enabled",!1);p(this,"onWorldSwitchedCb",null);p(this,"patched",!1);p(this,"initialWaveDone",!1);p(this,"wireframeMaterial");p(this,"wireframeGlowMaterial");p(this,"pulseTime",0);p(this,"revealedChunks",new Set);p(this,"originalFinishChunk",null);p(this,"originalDestroy",null);p(this,"originalSceneAdd",null);p(this,"originalHandleWorkerMessage",null);p(this,"originalWbgHandle",null);p(this,"configEnabled",!0);p(this,"render",()=>{this.enabled&&this.update(16)});this.configEnabled=this.worldRenderer.worldRendererConfig.futuristicReveal===!0,this.wireframeMaterial=new Pe.LineBasicMaterial({color:Xu,transparent:!0,opacity:1,blending:Pe.AdditiveBlending,depthWrite:!1}),this.wireframeGlowMaterial=new Pe.LineBasicMaterial({color:Xu,transparent:!0,opacity:.55,blending:Pe.AdditiveBlending,depthWrite:!1})}enable(){this.configEnabled&&(this.enabled||(this.enabled=!0,this.patchWorldRenderer()))}disable(){this.enabled&&(this.enabled=!1,this.unpatchWorldRenderer(),this.reset())}toggle(){return this.enabled?this.disable():this.enable(),this.enabled}dispose(){this.disable(),this.wireframeMaterial.dispose(),this.wireframeGlowMaterial.dispose()}patchWorldRenderer(){if(this.patched)return;this.patched=!0;let e=this.worldRenderer;this.onWorldSwitchedCb=()=>this.reset(),e.onWorldSwitched.push(this.onWorldSwitchedCb),this.originalFinishChunk=e.finishChunk.bind(e),e.finishChunk=o=>{this.originalFinishChunk(o),this.onChunkFinished(o)},this.originalDestroy=e.destroy.bind(e),e.destroy=()=>{this.dispose(),this.originalDestroy()};let t=e.worldBlockGeometry;this.originalWbgHandle=t.handleWorkerGeometryMessage.bind(t),t.handleWorkerGeometryMessage=o=>{let r=this.originalWbgHandle(o);return this.enabled&&o?.type==="geometry"&&Promise.resolve().then(()=>{try{this.registerSection(o.key,o.geometry)}catch{}}),r},this.originalSceneAdd=e.scene.add.bind(e.scene),e.scene.add=(...o)=>{let r=this.originalSceneAdd(...o);for(let a of o)this.checkAndPatchMesh(a);return r}}unpatchWorldRenderer(){let e=this.worldRenderer;if(this.originalFinishChunk&&(e.finishChunk=this.originalFinishChunk,this.originalFinishChunk=null),this.originalDestroy&&(e.destroy=this.originalDestroy,this.originalDestroy=null),this.originalHandleWorkerMessage&&(e.handleWorkerMessage=this.originalHandleWorkerMessage,this.originalHandleWorkerMessage=null),this.originalSceneAdd&&(e.scene.add=this.originalSceneAdd,this.originalSceneAdd=null),this.originalWbgHandle&&(e.worldBlockGeometry.handleWorkerGeometryMessage=this.originalWbgHandle,this.originalWbgHandle=null),this.onWorldSwitchedCb){let t=e.onWorldSwitched.indexOf(this.onWorldSwitchedCb);t!==-1&&e.onWorldSwitched.splice(t,1),this.onWorldSwitchedCb=null}this.patched=!1}checkAndPatchMesh(e){if(e instanceof Pe.Mesh&&e.name==="mesh"){let t=this.findSectionKeyForMesh(e);t&&this.shouldUseRevealEffect(t)&&(e.visible=!1,e.hiddenByReveal=!0)}for(let t of e.children)this.checkAndPatchMesh(t)}findSectionKeyForMesh(e){let t=e;for(;t;){let{sectionKey:_}=t;if(_&&this.worldRenderer.worldBlockGeometry.sectionObjects[_]===t)return _;t=t.parent}let o=e.position,r=16,a=this.worldRenderer.getSectionHeight(),s=Math.floor(o.x/r)*r,n=Math.floor(o.y/a)*a,i=Math.floor(o.z/r)*r,c=`${s},${n},${i}`;return this.worldRenderer.worldBlockGeometry.sectionObjects[c]?c:null}get scene(){return this.worldRenderer.scene}getCameraPosition(){return this.worldRenderer.getCameraPosition()}getOriginalMesh(e){let t=this.worldRenderer.worldBlockGeometry.sectionObjects[e];return t?t.children.find(o=>o.name==="mesh"):null}onChunkFinished(e){this.finishedChunkCount++,!this.revealTriggered&&this.finishedChunkCount>=sk&&this.triggerReveal()}registerSection(e,t){this.revealedChunks.has(e)||this.revealingSections.has(e)||(this.revealTriggered?this.startSectionReveal(e,t):this.pendingGeometries.set(e,t))}shouldUseRevealEffect(e){return this.enabled&&!this.revealedChunks.has(e)&&!this.revealingSections.has(e)}triggerReveal(){this.revealTriggered=!0,this.initialWaveDone=!0,this.revealStartTime=performance.now();let e=this.getCameraPosition(),t=[...this.pendingGeometries.entries()];this.pendingGeometries.clear();let o=t.map(([a,s])=>{let n=Math.hypot(s.sx-e.x,s.sy-e.y,s.sz-e.z);return{key:a,geometry:s,distance:n}}).sort((a,s)=>a.distance-s.distance),r=o.at(-1)?.distance||1;for(let{key:a,geometry:s,distance:n}of o){let i=n/r*1500;setTimeout(()=>{!this.revealedChunks.has(a)&&!this.revealingSections.has(a)&&this.startSectionReveal(a,s)},i)}}startSectionReveal(e,t){if(!t.positions?.length||this.revealingSections.has(e)||this.revealedChunks.has(e))return;let o=this.createWireframeGeometry(t),r=this.getOriginalMesh(e);r&&(r.visible=!1,r.hiddenByReveal=!0);let a=new Pe.LineSegments(o,this.wireframeMaterial.clone());a.position.set(t.sx,t.sy,t.sz),a.name="scifi-wireframe",a.renderOrder=1e3;let s=new Pe.LineSegments(o.clone(),this.wireframeGlowMaterial.clone());s.position.copy(a.position),s.scale.set(1.02,1.02,1.02),s.name="scifi-glow",s.renderOrder=999;let n=new Pe.Group;n.add(a),n.add(s),n.name="scifi-reveal-group",n.sectionKey=e,this.scene.add(n);let i=this.initialWaveDone?ck:nk,c=this.initialWaveDone?_k:ik,_={key:e,wireframeGroup:n,revealStartTime:performance.now(),phase:"wireframe",originalMeshRef:null,wireframeMs:i,revealMs:c};setTimeout(()=>{let u=this.getOriginalMesh(e);u&&!u.hiddenByReveal&&(u.visible=!1,u.hiddenByReveal=!0)},0),this.revealingSections.set(e,_)}createWireframeGeometry(e){let t=e.positions,o=e.indices,r=[],a=new Set;for(let n=0;n<o.length;n+=3){let i=o[n],c=o[n+1],_=o[n+2];this.addEdge(t,i,c,r,a),this.addEdge(t,c,_,r,a),this.addEdge(t,_,i,r,a)}let s=new Pe.BufferGeometry;return s.setAttribute("position",new Pe.Float32BufferAttribute(r,3)),s}addEdge(e,t,o,r,a){let s=Math.min(t,o),n=Math.max(t,o),i=`${s}-${n}`;a.has(i)||(a.add(i),r.push(e[t*3],e[t*3+1],e[t*3+2],e[o*3],e[o*3+1],e[o*3+2]))}update(e){if(!this.enabled||this.revealingSections.size===0)return;this.pulseTime+=e*.001;let t=performance.now(),o=.6+.4*Math.sin(this.pulseTime*4),r=[];for(let[a,s]of this.revealingSections){let n=t-s.revealStartTime;if(s.phase==="wireframe"){let i=s.wireframeGroup.children[0],c=s.wireframeGroup.children[1];if(i?.material){let _=i.material;_.opacity=o;let u=.85+.15*Math.sin(this.pulseTime*6+n*.002);_.color.setRGB(13/255*u,234/255*u,238/255*u)}if(c?.material){let _=c.material;_.opacity=o*.4}if(n>s.wireframeMs&&(s.phase="transitioning",s.originalMeshRef=this.getOriginalMesh(a),s.originalMeshRef)){s.originalMeshRef.visible=!0;let _=s.originalMeshRef.material,u=_.clone();u.transparent=!0,u.opacity=0,u.needsUpdate=!0,s.originalMeshRef.originalMaterial=_,s.originalMeshRef.material=u}}else if(s.phase==="transitioning"){let i=n-s.wireframeMs,c=Math.min(1,i/s.revealMs),_=1-(1-c)**3,u=s.wireframeGroup.children[0],b=s.wireframeGroup.children[1];if(u?.material){let h=u.material;h.opacity=1-_}if(b?.material){let h=b.material;h.opacity=(1-_)*.55}if(s.originalMeshRef?.material){let h=s.originalMeshRef.material;h.opacity=_}c>=1&&(s.phase="complete",r.push(s))}}for(let a of r)this.completeReveal(a)}completeReveal(e){if(this.revealingSections.delete(e.key),this.revealedChunks.add(e.key),e.originalMeshRef){let t=e.originalMeshRef.originalMaterial;if(t){let o=e.originalMeshRef.material;e.originalMeshRef.material=t,o.dispose(),delete e.originalMeshRef.originalMaterial}e.originalMeshRef.visible=!0,delete e.originalMeshRef.hiddenByReveal}this.disposeWireframeGroup(e.wireframeGroup)}disposeWireframeGroup(e){this.scene.remove(e);let t=[];e.traverse(o=>{t.push(o)});for(let o of t){let r=o;if(r.geometry&&r.geometry.dispose(),r.material){let a=r.material;if(Array.isArray(a))for(let s of a)s.dispose();else a&&typeof a.dispose=="function"&&a.dispose()}}e.clear()}reset(){for(let e of this.revealingSections.values())this.disposeWireframeGroup(e.wireframeGroup);this.pendingGeometries.clear(),this.revealingSections.clear(),this.revealedChunks.clear(),this.finishedChunkCount=0,this.revealTriggered=!1,this.revealStartTime=0,this.pulseTime=0}forceCompleteAll(){let e=[...this.revealingSections.values()];for(let t of e){if(t.originalMeshRef||(t.originalMeshRef=this.getOriginalMesh(t.key)),t.originalMeshRef){let o=t.originalMeshRef.originalMaterial;o&&(t.originalMeshRef.material=o),t.originalMeshRef.visible=!0}this.completeReveal(t)}}debugGetWireframeGroups(){let e=[];return this.scene.traverse(t=>{t.name==="scifi-reveal-group"&&e.push(t)}),e}debugForceCleanup(){let e=this.debugGetWireframeGroups();for(let t of e)this.disposeWireframeGroup(t);for(let t of this.revealingSections.values())this.disposeWireframeGroup(t.wireframeGroup);this.revealingSections.clear()}debugStatus(){let e=this.debugGetWireframeGroups(),t=new Set(this.revealingSections.keys()),o=e.filter(r=>!t.has(r.sectionKey));return{revealTriggered:this.revealTriggered,finishedChunkCount:this.finishedChunkCount,pendingGeometries:this.pendingGeometries.size,revealingSections:this.revealingSections.size,revealedChunks:this.revealedChunks.size,wireframeGroupsInScene:e.length,orphanedWireframeGroups:o.length,orphanedKeys:o.map(r=>r.sectionKey),sections:[...this.revealingSections.entries()].map(([r,a])=>({key:r,phase:a.phase,hasOriginalMesh:!!a.originalMeshRef,wireframeInScene:a.wireframeGroup.parent!==null}))}}debugLog(){}},Qu={id:"futuristicReveal",controller:pn,enabledDefault:!0};I();A();E();z();import*as Se from"three";var uk=parseInt(Se.REVISION.replaceAll(/\D+/g,""),10),mn=class extends Se.ShaderMaterial{constructor(){super({uniforms:{time:{value:0},fade:{value:1}},vertexShader:`
|
|
21770
|
+
`,$e={textureSize:128,gravity:new ce.Vector3(0,-.005,0),friction:.998,defaultParticleSize:300,maxActiveFireworks:5},dl=l=>{let t=l*3;return{x:t,y:t+1,z:t+2}},pl=l=>{let t=l*4;return{r:t,g:t+1,b:t+2,a:t+3}},Fo=(l=0,e=0)=>Math.floor(Math.random()*(l+1-e))+e,$h=(l,e,t,o)=>{l.save();let r=l.createRadialGradient(e,e,0,e,e,e);r.addColorStop(0,"rgba(255,255,255,1.0)"),r.addColorStop(.5,"rgba(255,255,255,0.5)"),r.addColorStop(1,"rgba(255,255,255,0)"),l.fillStyle=r,l.fillRect(0,0,t,o),l.restore()},Zh=()=>{let l=$e.textureSize,e=Fe(l,l),t=e.getContext("2d"),o=l/2;$h(t,o,e.width,e.height);let r=new ce.Texture(e);return r.needsUpdate=!0,r},Kh=(l,e,t,o,r=$e.defaultParticleSize)=>{let a=new ce.BufferGeometry,s=[],n=[],i=[],c=[],_=[],u=Math.random()>.3?"single":"multiple",b=Fo(100,20)*.01,h=()=>Fo(100,1)*.01,k="red",f=Math.random();f>.66?k="red":f>.33?k="green":k="blue";for(let v=0;v<l;v++){let x=new ce.Vector3(0,0,0);if(s.push(x.x,x.y,x.z),n.push(e[v].x,e[v].y,e[v].z),t==="seed"){let R=e[v].y**2*.04;v===0&&(R*=1.1),c.push(R),_.push(R*.017),i.push(1,1,1,1)}else if(t==="trail"){let R=Math.random()*.1+.1;c.push(R),_.push(R*.017),i.push(1,1,1,1)}else{let R=Fo(r,10)*.001;if(c.push(R),_.push(R*.017),u==="multiple")i.push(h(),h(),h(),1);else switch(k){case"red":i.push(b,.1,.1,1);break;case"green":i.push(.1,b,.1,1);break;case"blue":i.push(.1,.1,b,1);break}}}a.setAttribute("position",new ce.Float32BufferAttribute(s,3)),a.setAttribute("velocity",new ce.Float32BufferAttribute(n,3)),a.setAttribute("color",new ce.Float32BufferAttribute(i,4)),a.setAttribute("adjustSize",new ce.Float32BufferAttribute(c,1)),a.setAttribute("mass",new ce.Float32BufferAttribute(_,1));let y=new ce.RawShaderMaterial({uniforms:{size:{value:$e.textureSize},texture:{value:o}},transparent:!0,depthWrite:!1,blending:ce.AdditiveBlending,vertexShader:Vh,fragmentShader:Yh});return new ce.Points(a,y)},ml=class{constructor(e,t,o,r,a){p(this,"particleNum");p(this,"timerStartFading");p(this,"mesh");this.particleNum=e,this.timerStartFading=10,this.mesh=Kh(e,t,o,r,a)}update(e){this.timerStartFading>0&&(this.timerStartFading-=.3);let t=this.mesh.geometry.attributes.position,o=this.mesh.geometry.attributes.velocity,r=this.mesh.geometry.attributes.color,a=this.mesh.geometry.attributes.mass,s=()=>Math.random()>.5?.98:.96,n=i=>Math.random()>.5?0:(1-i)*.1;for(let i=0;i<this.particleNum;i++){let{x:c,y:_,z:u}=dl(i);o.array[_]+=e.y-a.array[i],o.array[c]*=$e.friction,o.array[u]*=$e.friction,o.array[_]*=$e.friction,t.array[c]+=o.array[c],t.array[_]+=o.array[_],t.array[u]+=o.array[u];let{a:b}=pl(i);this.timerStartFading<=0&&(r.array[b]*=s()-n(r.array[b]),r.array[b]<.001&&(r.array[b]=0))}t.needsUpdate=!0,o.needsUpdate=!0,r.needsUpdate=!0}disposeAll(){this.mesh.geometry.dispose(),this.mesh.material.dispose()}},rn=class extends ml{constructor(e,t,o){super(e,t,"seed",o)}update(e){let t=this.mesh.geometry.attributes.position,o=this.mesh.geometry.attributes.velocity,r=this.mesh.geometry.attributes.color,a=this.mesh.geometry.attributes.mass,s=()=>Math.random()>.3?.99:.96,n=u=>Math.random()>.3?0:(1-u)*.1,i=()=>Math.random()>.5?.05:-.05,c=()=>Math.random()>.1,_=$e.friction*.98;for(let u=0;u<this.particleNum;u++){let{x:b,y:h,z:k}=dl(u);o.array[h]+=e.y-a.array[u],o.array[b]*=_,o.array[k]*=_,o.array[h]*=_,t.array[b]+=o.array[b],t.array[h]+=o.array[h],t.array[k]+=o.array[k],c()&&(t.array[b]+=i()),c()&&(t.array[k]+=i());let{a:f}=pl(u);r.array[f]*=s()-n(r.array[f]),r.array[f]<.001&&(r.array[f]=0)}t.needsUpdate=!0,o.needsUpdate=!0,r.needsUpdate=!0}},ln=class extends ml{constructor(e,t,o){super(e,t,"trail",o)}update(e){let t=this.mesh.geometry.attributes.position,o=this.mesh.geometry.attributes.velocity,r=this.mesh.geometry.attributes.color,a=this.mesh.geometry.attributes.mass,s=()=>Math.random()>.3?.98:.95,n=()=>Math.random()>.5?.05:-.05,i=()=>Math.random()>.2;for(let c=0;c<this.particleNum;c++){let{x:_,y:u,z:b}=dl(c);o.array[u]+=e.y-a.array[c],o.array[_]*=$e.friction,o.array[b]*=$e.friction,o.array[u]*=$e.friction,t.array[_]+=o.array[_],t.array[u]+=o.array[u],t.array[b]+=o.array[b],i()&&(t.array[_]+=n()),i()&&(t.array[b]+=n());let{a:h}=pl(c);r.array[h]*=s(),r.array[h]<.001&&(r.array[h]=0)}t.needsUpdate=!0,o.needsUpdate=!0,r.needsUpdate=!0}},bl=class{constructor(e,t=$e.defaultParticleSize,o){p(this,"meshGroup");p(this,"isExplode");p(this,"petalsNum");p(this,"life");p(this,"seed");p(this,"flowerSizeRate");p(this,"flower");p(this,"texture");p(this,"particleSize");this.meshGroup=new ce.Group,this.isExplode=!1,this.texture=e,this.particleSize=t;let r=400,a=150;this.petalsNum=Fo(r,a),this.life=150,this.seed=this.getSeed(o),this.meshGroup.add(this.seed.mesh),this.flowerSizeRate=ce.MathUtils.mapLinear(this.petalsNum,a,r,.4,.7)}getSeed(e){let o=[];for(let a=0;a<40;a++){let n=a===0?Math.random()*2.5+.9:Math.random()*2+.4,i=0;o.push(new ce.Vector3(0,n,i))}let r=new rn(40,o,this.texture);if(e)r.mesh.position.set(e.x,e.y,e.z);else{let a=Math.random()*80-40,s=-50,n=Math.random()*80-40;r.mesh.position.set(a,s,n)}return r}explode(e){this.isExplode=!0,this.flower=this.getFlower(e),this.meshGroup.add(this.flower.mesh),this.meshGroup.remove(this.seed.mesh),this.seed.disposeAll()}getFlower(e){let t=this.petalsNum,o=[],r;if(Math.random()>.5)for(let n=0;n<t;n++){r=Fo(120,60)*.01;let i=ce.MathUtils.degToRad(Math.random()*180),c=ce.MathUtils.degToRad(Math.random()*360),_=Math.sin(i)*Math.cos(c)*r,u=Math.sin(i)*Math.sin(c)*r,b=Math.cos(i)*r,h=new ce.Vector3(_,u,b);h.multiplyScalar(this.flowerSizeRate),o.push(h)}else{let n=180/t,i=360*(Math.random()*20+1)/t,c=i,_=i;r=Fo(120,60)*.01;for(let u=0;u<t;u++){let b=Math.sin(ce.MathUtils.degToRad(n*u)),h=Math.cos(ce.MathUtils.degToRad(n*u))*r,k=Math.cos(ce.MathUtils.degToRad(c*u))*b*r,f=Math.sin(ce.MathUtils.degToRad(_*u))*b*r,y=new ce.Vector3(k,f,h);y.multiplyScalar(this.flowerSizeRate),o.push(y)}}let s=new ml(t,o,"default",this.texture,this.particleSize);return s.mesh.position.set(e.x,e.y,e.z),s}update(e){this.isExplode?(this.flower.update(e),this.life>0&&(this.life-=1)):this.drawTail()}drawTail(){this.seed.update($e.gravity);let e=this.seed.mesh.geometry.attributes.position,t=this.seed.mesh.geometry.attributes.velocity,o=0;for(let u=0,b=t.array.length;u<b;u++){let h=t.array[u];u%3===1&&h>0&&o++}if(!(o===0))return;let{x:a,y:s,z:n}=this.seed.mesh.position,i=new ce.Vector3(a,s,n),c=0,_;for(let u=0,b=e.array.length;u<b;u++){let h=e.array[u];u%3===1&&h>c&&(c=h,_=new ce.Vector3(e.array[u-1],h,e.array[u+2]))}_&&(i.add(_),this.explode(i))}},Rr=class extends bl{constructor(t,o=$e.defaultParticleSize,r){super(t,o,r);p(this,"tailMeshGroup");p(this,"tails");let a=150,s=100;this.petalsNum=Fo(a,s),this.flowerSizeRate=ce.MathUtils.mapLinear(this.petalsNum,s,a,.4,.7),this.tailMeshGroup=new ce.Group,this.tails=[]}explode(t){this.isExplode=!0,this.flower=this.getFlower(t),this.tails=this.getTail(),this.meshGroup.add(this.flower.mesh),this.meshGroup.add(this.tailMeshGroup)}getTail(){let t=[],r=this.flower.mesh.geometry.attributes.color;for(let a=0;a<this.petalsNum;a++){let s=[];for(let O=0;O<20;O++)s.push(new ce.Vector3(0,0,0));let n=new ln(20,s,this.texture),{r:i,g:c,b:_,a:u}=pl(a),b=r.array[i],h=r.array[c],k=r.array[_],f=r.array[u],y=n.mesh.geometry.attributes.position,v=n.mesh.geometry.attributes.color;for(let O=0;O<y.count;O++){let T=pl(O);v.array[T.r]=b,v.array[T.g]=h,v.array[T.b]=k,v.array[T.a]=f}let{x,y:R,z:M}=this.flower.mesh.position;n.mesh.position.set(x,R,M),t.push(n),this.tailMeshGroup.add(n.mesh)}return t}update(t){if(this.isExplode){this.flower.update(t);let o=this.flower.mesh.geometry.attributes.position;for(let r=0,a=this.tails.length;r<a;r++){let s=this.tails[r];s.update(t);let{x:n,y:i,z:c}=dl(r),_=new ce.Vector3(o.array[n],o.array[i],o.array[c]),u=s.mesh.geometry.attributes.position,b=s.mesh.geometry.attributes.velocity;for(let h=0;h<u.count;h++){let k=dl(h),f=new ce.Vector3,y=new ce.Vector3(u.array[k.x],u.array[k.y],u.array[k.z]),v=new ce.Vector3(b.array[k.x],b.array[k.y],b.array[k.z]);f.subVectors(_,y);let x=f.sub(v);x.normalize(),x.multiplyScalar(Math.random()*3e-4*this.life),b.array[k.x]+=x.x,b.array[k.y]+=x.y,b.array[k.z]+=x.z}b.needsUpdate=!0}this.life>0&&(this.life-=1.2)}else this.drawTail()}},Ia=class{constructor(e,t){p(this,"fireworksInstances");p(this,"scene");p(this,"texture");p(this,"particleSize");p(this,"maxFireworks");this.fireworksInstances=[],this.scene=e,this.texture=Zh(),this.particleSize=t?.defaultParticleSize??$e.defaultParticleSize,this.maxFireworks=t?.maxActiveFireworks??$e.maxActiveFireworks}launchFirework(e){if(this.fireworksInstances.length>=this.maxFireworks)return;let t=e?.particleSize??this.particleSize,o=e?.position,r;e?.forceRich?r=new Rr(this.texture,t,o):e?.forceBasic?r=new bl(this.texture,t,o):r=Math.random()>.5?new bl(this.texture,t,o):new Rr(this.texture,t,o),this.fireworksInstances.push(r),this.scene.add(r.meshGroup)}update(){let e=[];for(let t=this.fireworksInstances.length-1;t>=0;t--){let o=this.fireworksInstances[t];o.update($e.gravity),o.isExplode&&e.push(t)}for(let t=0,o=e.length;t<o;t++){let r=e[t],a=this.fireworksInstances[r];if(a&&(a.meshGroup.remove(a.seed.mesh),a.seed.disposeAll(),a.life<=0)){if(this.scene.remove(a.meshGroup),a instanceof Rr&&a.tailMeshGroup)for(let s of a.tails)s.disposeAll();a.flower?.disposeAll(),this.fireworksInstances.splice(r,1)}}}clear(){for(let e of this.fireworksInstances)if(this.scene.remove(e.meshGroup),e.seed.disposeAll(),e.flower&&e.flower.disposeAll(),e instanceof Rr)for(let t of e.tails)t.disposeAll();this.fireworksInstances=[]}dispose(){this.clear(),this.texture.dispose()}};sn();I();A();E();z();import*as Te from"three";import{Vec3 as hl}from"vec3";import _n from"prismarine-nbt";I();A();E();z();import*as Xe from"three";var nn=20,cn=40,ek={white_banner:15,orange_banner:14,magenta_banner:13,light_blue_banner:12,yellow_banner:11,lime_banner:10,pink_banner:9,gray_banner:8,light_gray_banner:7,cyan_banner:6,purple_banner:5,blue_banner:4,brown_banner:3,green_banner:2,red_banner:1,black_banner:0},Aa={0:"#1d1d21",1:"#b02e26",2:"#5e7c16",3:"#835432",4:"#3c44aa",5:"#8932b8",6:"#169c9c",7:"#9d9d97",8:"#474f52",9:"#f38baa",10:"#80c71f",11:"#fed83d",12:"#3ab3da",13:"#c74ebd",14:"#f9801d",15:"#f9fffe"};function tk(l){let e=l.replace("_wall_banner","_banner");return ek[e]??15}var ok=(l,e,t,o,r,a,s)=>{switch(l.fillStyle=t,e){case"bs":l.fillRect(o,r,a,s);break;case"ls":l.fillRect(o,r,a/3,s);break;case"rs":l.fillRect(o+a*2/3,r,a/3,s);break;case"ts":l.fillRect(o,r,a,s/3);break;case"ms":l.fillRect(o,r+s/3,a,s/3);break;case"drs":l.fillRect(o,r,a/2,s/2);break;case"dls":l.fillRect(o+a/2,r,a/2,s/2);break;case"ss":for(let n=0;n<a;n+=2)l.fillRect(o+n,r,1,s);break;case"cr":l.fillRect(o,r+s/3,a,s/3),l.fillRect(o+a/3,r,a/3,s);break;case"sc":l.fillRect(o,r+s/2-1,a,2),l.fillRect(o+a/2-1,r,2,s);break;default:l.fillRect(o,r,a,s)}};function rk(l,e){if(!e||e.length===0)return`banner_${l}_empty`;let t=e.map(o=>`${o.Pattern??"bs"}_${o.Color??0}`).join(",");return`banner_${l}_${t}`}var lk=(l,e,t=(o,r)=>Fe(o,r))=>{let r=t(nn*1,cn*1),a=r.getContext("2d");if(!a)return;a.imageSmoothingEnabled=!1;let s=Aa[l]||Aa[15];if(a.fillStyle=s,a.fillRect(0,0,nn*1,cn*1),e?.Patterns&&e.Patterns.length>0)for(let n of e.Patterns){let i=n.Color??0,c=n.Pattern??"bs",_=Aa[i]||Aa[0];ok(a,c,_,0,0,nn*1,cn*1)}return r},za=new Map;function Vu(l,e,t){let o=tk(e),r=rk(o,t?.Patterns),a=za.get(r);if(a)return a.refCount++,a.texture;let s=lk(o,t);if(!s)return;let n=new Xe.Texture(s);return n.magFilter=Xe.NearestFilter,n.minFilter=Xe.NearestFilter,n.needsUpdate=!0,za.set(r,{texture:n,refCount:1}),n}function Ea(l){for(let[e,t]of za.entries())if(t.texture===l){t.refCount--,t.refCount<=0&&(t.texture.dispose(),za.delete(e));return}}function Yu(l,e,t,o){let n,i,c;t?(n=(-14.6+13.4)/2/16-.5,i=1-14.75/16-.5,c=1/2):(n=(1.4+29.4)/2/16,i=1-7.25/16-.5,c=0);let _=new Xe.Mesh(new Xe.PlaneGeometry(.85,1.75),new Xe.MeshBasicMaterial({map:o,transparent:!0}));_.renderOrder=999;let u=.5/16,b=.25/16;t?_.position.set(0,n,i+b+.004):_.position.set(0,n,i+u/2+.004);let h=new Xe.Group;return h.rotation.set(0,-Xe.MathUtils.degToRad(e*(t?90:45/2)),0),h.add(_),h.bannerTexture=o,h.position.set(l.x+.5,l.y+c,l.z+.5),h}var Ma=class{constructor(e,t,o,r){this.worldRenderer=e;this.scene=t;this.material=o;this.displayOptions=r;p(this,"sectionObjects",{});p(this,"waitingChunksToDisplay",{});p(this,"estimatedMemoryUsage",0)}handleWorkerGeometryMessage(e){var f;let t=this.sectionObjects[e.key];t&&(this.removeSectionMemoryUsage(t),t.traverse(y=>{y.bannerTexture&&Ea(y.bannerTexture)}),this.scene.remove(t),nt(t),delete this.sectionObjects[e.key]);let o=e.key.split(",");if(!this.worldRenderer.loadedChunks[o[0]+","+o[2]]||!e.geometry.positions.length||!this.worldRenderer.active)return;let r=new Te.BufferGeometry,a=new Te.BufferAttribute(e.geometry.positions,3),s=new Te.BufferAttribute(e.geometry.normals,3),n=new Te.BufferAttribute(e.geometry.colors,3),i=new Te.BufferAttribute(e.geometry.uvs,2),c=new Te.BufferAttribute(e.geometry.indices,1);r.setAttribute("position",a),r.setAttribute("normal",s),r.setAttribute("color",n),r.setAttribute("uv",i),r.index=c,this.addSectionMemoryUsage(r);let _=new Te.Mesh(r,this.material);_.position.set(e.geometry.sx,e.geometry.sy,e.geometry.sz),_.name="mesh",t=new Te.Group,t.add(_);let u=e.geometry.sectionEndY-e.geometry.sectionStartY,b=16,h=new Te.Mesh(new Te.BoxGeometry(b,u,b),new Te.MeshBasicMaterial({color:0,transparent:!0,opacity:0}));h.position.set(e.geometry.sx,e.geometry.sy,e.geometry.sz);let k=new Te.BoxHelper(h,16776960);if(k.name="helper",t.add(k),t.name="chunk",t.tilesCount=e.geometry.positions.length/3/4,t.blocksCount=e.geometry.blocksCount,this.displayOptions.inWorldRenderingConfig.showChunkBorders||(k.visible=!1),Object.keys(e.geometry.signs).length)for(let[y,{isWall:v,isHanging:x,rotation:R}]of Object.entries(e.geometry.signs)){let M=this.worldRenderer.blockEntities[y];if(!M)continue;let[O,T,S]=y.split(","),P=this.worldRenderer.renderSign(new hl(+O,+T,+S),R,v,x,_n.simplify(M));P&&t.add(P)}if(Object.keys(e.geometry.heads).length)for(let[y,{isWall:v,rotation:x}]of Object.entries(e.geometry.heads)){let R=this.worldRenderer.blockEntities[y];if(!R)continue;let[M,O,T]=y.split(","),S=this.worldRenderer.renderHead(new hl(+M,+O,+T),x,v,_n.simplify(R));S&&t.add(S)}if(Object.keys(e.geometry.banners).length)for(let[y,{isWall:v,rotation:x,blockName:R}]of Object.entries(e.geometry.banners)){let M=this.worldRenderer.blockEntities[y];if(!M)continue;let[O,T,S]=y.split(","),P=Vu(this.worldRenderer,R,_n.simplify(M));if(!P)continue;let L=Yu(new hl(+O,+T,+S),x,v,P);t.add(L)}if(this.sectionObjects[e.key]=t,this.displayOptions.inWorldRenderingConfig._renderByChunks){t.visible=!1;let y=`${o[0]},${o[2]}`;(f=this.waitingChunksToDisplay)[y]??(f[y]=[]),this.waitingChunksToDisplay[y].push(e.key),this.worldRenderer.finishedChunks[y]&&this.finishChunk(y)}this.worldRenderer.updatePosDataChunk(e.key),t.matrixAutoUpdate=!1,_.onAfterRender=(y,v,x,R,M,O)=>{},this.scene.add(t)}finishChunk(e){for(let t of this.waitingChunksToDisplay[e]??[])this.sectionObjects[t].visible=!0;delete this.waitingChunksToDisplay[e]}estimateGeometryMemoryUsage(e){let t=0,{attributes:o}=e;for(let[r,a]of Object.entries(o))if(a?.array){let s=a.array.BYTES_PER_ELEMENT;t+=a.array.length*s}if(e.index?.array){let r=e.index.array.BYTES_PER_ELEMENT;t+=e.index.array.length*r}return t}addSectionMemoryUsage(e){let t=this.estimateGeometryMemoryUsage(e);this.estimatedMemoryUsage+=t}removeSectionMemoryUsage(e){let t=e.children.find(o=>o.name==="mesh");if(t?.geometry){let o=this.estimateGeometryMemoryUsage(t.geometry);this.estimatedMemoryUsage-=o,this.estimatedMemoryUsage=Math.max(0,this.estimatedMemoryUsage)}}getEstimatedMemoryUsage(){let e=this.estimatedMemoryUsage,o=`${(e/(1024*1024)).toFixed(2)} MB`;return{bytes:e,readable:o}}resetWorld(){for(let e of Object.values(this.sectionObjects))this.removeSectionMemoryUsage(e),this.scene.remove(e);this.sectionObjects={},this.waitingChunksToDisplay={},this.estimatedMemoryUsage=0}removeColumn(e,t){let o=this.worldRenderer.getSectionHeight(),r=this.worldRenderer.worldMinYRender;if(Ho){let a=r;this.worldRenderer.setSectionDirty(new hl(e,a,t),!1);let s=`${e},${a},${t}`,n=this.sectionObjects[s];n&&(this.removeSectionMemoryUsage(n),n.traverse(i=>{i.bannerTexture&&Ea(i.bannerTexture)}),this.scene.remove(n),nt(n)),delete this.sectionObjects[s]}else for(let a=r;a<this.worldRenderer.worldSizeParams.worldHeight;a+=o){this.worldRenderer.setSectionDirty(new hl(e,a,t),!1);let s=`${e},${a},${t}`,n=this.sectionObjects[s];n&&(this.removeSectionMemoryUsage(n),n.traverse(i=>{i.bannerTexture&&Ea(i.bannerTexture)}),this.scene.remove(n),nt(n)),delete this.sectionObjects[s]}}};I();A();E();z();I();A();E();z();import*as Ze from"three";var un=2e3,$u=32,Zu=32,Ra=12,Ku=24,Oa=1.2,ak=-5,dn=class{constructor(e){this.worldRenderer=e;p(this,"instancedMesh");p(this,"geometry");p(this,"material");p(this,"particles",[]);p(this,"enabled",!1);p(this,"dummy",new Ze.Matrix4);p(this,"tempPosition",new Ze.Vector3);p(this,"tempQuaternion",new Ze.Quaternion);p(this,"tempScale",new Ze.Vector3);p(this,"render",e=>{if(!this.enabled||!this.instancedMesh)return;let t=this.worldRenderer.getCameraPosition();this.instancedMesh.position.copy(t);let o=this.worldRenderer.reactiveState.world.heightmaps,{dummy:r,tempPosition:a,tempQuaternion:s,tempScale:n}=this,i=NaN,c=NaN,_;for(let u=0;u<un;u++){let b=this.particles[u];this.instancedMesh.getMatrixAt(u,r),r.decompose(a,s,n),a.addScaledVector(b.velocity,e);let h=a.y,k=Math.sqrt(a.x*a.x+a.z*a.z),f=t.x+a.x,y=t.y+a.y,v=t.z+a.z,x=Math.floor(f/16),R=Math.floor(v/16);(x!==i||R!==c)&&(_=o.get(`${x},${R}`),i=x,c=R);let M=(Math.floor(f)%16+16)%16,O=(Math.floor(v)%16+16)%16,T=_?.[O*16+M];if(k>$u||T!==void 0&&T!==-32768&&y<=T+1+b.despawnOffset||h<ak){this.respawnParticle(a);let P=Ra+Math.random()*(Ku-Ra);b.velocity.set((Math.random()-.5)*Oa,-P,(Math.random()-.5)*Oa),b.despawnOffset=Math.random()*.5}r.compose(a,s,n),this.instancedMesh.setMatrixAt(u,r)}this.instancedMesh.instanceMatrix.needsUpdate=!0})}enable(){this.enabled||(this.enabled=!0,this.instancedMesh?this.instancedMesh.visible=!0:this.createRain())}disable(){this.enabled&&(this.enabled=!1,this.instancedMesh&&(this.instancedMesh.visible=!1))}autoEnableCheck(){return this.worldRenderer.worldRendererConfig.isRaining===!0}dispose(){this.instancedMesh&&this.worldRenderer.scene.remove(this.instancedMesh),this.geometry?.dispose(),this.material?.dispose(),this.instancedMesh=void 0,this.geometry=void 0,this.material=void 0,this.particles=[]}createRain(){this.geometry=new Ze.BoxGeometry(.03,.3,.03),this.material=new Ze.MeshBasicMaterial({color:4482713,transparent:!0,opacity:.6}),this.instancedMesh=new Ze.InstancedMesh(this.geometry,this.material,un),this.instancedMesh.name="rain-particles";let e=new Ze.Matrix4,t=new Ze.Vector3;for(let o=0;o<un;o++){this.respawnParticle(t),t.y=Math.random()*Zu,e.setPosition(t),this.instancedMesh.setMatrixAt(o,e);let r=Ra+Math.random()*(Ku-Ra);this.particles.push({velocity:new Ze.Vector3((Math.random()-.5)*Oa,-r,(Math.random()-.5)*Oa),age:0,despawnOffset:Math.random()*.5})}this.instancedMesh.instanceMatrix.needsUpdate=!0,this.worldRenderer.scene.add(this.instancedMesh)}respawnParticle(e){let t=Math.random()*Math.PI*2,o=Math.random()*$u;e.set(Math.cos(t)*o,Zu,Math.sin(t)*o)}},Ju={id:"rain",controller:dn,enabledDefault:!1,requiresHeightmap:!0};I();A();E();z();import*as Pe from"three";var Xu=new Pe.Color(13/255,234/255,238/255),sk=9;var nk=350,ik=650;var ck=120,_k=280,pn=class{constructor(e){this.worldRenderer=e;p(this,"pendingGeometries",new Map);p(this,"revealingSections",new Map);p(this,"finishedChunkCount",0);p(this,"revealTriggered",!1);p(this,"revealStartTime",0);p(this,"enabled",!1);p(this,"onWorldSwitchedCb",null);p(this,"patched",!1);p(this,"initialWaveDone",!1);p(this,"wireframeMaterial");p(this,"wireframeGlowMaterial");p(this,"pulseTime",0);p(this,"revealedChunks",new Set);p(this,"originalFinishChunk",null);p(this,"originalDestroy",null);p(this,"originalSceneAdd",null);p(this,"originalHandleWorkerMessage",null);p(this,"originalWbgHandle",null);p(this,"configEnabled",!0);p(this,"render",e=>{this.enabled&&this.update(e*1e3)});this.configEnabled=this.worldRenderer.worldRendererConfig.futuristicReveal===!0,this.wireframeMaterial=new Pe.LineBasicMaterial({color:Xu,transparent:!0,opacity:1,blending:Pe.AdditiveBlending,depthWrite:!1}),this.wireframeGlowMaterial=new Pe.LineBasicMaterial({color:Xu,transparent:!0,opacity:.55,blending:Pe.AdditiveBlending,depthWrite:!1})}enable(){this.configEnabled&&(this.enabled||(this.enabled=!0,this.patchWorldRenderer()))}disable(){this.enabled&&(this.enabled=!1,this.unpatchWorldRenderer(),this.reset())}toggle(){return this.enabled?this.disable():this.enable(),this.enabled}dispose(){this.disable(),this.wireframeMaterial.dispose(),this.wireframeGlowMaterial.dispose()}patchWorldRenderer(){if(this.patched)return;this.patched=!0;let e=this.worldRenderer;this.onWorldSwitchedCb=()=>this.reset(),e.onWorldSwitched.push(this.onWorldSwitchedCb),this.originalFinishChunk=e.finishChunk.bind(e),e.finishChunk=o=>{this.originalFinishChunk(o),this.onChunkFinished(o)},this.originalDestroy=e.destroy.bind(e),e.destroy=()=>{this.dispose(),this.originalDestroy()};let t=e.worldBlockGeometry;this.originalWbgHandle=t.handleWorkerGeometryMessage.bind(t),t.handleWorkerGeometryMessage=o=>{let r=this.originalWbgHandle(o);return this.enabled&&o?.type==="geometry"&&Promise.resolve().then(()=>{try{this.registerSection(o.key,o.geometry)}catch{}}),r},this.originalSceneAdd=e.scene.add.bind(e.scene),e.scene.add=(...o)=>{let r=this.originalSceneAdd(...o);for(let a of o)this.checkAndPatchMesh(a);return r}}unpatchWorldRenderer(){let e=this.worldRenderer;if(this.originalFinishChunk&&(e.finishChunk=this.originalFinishChunk,this.originalFinishChunk=null),this.originalDestroy&&(e.destroy=this.originalDestroy,this.originalDestroy=null),this.originalHandleWorkerMessage&&(e.handleWorkerMessage=this.originalHandleWorkerMessage,this.originalHandleWorkerMessage=null),this.originalSceneAdd&&(e.scene.add=this.originalSceneAdd,this.originalSceneAdd=null),this.originalWbgHandle&&(e.worldBlockGeometry.handleWorkerGeometryMessage=this.originalWbgHandle,this.originalWbgHandle=null),this.onWorldSwitchedCb){let t=e.onWorldSwitched.indexOf(this.onWorldSwitchedCb);t!==-1&&e.onWorldSwitched.splice(t,1),this.onWorldSwitchedCb=null}this.patched=!1}checkAndPatchMesh(e){if(e instanceof Pe.Mesh&&e.name==="mesh"){let t=this.findSectionKeyForMesh(e);t&&this.shouldUseRevealEffect(t)&&(e.visible=!1,e.hiddenByReveal=!0)}for(let t of e.children)this.checkAndPatchMesh(t)}findSectionKeyForMesh(e){let t=e;for(;t;){let{sectionKey:_}=t;if(_&&this.worldRenderer.worldBlockGeometry.sectionObjects[_]===t)return _;t=t.parent}let o=e.position,r=16,a=this.worldRenderer.getSectionHeight(),s=Math.floor(o.x/r)*r,n=Math.floor(o.y/a)*a,i=Math.floor(o.z/r)*r,c=`${s},${n},${i}`;return this.worldRenderer.worldBlockGeometry.sectionObjects[c]?c:null}get scene(){return this.worldRenderer.scene}getCameraPosition(){return this.worldRenderer.getCameraPosition()}getOriginalMesh(e){let t=this.worldRenderer.worldBlockGeometry.sectionObjects[e];return t?t.children.find(o=>o.name==="mesh"):null}onChunkFinished(e){this.finishedChunkCount++,!this.revealTriggered&&this.finishedChunkCount>=sk&&this.triggerReveal()}registerSection(e,t){this.revealedChunks.has(e)||this.revealingSections.has(e)||(this.revealTriggered?this.startSectionReveal(e,t):this.pendingGeometries.set(e,t))}shouldUseRevealEffect(e){return this.enabled&&!this.revealedChunks.has(e)&&!this.revealingSections.has(e)}triggerReveal(){this.revealTriggered=!0,this.initialWaveDone=!0,this.revealStartTime=performance.now();let e=this.getCameraPosition(),t=[...this.pendingGeometries.entries()];this.pendingGeometries.clear();let o=t.map(([a,s])=>{let n=Math.hypot(s.sx-e.x,s.sy-e.y,s.sz-e.z);return{key:a,geometry:s,distance:n}}).sort((a,s)=>a.distance-s.distance),r=o.at(-1)?.distance||1;for(let{key:a,geometry:s,distance:n}of o){let i=n/r*1500;setTimeout(()=>{!this.revealedChunks.has(a)&&!this.revealingSections.has(a)&&this.startSectionReveal(a,s)},i)}}startSectionReveal(e,t){if(!t.positions?.length||this.revealingSections.has(e)||this.revealedChunks.has(e))return;let o=this.createWireframeGeometry(t),r=this.getOriginalMesh(e);r&&(r.visible=!1,r.hiddenByReveal=!0);let a=new Pe.LineSegments(o,this.wireframeMaterial.clone());a.position.set(t.sx,t.sy,t.sz),a.name="scifi-wireframe",a.renderOrder=1e3;let s=new Pe.LineSegments(o.clone(),this.wireframeGlowMaterial.clone());s.position.copy(a.position),s.scale.set(1.02,1.02,1.02),s.name="scifi-glow",s.renderOrder=999;let n=new Pe.Group;n.add(a),n.add(s),n.name="scifi-reveal-group",n.sectionKey=e,this.scene.add(n);let i=this.initialWaveDone?ck:nk,c=this.initialWaveDone?_k:ik,_={key:e,wireframeGroup:n,revealStartTime:performance.now(),phase:"wireframe",originalMeshRef:null,wireframeMs:i,revealMs:c};setTimeout(()=>{let u=this.getOriginalMesh(e);u&&!u.hiddenByReveal&&(u.visible=!1,u.hiddenByReveal=!0)},0),this.revealingSections.set(e,_)}createWireframeGeometry(e){let t=e.positions,o=e.indices,r=[],a=new Set;for(let n=0;n<o.length;n+=3){let i=o[n],c=o[n+1],_=o[n+2];this.addEdge(t,i,c,r,a),this.addEdge(t,c,_,r,a),this.addEdge(t,_,i,r,a)}let s=new Pe.BufferGeometry;return s.setAttribute("position",new Pe.Float32BufferAttribute(r,3)),s}addEdge(e,t,o,r,a){let s=Math.min(t,o),n=Math.max(t,o),i=`${s}-${n}`;a.has(i)||(a.add(i),r.push(e[t*3],e[t*3+1],e[t*3+2],e[o*3],e[o*3+1],e[o*3+2]))}update(e){if(!this.enabled||this.revealingSections.size===0)return;this.pulseTime+=e*.001;let t=performance.now(),o=.6+.4*Math.sin(this.pulseTime*4),r=[];for(let[a,s]of this.revealingSections){let n=t-s.revealStartTime;if(s.phase==="wireframe"){let i=s.wireframeGroup.children[0],c=s.wireframeGroup.children[1];if(i?.material){let _=i.material;_.opacity=o;let u=.85+.15*Math.sin(this.pulseTime*6+n*.002);_.color.setRGB(13/255*u,234/255*u,238/255*u)}if(c?.material){let _=c.material;_.opacity=o*.4}if(n>s.wireframeMs&&(s.phase="transitioning",s.originalMeshRef=this.getOriginalMesh(a),s.originalMeshRef)){s.originalMeshRef.visible=!0;let _=s.originalMeshRef.material,u=_.clone();u.transparent=!0,u.opacity=0,u.needsUpdate=!0,s.originalMeshRef.originalMaterial=_,s.originalMeshRef.material=u}}else if(s.phase==="transitioning"){let i=n-s.wireframeMs,c=Math.min(1,i/s.revealMs),_=1-(1-c)**3,u=s.wireframeGroup.children[0],b=s.wireframeGroup.children[1];if(u?.material){let h=u.material;h.opacity=1-_}if(b?.material){let h=b.material;h.opacity=(1-_)*.55}if(s.originalMeshRef?.material){let h=s.originalMeshRef.material;h.opacity=_}c>=1&&(s.phase="complete",r.push(s))}}for(let a of r)this.completeReveal(a)}completeReveal(e){if(this.revealingSections.delete(e.key),this.revealedChunks.add(e.key),e.originalMeshRef){let t=e.originalMeshRef.originalMaterial;if(t){let o=e.originalMeshRef.material;e.originalMeshRef.material=t,o.dispose(),delete e.originalMeshRef.originalMaterial}e.originalMeshRef.visible=!0,delete e.originalMeshRef.hiddenByReveal}this.disposeWireframeGroup(e.wireframeGroup)}disposeWireframeGroup(e){this.scene.remove(e);let t=[];e.traverse(o=>{t.push(o)});for(let o of t){let r=o;if(r.geometry&&r.geometry.dispose(),r.material){let a=r.material;if(Array.isArray(a))for(let s of a)s.dispose();else a&&typeof a.dispose=="function"&&a.dispose()}}e.clear()}reset(){for(let e of this.revealingSections.values())this.disposeWireframeGroup(e.wireframeGroup);this.pendingGeometries.clear(),this.revealingSections.clear(),this.revealedChunks.clear(),this.finishedChunkCount=0,this.revealTriggered=!1,this.revealStartTime=0,this.pulseTime=0}forceCompleteAll(){let e=[...this.revealingSections.values()];for(let t of e){if(t.originalMeshRef||(t.originalMeshRef=this.getOriginalMesh(t.key)),t.originalMeshRef){let o=t.originalMeshRef.originalMaterial;o&&(t.originalMeshRef.material=o),t.originalMeshRef.visible=!0}this.completeReveal(t)}}debugGetWireframeGroups(){let e=[];return this.scene.traverse(t=>{t.name==="scifi-reveal-group"&&e.push(t)}),e}debugForceCleanup(){let e=this.debugGetWireframeGroups();for(let t of e)this.disposeWireframeGroup(t);for(let t of this.revealingSections.values())this.disposeWireframeGroup(t.wireframeGroup);this.revealingSections.clear()}debugStatus(){let e=this.debugGetWireframeGroups(),t=new Set(this.revealingSections.keys()),o=e.filter(r=>!t.has(r.sectionKey));return{revealTriggered:this.revealTriggered,finishedChunkCount:this.finishedChunkCount,pendingGeometries:this.pendingGeometries.size,revealingSections:this.revealingSections.size,revealedChunks:this.revealedChunks.size,wireframeGroupsInScene:e.length,orphanedWireframeGroups:o.length,orphanedKeys:o.map(r=>r.sectionKey),sections:[...this.revealingSections.entries()].map(([r,a])=>({key:r,phase:a.phase,hasOriginalMesh:!!a.originalMeshRef,wireframeInScene:a.wireframeGroup.parent!==null}))}}debugLog(){}},Qu={id:"futuristicReveal",controller:pn,enabledDefault:!0};I();A();E();z();import*as Se from"three";var uk=parseInt(Se.REVISION.replaceAll(/\D+/g,""),10),mn=class extends Se.ShaderMaterial{constructor(){super({uniforms:{time:{value:0},fade:{value:1}},vertexShader:`
|
|
21771
21771
|
uniform float time;
|
|
21772
21772
|
attribute float size;
|
|
21773
21773
|
varying vec3 vColor;
|
|
@@ -21787,7 +21787,7 @@ void main() {
|
|
|
21787
21787
|
|
|
21788
21788
|
#include <tonemapping_fragment>
|
|
21789
21789
|
#include <${uk>=154?"colorspace_fragment":"encodings_fragment"}>
|
|
21790
|
-
}`})}},bn=class{constructor(e){this.worldRenderer=e;p(this,"points");p(this,"clock",new Se.Clock);p(this,"enabled",!1);p(this,"currentTime");p(this,"enablementCheck",()=>this.currentTime?this.currentTime>13500&&this.currentTime<23e3:!1);p(this,"render",()=>{this.points&&(this.points.position.copy(this.worldRenderer.getCameraPosition()),this.points.material.uniforms.time.value=this.clock.getElapsedTime()*.2)})}enable(){this.enabled||(this.enabled=!0,this.updateVisibility())}disable(){this.enabled&&(this.enabled=!1,this.removeStars())}toggle(){return this.enabled?this.disable():this.enable(),this.enabled}updateTimeOfDay(e){this.currentTime=e,this.enabled&&this.updateVisibility()}updateVisibility(){if(!this.enabled)return;let e=this.enablementCheck?.()??!1;e&&!this.points?this.createStars():!e&&this.points&&this.removeStars()}createStars(){if(this.points)return;let e=80,t=50,o=7e3,r=7,a=10,s=new Se.BufferGeometry,n=f=>new Se.Vector3().setFromSpherical(new Se.Spherical(f,Math.acos(1-Math.random()*2),Math.random()*2*Math.PI)),i=[],c=[],_=Array.from({length:o},()=>(.5+.5*Math.random())*r),u=new Se.Color,b=e+t,h=t/o;for(let f=0;f<o;f++)b-=h*Math.random(),i.push(...n(b).toArray()),u.setHSL(f/o,a,.9),c.push(u.r,u.g,u.b);s.setAttribute("position",new Se.Float32BufferAttribute(i,3)),s.setAttribute("color",new Se.Float32BufferAttribute(c,3)),s.setAttribute("size",new Se.Float32BufferAttribute(_,1));let k=new mn;k.blending=Se.AdditiveBlending,k.depthTest=!1,k.transparent=!0,this.points=new Se.Points(s,k),this.points.renderOrder=-1,this.worldRenderer.scene.add(this.points)}dispose(){this.removeStars()}removeStars(){this.points&&(this.points.geometry.dispose(),this.points.material.dispose(),this.worldRenderer.scene.remove(this.points),this.points=void 0)}},ed={id:"starfield",controller:bn,enabledDefault:!0,cannotBeDisabled:!0};var td={starfield:ed,futuristicReveal:Qu,rain:Ju};var Vo=class l extends Zl{constructor(t,o,r){if(!r.resourcesManager)throw new Error("resourcesManager is required in displayOptions");super(r.resourcesManager,r,o);this.renderer=t;this.initOptions=o;this.displayOptions=r;p(this,"outputFormat","threeJs");p(this,"worldBlockGeometry");p(this,"chunkTextures",new Map);p(this,"signsCache",new Map);p(this,"cameraSectionPos",new ao(0,0,0));p(this,"holdingBlock");p(this,"holdingBlockLeft");p(this,"scene",new ee.Scene);p(this,"ambientLight",new ee.AmbientLight(13421772));p(this,"directionalLight",new ee.DirectionalLight(16777215,.5));p(this,"entities",new pa(this,globalThis.mcData));p(this,"cameraGroupVr");p(this,"material",new ee.MeshLambertMaterial({vertexColors:!0,transparent:!0,alphaTest:.1}));p(this,"itemsTexture");p(this,"cursorBlock");p(this,"onRender",[]);p(this,"cameraShake");p(this,"cameraContainer");p(this,"media");p(this,"waypoints");p(this,"cinimaticScript");p(this,"camera");p(this,"renderTimeAvg",0);p(this,"modules",{});p(this,"sectionsOffsetsAnimations",{});p(this,"fountains",[]);p(this,"fireworksLegacy");p(this,"DEBUG_RAYCAST",!1);p(this,"skyboxRenderer");p(this,"fireworks");p(this,"currentPosTween");p(this,"currentRotTween");p(this,"debugOverlayAdded",!1);p(this,"debugRaycastHelper");p(this,"debugHitPoint");p(this,"prevFramePerspective",null);this.renderer=t,r.rendererState.renderer=l.getRendererInfo(t)??"...",this.worldBlockGeometry=new Ma(this,this.scene,this.material,r),this.cursorBlock=new ma(this),this.holdingBlock=new fr(this),this.holdingBlockLeft=new fr(this,!0);for(let a of Object.values(td))this.registerModule(a);this.skyboxRenderer=new wa(this.scene,!1,null),this.skyboxRenderer.init(),this.addDebugOverlay(),this.resetScene(),this.init(),this.soundSystem=new ha(this),this.cameraShake=new ka(this,this.onRender),this.media=new fa(this),this.fireworksLegacy=new xa(this),this.waypoints=new va(this),this.cinimaticScript=new ya(this,(a,s,n)=>this.setCinimaticCamera(a,s,n),a=>this.setCinimaticFov(a),()=>({position:new ao(this.cameraObject.position.x,this.cameraObject.position.y,this.cameraObject.position.z),yaw:this.cameraShake.getBaseRotation().yaw,pitch:this.cameraShake.getBaseRotation().pitch,fov:this.camera.fov})),this.fireworks=new Ia(this.scene),this.renderUpdateEmitter.on("chunkFinished",a=>{this.finishChunk(a)}),this.worldSwitchActions(),this.initializeModules()}get sectionObjects(){return this.worldBlockGeometry.sectionObjects}get waitingChunksToDisplay(){return this.worldBlockGeometry.waitingChunksToDisplay}get estimatedMemoryUsage(){return this.worldBlockGeometry.estimatedMemoryUsage}get tilesRendered(){return Object.values(this.sectionObjects).reduce((t,o)=>t+o.tilesCount,0)}get blocksRendered(){return Object.values(this.sectionObjects).reduce((t,o)=>t+o.blocksCount,0)}registerModule(t){if(t.id in this.modules)return;let o=new t.controller(this),r={manifest:t,controller:o,enabled:!1,toggle:()=>this.toggleModule(t.id)};this.modules[t.id]=r,t.enabledDefault&&this.toggleModule(t.id,!0)}enableModule(t){let o=this.modules[t];o&&(o.enabled||(o.enabled=!0,o.controller.enable(),o.controller.render&&this.onRender.push(o.controller.render)))}disableModule(t){let o=this.modules[t];if(o&&!o.manifest.cannotBeDisabled&&o.enabled&&(o.enabled=!1,o.controller.disable(),o.controller.render)){let r=this.onRender.indexOf(o.controller.render);r>-1&&this.onRender.splice(r,1)}}toggleModule(t,o){let r=this.modules[t];if(!r)return!1;let a=o!==void 0?o:!r.enabled;if(a===r.enabled)return r.enabled;if(!a&&r.manifest.cannotBeDisabled)return!0;if(r.enabled=a,a)r.controller.enable(),r.controller.render&&!this.onRender.includes(r.controller.render)&&this.onRender.push(r.controller.render);else if(r.controller.disable(),r.controller.render){let s=this.onRender.indexOf(r.controller.render);s>-1&&this.onRender.splice(s,1)}return a}disposeModules(){for(let t of Object.values(this.modules))t.controller.dispose();this.modules={}}initializeModules(){this.updateModulesFromConfig()}getModule(t){return this.modules[t]?.controller}anyModuleRequiresHeightmap(){return Object.values(this.modules).some(t=>t.enabled&&t.manifest.requiresHeightmap)}get cameraObject(){return this.cameraGroupVr??this.cameraContainer}worldSwitchActions(){this.onWorldSwitched.push(()=>{this.protocolCustomBlocks.clear(),this.sectionsOffsetsAnimations={},this.waypoints.clear(),this.cinimaticScript.stopScript(),this.fireworks.clear()})}downloadWorldGeometry(){an(this,this.cameraObject.position,this.cameraShake.getBaseRotation(),"world-geometry.json")}updateEntity(t,o=!1){let r={rotation:{head:{x:t.headPitch??t.pitch,y:t.headYaw,z:0}}};o?this.entities.updateEntityPosition(t,!1,r):this.entities.update(t,r)}updatePlayerEntity(t){this.entities.handlePlayerEntity(t)}resetScene(){this.scene.matrixAutoUpdate=!1,this.scene.background=new ee.Color(this.initOptions.config.sceneBackground),this.scene.add(this.ambientLight),this.directionalLight.position.set(1,1,.5).normalize(),this.directionalLight.castShadow=!0,this.scene.add(this.directionalLight);let t=this.renderer.getSize(new ee.Vector2);this.camera=new ee.PerspectiveCamera(75,t.x/t.y,.1,1e3),this.cameraContainer=new ee.Object3D,this.cameraContainer.add(this.camera),this.scene.add(this.cameraContainer)}watchReactivePlayerState(){super.watchReactivePlayerState(),this.onReactivePlayerStateUpdated("inWater",t=>{this.skyboxRenderer.updateWaterState(t,this.playerStateReactive.waterBreathing)}),this.onReactivePlayerStateUpdated("waterBreathing",t=>{this.skyboxRenderer.updateWaterState(this.playerStateReactive.inWater,t)}),this.onReactivePlayerStateUpdated("ambientLight",t=>{t&&(this.ambientLight.intensity=t)}),this.onReactivePlayerStateUpdated("directionalLight",t=>{t&&(this.directionalLight.intensity=t)}),this.onReactivePlayerStateUpdated("lookingAtBlock",t=>{this.cursorBlock.setHighlightCursorBlock(t?new ao(t.x,t.y,t.z):null,t?.shapes)}),this.onReactivePlayerStateUpdated("diggingBlock",t=>{this.cursorBlock.updateBreakAnimation(t?{x:t.x,y:t.y,z:t.z}:void 0,t?.stage??null,t?.mergedShape)}),this.onReactivePlayerStateUpdated("perspective",t=>{let o=new ao(this.cameraObject.position.x,this.cameraObject.position.y,this.cameraObject.position.z);this.updateCamera(o,this.cameraShake.getBaseRotation().yaw,this.cameraShake.getBaseRotation().pitch)})}watchReactiveConfig(){super.watchReactiveConfig(),this.onReactiveConfigUpdated("showChunkBorders",t=>{this.updateShowChunksBorder(t)}),this.onReactiveConfigUpdated("defaultSkybox",t=>{this.skyboxRenderer.updateDefaultSkybox(t)}),this.onReactiveConfigUpdated("*",()=>{this.updateModulesFromConfig()}),this.updateModulesFromConfig()}updateModulesFromConfig(){let{moduleStates:t}=this.worldRendererConfig;for(let[o,r]of Object.entries(this.modules)){let a=t[o];if(a==="enabled"){r.enabled||this.toggleModule(o,!0);continue}if(a==="disabled"){r.enabled&&!r.manifest.cannotBeDisabled&&this.toggleModule(o,!1);continue}if(a==="auto"||a===void 0)if(r.controller.autoEnableCheck){let s=r.controller.autoEnableCheck();s&&!r.enabled?this.toggleModule(o,!0):!s&&r.enabled&&!r.manifest.cannotBeDisabled&&this.toggleModule(o,!1)}else{let s=r.manifest.enabledDefault??!1;s&&!r.enabled?this.toggleModule(o,!0):!s&&r.enabled&&!r.manifest.cannotBeDisabled&&this.toggleModule(o,!1)}}}changeHandSwingingState(t,o=!1){let r=o?this.holdingBlockLeft:this.holdingBlock;t?r.startSwing():r.stopSwing()}async updateAssetsData(){let t=this.resourcesManager.currentResources,o=this.material.map,r=this.itemsTexture,a=ds(t.blocksAtlasImage);a.needsUpdate=!0,a.flipY=!1,this.material.map=a;let s=ds(t.itemsAtlasImage);s.needsUpdate=!0,s.flipY=!1,this.itemsTexture=s,o&&o.dispose(),r&&r.dispose(),await super.updateAssetsData(),this.onAllTexturesLoaded(),Object.keys(this.loadedChunks).length>0&&this.rerenderAllChunks()}onAllTexturesLoaded(){this.holdingBlock.ready=!0,this.holdingBlock.updateItem(),this.holdingBlockLeft.ready=!0,this.holdingBlockLeft.updateItem()}changeBackgroundColor(t){this.scene.background=new ee.Color(t[0],t[1],t[2])}timeUpdated(t){let o=this.getModule("starfield");o?.updateTimeOfDay&&o.updateTimeOfDay(t),this.skyboxRenderer.updateTime(t)}biomeUpdated(t){t?.temperature!==void 0&&this.skyboxRenderer.updateTemperature(t.temperature)}biomeReset(){this.skyboxRenderer.updateTemperature(on)}getItemRenderData(t,o){return Nu(t,o,this.resourcesManager,this.playerStateReactive)}async demoModel(){let t=cursorBlockRel(0,1,0).position,o=await sl();s_(o,t);let r=new ee.BoxHelper(o,16776960);o.add(r),this.scene.add(o)}demoItem(){let t=cursorBlockRel(0,1,0).position,{mesh:o}=this.entities.getItemMesh({itemId:541},{});o.position.set(t.x+.5,t.y+.5,t.z+.5);let r=new ee.BoxHelper(o,16776960);o.add(r),this.scene.add(o)}addDebugOverlay(){if(this.debugOverlayAdded)return;this.debugOverlayAdded=!0;let t=_r("debug-overlay");setInterval(()=>{if(t.setVisibility(this.displayAdvancedStats),this.displayAdvancedStats){let o=a=>new Intl.NumberFormat("en-US",{}).format(a),r="";r+=`C: ${o(this.renderer.info.render.calls)} `,r+=`TR: ${o(this.renderer.info.render.triangles)} `,r+=`TE: ${o(this.renderer.info.memory.textures)} `,r+=`F: ${o(this.tilesRendered)} `,r+=`B: ${o(this.blocksRendered)} `,r+=`MEM: ${this.worldBlockGeometry.getEstimatedMemoryUsage().readable}`,t.updateText(r),this.backendInfoReport=r}},200)}updatePosDataChunk(t){let[o,r,a]=t.split(",").map(i=>Math.floor(+i/16)),s=Math.abs(o-this.cameraSectionPos.x)+Math.abs(r-this.cameraSectionPos.y)+Math.abs(a-this.cameraSectionPos.z),n=this.sectionObjects[t].children.find(i=>i.name==="mesh");n.renderOrder=500-s}updateViewerPosition(t){this.viewerChunkPosition=t}cameraSectionPositionUpdate(){for(let t in this.sectionObjects)this.sectionObjects[t]&&this.updatePosDataChunk(t)}getDir(t,o){return t===o?0:t<o?1:-1}finishChunk(t){this.worldBlockGeometry.finishChunk(t)}handleWorkerMessage(t){t.type==="geometry"&&this.worldBlockGeometry.handleWorkerGeometryMessage(t)}getSignTexture(t,o,r,a=!1){let s=Wl(t),n=this.chunkTextures.get(`${s[0]},${s[1]}`);n||(n={},this.chunkTextures.set(`${s[0]},${s[1]}`,n));let i=`${t.x},${t.y},${t.z}`;if(n[i])return n[i];let c=dk(this.version),_=Uc(o,r,c);if(!_)return;let u=new ee.Texture(_);return u.magFilter=ee.NearestFilter,u.minFilter=ee.NearestFilter,u.needsUpdate=!0,n[i]=u,u}getCameraPosition(){let t=new ee.Vector3;return this.camera.getWorldPosition(t),t}getSectionCameraPosition(){let t=this.getCameraPosition();return new ao(Math.floor(t.x/16),Math.floor(t.y/16),Math.floor(t.z/16))}updateCameraSectionPos(){let t=this.getSectionCameraPosition();this.cameraSectionPos.equals(t)||(this.cameraSectionPos=t,this.cameraSectionPositionUpdate())}setFirstPersonCamera(t,o,r){let a=this.playerStateReactive.eyeHeight;this.updateCamera(t?.offset(0,a,0)??null,o,r),this.media.tryIntersectMedia(),this.updateCameraSectionPos()}getThirdPersonCamera(t,o,r){t??(t=this.cameraObject.position);let a=this.playerStateReactive.perspective==="third_person_back",s=4,n=new ee.Vector3(0,0,-1),i=new ee.Quaternion().setFromAxisAngle(new ee.Vector3(1,0,0),r),c=new ee.Quaternion().setFromAxisAngle(new ee.Vector3(0,1,0),o),_=new ee.Quaternion().multiplyQuaternions(c,i);n.applyQuaternion(_),a&&n.multiplyScalar(-1),this.DEBUG_RAYCAST&&this.debugRaycast(t,n,s);let u=new ee.Raycaster;u.set(t,n),u.far=s;let b=Object.values(this.sectionObjects).filter(v=>v.name==="chunk"&&v.visible).filter(v=>{let x=v.children.find(O=>O.name==="mesh");if(!x)return!1;let R=new ee.Vector3;return x.getWorldPosition(R),t.distanceTo(R)<80}),h=[];for(let v of b){let x=v.children.find(R=>R.name==="mesh");x&&h.push(x)}let k=u.intersectObjects(h,!1),f=s;return k.length>0&&(f=Math.max(.5,k[0].distance-.2)),new ao(t.x+n.x*f,t.y+n.y*f,t.z+n.z*f)}debugRaycast(t,o,r){this.debugRaycastHelper&&(this.scene.remove(this.debugRaycastHelper),this.debugRaycastHelper=void 0),this.debugHitPoint&&(this.scene.remove(this.debugHitPoint),this.debugHitPoint=void 0),this.debugRaycastHelper=new ee.ArrowHelper(o.clone().normalize(),t,r,16711680,r*.1,r*.05),this.scene.add(this.debugRaycastHelper);let a=new ee.SphereGeometry(.2,8,8),s=new ee.MeshBasicMaterial({color:65280});this.debugHitPoint=new ee.Mesh(a,s),this.debugHitPoint.position.copy(t).add(o.clone().multiplyScalar(r)),this.scene.add(this.debugHitPoint)}setCinimaticCamera(t,o,r){this.cameraObject.position.set(t.x,t.y,t.z),this.cameraShake.setBaseRotation(r,o),this.updateCameraSectionPos()}setCinimaticFov(t){this.camera.fov=t,this.camera.updateProjectionMatrix()}updateCamera(t,o,r){if(!this.cinimaticScript.running){if(t){this.renderer.xr.isPresenting&&(t.y-=this.camera.position.y),this.currentPosTween?.stop();let a=this.displayOptions.inWorldRenderingConfig.instantCameraUpdate?0:this.playerStateUtils.isSpectatingEntity()?150:50;this.currentPosTween=new Le(this.cameraObject.position).to({x:t.x,y:t.y,z:t.z},a).start()}if(this.playerStateUtils.isSpectatingEntity()){let a=this.cameraShake.getBaseRotation(),s=0,n=Math.PI/2;a.yaw<n&&o>Math.PI+n?s=-Math.PI*2:o<n&&a.yaw>Math.PI+n&&(s=Math.PI*2),this.currentRotTween?.stop(),this.currentRotTween=new Le(a).to({pitch:r,yaw:o+s},100).onUpdate(i=>this.cameraShake.setBaseRotation(i.pitch,i.yaw-s)).start()}else{this.currentRotTween?.stop(),this.cameraShake.setBaseRotation(r,o);let{perspective:a}=this.playerStateReactive;if(a==="third_person_back"||a==="third_person_front"){let s=this.cameraObject.position,n=this.getThirdPersonCamera(new ee.Vector3(s.x,s.y,s.z),o,r),i=s.distanceTo(new ee.Vector3(n.x,n.y,n.z)),c=a==="third_person_back"?i:-i;this.camera.position.set(0,0,c),a==="third_person_front"?this.camera.rotation.set(0,Math.PI,0):this.camera.rotation.set(0,0,0)}else this.camera.position.set(0,0,0),this.camera.rotation.set(0,0,0),this.debugRaycastHelper&&(this.scene.remove(this.debugRaycastHelper),this.debugRaycastHelper=void 0),this.debugHitPoint&&(this.scene.remove(this.debugHitPoint),this.debugHitPoint=void 0)}this.updateCameraSectionPos()}}debugChunksVisibilityOverride(){let{chunksRenderAboveOverride:t,chunksRenderBelowOverride:o,chunksRenderDistanceOverride:r,chunksRenderAboveEnabled:a,chunksRenderBelowEnabled:s,chunksRenderDistanceEnabled:n}=this.reactiveDebugParams,i=this.getSectionHeight(),c=this.cameraSectionPos.y*i;if(this.displayOptions.inWorldRenderingConfig.enableDebugOverlay&&t!==void 0||o!==void 0||r!==void 0)for(let[_,u]of Object.entries(this.sectionObjects)){let[b,h,k]=_.split(",").map(Number),f=a&&t!==void 0?h<=c+t:s&&o!==void 0?h>=c-o:n&&r!==void 0?Math.abs(h-c)<=r:!0;u.visible=f}else for(let _ of Object.values(this.sectionObjects))_.visible=!0}render(t=!1){if(this.currentRenderedFrames++,this.reactiveDebugParams.stopRendering)return;this.debugChunksVisibilityOverride();let o=performance.now();this.lastRendered=performance.now(),this.cursorBlock.render(),this.updateSectionOffsets();let r=this.getCameraPosition();if(this.skyboxRenderer.update(r,this.viewDistance),t||this.displayOptions.inWorldRenderingConfig.fov!==this.camera.fov){let c=this.renderer.getSize(new ee.Vector2);this.camera.aspect=c.width/c.height,this.camera.fov=this.displayOptions.inWorldRenderingConfig.fov,this.camera.updateProjectionMatrix()}this.reactiveDebugParams.disableEntities||this.entities.render();let s=this.cameraGroupVr instanceof ee.Group?this.cameraGroupVr.children.find(c=>c instanceof ee.PerspectiveCamera):this.camera;this.renderer.render(this.scene,s),this.displayOptions.inWorldRenderingConfig.showHand&&this.playerStateReactive.gameMode!=="spectator"&&this.playerStateReactive.perspective==="first_person"&&!this.renderer.xr.isPresenting&&(this.holdingBlock.render(this.camera,this.renderer,this.ambientLight,this.directionalLight),this.holdingBlockLeft.render(this.camera,this.renderer,this.ambientLight,this.directionalLight));for(let c of this.fountains)this.sectionObjects[c.sectionId]&&!this.sectionObjects[c.sectionId].foutain&&(c.createParticles(this.sectionObjects[c.sectionId]),this.sectionObjects[c.sectionId].foutain=!0),c.render();this.waypoints.render(),this.fireworks.update();for(let c of this.onRender)c();let i=performance.now()-o;this.renderTimeAvgCount++,this.renderTimeAvg=(this.renderTimeAvg*(this.renderTimeAvgCount-1)+i)/this.renderTimeAvgCount,this.renderTimeMax=Math.max(this.renderTimeMax,i)}renderHead(t,o,r,a){let s;if(a.SkullOwner?s=a.SkullOwner.Properties?.textures?.[0]?.Value:s=a.profile?.properties?.find(n=>n.name==="textures")?.value,!!s)try{let i=JSON.parse(D.from(s,"base64").toString()).textures?.SKIN?.url,{skinTexturesProxy:c}=this.worldRendererConfig;c&&(i=i?.replace("http://textures.minecraft.net/",c).replace("https://textures.minecraft.net/",c));let _=yr(this,i,Ir.head),u=new ee.Group;return r&&_.position.set(0,.3125,.3125),_.position.y-=23/16,u.add(_),u.position.set(t.x+.5,t.y+.045,t.z+.5),u.rotation.set(0,-ee.MathUtils.degToRad(o*(r?90:45/2)),0),u.scale.set(.8,.8,.8),u}catch{}}renderSign(t,o,r,a,s){let n=this.getSignTexture(t,s,a);if(!n)return;let i=new ee.Mesh(new ee.PlaneGeometry(1,1),new ee.MeshBasicMaterial({map:n,transparent:!0}));i.renderOrder=999;let c=7/16,_=a?1.3:1;i.scale.set(1*_,c*_,1*_);let u=(a?2:1.5)/16,b=.25/16;r&&!a?i.position.set(0,0,-.5+u+b+1e-4):i.position.set(0,0,u/2+1e-4);let h=new ee.Group;h.rotation.set(0,-ee.MathUtils.degToRad(o*(r?90:45/2)),0),h.add(i);let k=(a?10:8)/16,f=(a?0:r?4.333:9.333)/16,y=k/2+f;return h.position.set(t.x+.5,t.y+y,t.z+.5),h}lightUpdate(t,o){for(let r=this.worldSizeParams.minY;r<this.worldSizeParams.worldHeight;r+=16)this.setSectionDirty(new ao(t,r,o))}rerenderAllChunks(){for(let t of Object.keys(this.sectionObjects)){let[o,r,a]=t.split(",").map(Number);this.setSectionDirty(new ao(o,r,a))}}updateShowChunksBorder(t){for(let o of Object.values(this.sectionObjects))for(let r of o.children)r.name==="helper"&&(r.visible=t)}resetWorld(){super.resetWorld(),this.worldBlockGeometry.resetWorld(),this.debugRaycastHelper&&(this.scene.remove(this.debugRaycastHelper),this.debugRaycastHelper=void 0),this.debugHitPoint&&(this.scene.remove(this.debugHitPoint),this.debugHitPoint=void 0)}getLoadedChunksRelative(t,o=!1){let[r,a,s]=Xa(t);return Object.fromEntries(Object.entries(this.sectionObjects).map(([n,i])=>{let[c,_,u]=n.split(",").map(Number),[b,h,k]=Xa({x:c,y:_,z:u});return[o?`${b-r},${h-a},${k-s}`:`${b-r},${k-s}`,i]}))}cleanChunkTextures(t,o){let r=this.chunkTextures.get(`${Math.floor(t/16)},${Math.floor(o/16)}`)??{};for(let a of Object.keys(r))r[a].dispose(),delete r[a]}readdChunks(){for(let t of Object.keys(this.sectionObjects))this.scene.remove(this.sectionObjects[t]);setTimeout(()=>{for(let t of Object.keys(this.sectionObjects))this.scene.add(this.sectionObjects[t])},500)}disableUpdates(t=this.scene.children){for(let o of t)o.matrixWorldNeedsUpdate=!1,this.disableUpdates(o.children??[])}removeColumn(t,o){super.removeColumn(t,o),this.cleanChunkTextures(t,o),this.worldBlockGeometry.removeColumn(t,o)}setSectionDirty(...t){let[o]=t;this.cleanChunkTextures(o.x,o.z),super.setSectionDirty(...t)}static getRendererInfo(t){try{let o=t.getContext();return`${o.getParameter(o.getExtension("WEBGL_debug_renderer_info").UNMASKED_RENDERER_WEBGL)}`}catch{}}worldStop(){this.media.onWorldStop()}destroy(){this.disposeModules(),this.fireworksLegacy.destroy(),super.destroy(),this.skyboxRenderer.dispose(),this.fireworks.dispose()}shouldObjectVisible(t){let r=this.getSectionHeight(),a=Math.floor(t.position.x/16)*16,s=Math.floor(t.position.z/16)*16,n=Math.floor(t.position.y/r)*r,i=`${a},${s}`,c=`${a},${n},${s}`;return!!this.finishedChunks[i]||!!this.sectionObjects[c]}handleUserClick(t){this.media.handleUserClick(t)}updateSectionOffsets(){let t=performance.now();for(let[o,r]of Object.entries(this.sectionsOffsetsAnimations)){let a=(t-r.time)/1e3;r.time=t,r.currentOffsetX+=r.speedX*a,r.currentOffsetY+=r.speedY*a,r.currentOffsetZ+=r.speedZ*a,r.limitX!==void 0&&(r.speedX>0?r.currentOffsetX=Math.min(r.currentOffsetX,r.limitX):r.currentOffsetX=Math.max(r.currentOffsetX,r.limitX)),r.limitY!==void 0&&(r.speedY>0?r.currentOffsetY=Math.min(r.currentOffsetY,r.limitY):r.currentOffsetY=Math.max(r.currentOffsetY,r.limitY)),r.limitZ!==void 0&&(r.speedZ>0?r.currentOffsetZ=Math.min(r.currentOffsetZ,r.limitZ):r.currentOffsetZ=Math.max(r.currentOffsetZ,r.limitZ));let s=this.sectionObjects[o];s&&(s.position.set(r.currentOffsetX,r.currentOffsetY,r.currentOffsetZ),s.updateMatrix())}}reloadWorld(){this.entities.reloadEntities()}};I();A();E();z();I();A();E();z();I();A();E();z();I();A();E();z();function gn(l){throw new Error("Node.js process "+l+" is not supported by JSPM core outside of Node.js")}var Ft=[],Or=!1,Yo,Sa=-1;function pk(){!Or||!Yo||(Or=!1,Yo.length?Ft=Yo.concat(Ft):Sa=-1,Ft.length&&od())}function od(){if(!Or){var l=setTimeout(pk,0);Or=!0;for(var e=Ft.length;e;){for(Yo=Ft,Ft=[];++Sa<e;)Yo&&Yo[Sa].run();Sa=-1,e=Ft.length}Yo=null,Or=!1,clearTimeout(l)}}function mk(l){var e=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)e[t-1]=arguments[t];Ft.push(new rd(l,e)),Ft.length===1&&!Or&&setTimeout(od,0)}function rd(l,e){this.fun=l,this.array=e}rd.prototype.run=function(){this.fun.apply(null,this.array)};var bk="browser",hk="x64",kk="browser",fk={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},gk=["/usr/bin/node"],vk=[],xk="v16.8.0",yk={},wk=function(l,e){},Ik=function(l){gn("binding")},Ak=function(l){return 0},zk=function(){return"/"},Ek=function(l){},Mk={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};function Ke(){}var Rk=Ke,Ok=[];function Sk(l){gn("_linkedBinding")}var Ck={},Tk=!1,Pk={};function Bk(l){gn("dlopen")}function jk(){return[]}function Hk(){return[]}var Dk=Ke,Nk=Ke,vn=function(){return{}},Gk=vn,Lk=vn,Wk=Ke,Uk=Ke,qk=Ke,Fk={};function Vk(l,e){if(!l)throw new Error(e||"assertion error")}var Yk={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},$k=Ke,Zk=Ke;function Kk(){return!1}var Jk=Ke,Xk=Ke,Qk=Ke,ef=Ke,tf=Ke,of=void 0,rf=void 0,lf=void 0,af=Ke,sf=2,nf=1,cf="/bin/usr/node",_f=9229,uf="node",df=[],pf=Ke,so={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};so.now===void 0&&(hn=Date.now(),so.timing&&so.timing.navigationStart&&(hn=so.timing.navigationStart),so.now=()=>Date.now()-hn);var hn;function mf(){return so.now()/1e3}var kn=1e9;function fn(l){var e=Math.floor((Date.now()-so.now())*.001),t=so.now()*.001,o=Math.floor(t)+e,r=Math.floor(t%1*1e9);return l&&(o=o-l[0],r=r-l[1],r<0&&(o--,r+=kn)),[o,r]}fn.bigint=function(l){var e=fn(l);return typeof BigInt>"u"?e[0]*kn+e[1]:BigInt(e[0]*kn)+BigInt(e[1])};var bf=10,hf={},kf=0;function no(){return xn}var ff=no,gf=no,vf=no,xf=no,yf=no,wf=Ke,If=no,Af=no;function zf(l){return[]}var xn={version:xk,versions:yk,arch:hk,platform:kk,release:Mk,_rawDebug:Rk,moduleLoadList:Ok,binding:Ik,_linkedBinding:Sk,_events:hf,_eventsCount:kf,_maxListeners:bf,on:no,addListener:ff,once:gf,off:vf,removeListener:xf,removeAllListeners:yf,emit:wf,prependListener:If,prependOnceListener:Af,listeners:zf,domain:Ck,_exiting:Tk,config:Pk,dlopen:Bk,uptime:mf,_getActiveRequests:jk,_getActiveHandles:Hk,reallyExit:Dk,_kill:Nk,cpuUsage:vn,resourceUsage:Gk,memoryUsage:Lk,kill:Wk,exit:Uk,openStdin:qk,allowedNodeEnvironmentFlags:Fk,assert:Vk,features:Yk,_fatalExceptions:$k,setUncaughtExceptionCaptureCallback:Zk,hasUncaughtExceptionCaptureCallback:Kk,emitWarning:wk,nextTick:mk,_tickCallback:Jk,_debugProcess:Xk,_debugEnd:Qk,_startProfilerIdleNotifier:ef,_stopProfilerIdleNotifier:tf,stdout:of,stdin:lf,stderr:rf,abort:af,umask:Ak,chdir:Ek,cwd:zk,env:fk,title:bk,argv:gk,execArgv:vk,pid:sf,ppid:nf,execPath:cf,debugPort:_f,hrtime:fn,argv0:uf,_preload_modules:df,setSourceMapsEnabled:pf};var yn={},ld=!1;function Ef(){if(ld)return yn;ld=!0;var l=xn;function e(a){if(typeof a!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(a))}function t(a,s){for(var n="",i=0,c=-1,_=0,u,b=0;b<=a.length;++b){if(b<a.length)u=a.charCodeAt(b);else{if(u===47)break;u=47}if(u===47){if(!(c===b-1||_===1))if(c!==b-1&&_===2){if(n.length<2||i!==2||n.charCodeAt(n.length-1)!==46||n.charCodeAt(n.length-2)!==46){if(n.length>2){var h=n.lastIndexOf("/");if(h!==n.length-1){h===-1?(n="",i=0):(n=n.slice(0,h),i=n.length-1-n.lastIndexOf("/")),c=b,_=0;continue}}else if(n.length===2||n.length===1){n="",i=0,c=b,_=0;continue}}s&&(n.length>0?n+="/..":n="..",i=2)}else n.length>0?n+="/"+a.slice(c+1,b):n=a.slice(c+1,b),i=b-c-1;c=b,_=0}else u===46&&_!==-1?++_:_=-1}return n}function o(a,s){var n=s.dir||s.root,i=s.base||(s.name||"")+(s.ext||"");return n?n===s.root?n+i:n+a+i:i}var r={resolve:function(){for(var s="",n=!1,i,c=arguments.length-1;c>=-1&&!n;c--){var _;c>=0?_=arguments[c]:(i===void 0&&(i=l.cwd()),_=i),e(_),_.length!==0&&(s=_+"/"+s,n=_.charCodeAt(0)===47)}return s=t(s,!n),n?s.length>0?"/"+s:"/":s.length>0?s:"."},normalize:function(s){if(e(s),s.length===0)return".";var n=s.charCodeAt(0)===47,i=s.charCodeAt(s.length-1)===47;return s=t(s,!n),s.length===0&&!n&&(s="."),s.length>0&&i&&(s+="/"),n?"/"+s:s},isAbsolute:function(s){return e(s),s.length>0&&s.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var s,n=0;n<arguments.length;++n){var i=arguments[n];e(i),i.length>0&&(s===void 0?s=i:s+="/"+i)}return s===void 0?".":r.normalize(s)},relative:function(s,n){if(e(s),e(n),s===n||(s=r.resolve(s),n=r.resolve(n),s===n))return"";for(var i=1;i<s.length&&s.charCodeAt(i)===47;++i);for(var c=s.length,_=c-i,u=1;u<n.length&&n.charCodeAt(u)===47;++u);for(var b=n.length,h=b-u,k=_<h?_:h,f=-1,y=0;y<=k;++y){if(y===k){if(h>k){if(n.charCodeAt(u+y)===47)return n.slice(u+y+1);if(y===0)return n.slice(u+y)}else _>k&&(s.charCodeAt(i+y)===47?f=y:y===0&&(f=0));break}var v=s.charCodeAt(i+y),x=n.charCodeAt(u+y);if(v!==x)break;v===47&&(f=y)}var R="";for(y=i+f+1;y<=c;++y)(y===c||s.charCodeAt(y)===47)&&(R.length===0?R+="..":R+="/..");return R.length>0?R+n.slice(u+f):(u+=f,n.charCodeAt(u)===47&&++u,n.slice(u))},_makeLong:function(s){return s},dirname:function(s){if(e(s),s.length===0)return".";for(var n=s.charCodeAt(0),i=n===47,c=-1,_=!0,u=s.length-1;u>=1;--u)if(n=s.charCodeAt(u),n===47){if(!_){c=u;break}}else _=!1;return c===-1?i?"/":".":i&&c===1?"//":s.slice(0,c)},basename:function(s,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');e(s);var i=0,c=-1,_=!0,u;if(n!==void 0&&n.length>0&&n.length<=s.length){if(n.length===s.length&&n===s)return"";var b=n.length-1,h=-1;for(u=s.length-1;u>=0;--u){var k=s.charCodeAt(u);if(k===47){if(!_){i=u+1;break}}else h===-1&&(_=!1,h=u+1),b>=0&&(k===n.charCodeAt(b)?--b===-1&&(c=u):(b=-1,c=h))}return i===c?c=h:c===-1&&(c=s.length),s.slice(i,c)}else{for(u=s.length-1;u>=0;--u)if(s.charCodeAt(u)===47){if(!_){i=u+1;break}}else c===-1&&(_=!1,c=u+1);return c===-1?"":s.slice(i,c)}},extname:function(s){e(s);for(var n=-1,i=0,c=-1,_=!0,u=0,b=s.length-1;b>=0;--b){var h=s.charCodeAt(b);if(h===47){if(!_){i=b+1;break}continue}c===-1&&(_=!1,c=b+1),h===46?n===-1?n=b:u!==1&&(u=1):n!==-1&&(u=-1)}return n===-1||c===-1||u===0||u===1&&n===c-1&&n===i+1?"":s.slice(n,c)},format:function(s){if(s===null||typeof s!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof s);return o("/",s)},parse:function(s){e(s);var n={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return n;var i=s.charCodeAt(0),c=i===47,_;c?(n.root="/",_=1):_=0;for(var u=-1,b=0,h=-1,k=!0,f=s.length-1,y=0;f>=_;--f){if(i=s.charCodeAt(f),i===47){if(!k){b=f+1;break}continue}h===-1&&(k=!1,h=f+1),i===46?u===-1?u=f:y!==1&&(y=1):u!==-1&&(y=-1)}return u===-1||h===-1||y===0||y===1&&u===h-1&&u===b+1?h!==-1&&(b===0&&c?n.base=n.name=s.slice(1,h):n.base=n.name=s.slice(b,h)):(b===0&&c?(n.name=s.slice(1,u),n.base=s.slice(1,h)):(n.name=s.slice(b,u),n.base=s.slice(b,h)),n.ext=s.slice(u,h)),b>0?n.dir=s.slice(0,b-1):c&&(n.dir="/"),n},sep:"/",delimiter:":",win32:null,posix:null};return r.posix=r,yn=r,yn}var Je=Ef();var jO=Je._makeLong,HO=Je.basename,DO=Je.delimiter,NO=Je.dirname,GO=Je.extname,LO=Je.format,WO=Je.isAbsolute,wn=Je.join,UO=Je.normalize,qO=Je.parse,FO=Je.posix,VO=Je.relative,YO=Je.resolve,$O=Je.sep,ZO=Je.win32;import*as he from"three";I();A();E();z();import Mf from"prismarine-world";import Rf from"prismarine-chunk";var ad=l=>{let e=Mf(l),t=Rf(l),o=new e(l).sync,r=Of(o);for(let a of r)if(a.startsWith("set")&&a!=="setColumn"){let s=o[a].bind(o);o[a]=(...n)=>{let i=n[0];i.x!==void 0&&!o.getColumnAt(i)&&o.setColumn(Math.floor(i.x/16),Math.floor(i.z/16),new t(void 0)),s(...n)}}return o};function Of(l){let e=new Set,t=l;do for(let o of Object.getOwnPropertyNames(t))typeof l[o]=="function"&&o!=="constructor"&&e.add(o);while(t=Object.getPrototypeOf(t));return[...e]}import{Vec3 as nd}from"vec3";I();A();E();z();var sd="1.21.4";var In=new Date,id=In.getMonth()===11&&In.getDate()>=24&&In.getDate()<=26,Sf=["panorama_3.webp","panorama_1.webp","panorama_4.webp","panorama_5.webp","panorama_0.webp","panorama_2.webp"],Ca=class{constructor(e,t,o=!1){this.documentRenderer=e;this.options=t;this.doWorldBlocksPanorama=o;p(this,"camera");p(this,"scene");p(this,"ambientLight");p(this,"directionalLight");p(this,"panoramaGroup",null);p(this,"time",0);p(this,"abortController",new AbortController);p(this,"worldRenderer");p(this,"WorldRendererClass",Vo);p(this,"startTimes",new Map);this.scene=new he.Scene,this.scene.background=new he.Color(3294568),this.ambientLight=new he.AmbientLight(13421772),this.scene.add(this.ambientLight),this.directionalLight=new he.DirectionalLight(16777215,.5),this.directionalLight.position.set(1,1,.5).normalize(),this.directionalLight.castShadow=!0,this.scene.add(this.directionalLight),this.camera=new he.PerspectiveCamera(85,this.documentRenderer.canvas.width/this.documentRenderer.canvas.height,.05,1e3),this.camera.position.set(0,0,0),this.camera.rotation.set(0,0,0)}async start(){this.doWorldBlocksPanorama?await this.worldBlocksPanorama():this.addClassicPanorama(),this.documentRenderer.render=(e=!1)=>{e&&(this.camera.aspect=this.documentRenderer.canvas.width/this.documentRenderer.canvas.height,this.camera.updateProjectionMatrix()),this.documentRenderer.renderer.render(this.scene,this.camera)}}async debugImageInFrontOfCamera(){let e=await to(wn("background","panorama_0.webp")),t=new he.Mesh(new he.PlaneGeometry(1e3,1e3),new he.MeshBasicMaterial({map:e}));t.position.set(0,0,-500),t.rotation.set(0,0,0),this.scene.add(t)}addClassicPanorama(){let e=new he.BoxGeometry(1e3,1e3,1e3),t=[],o=200;for(let s of Sf)(async()=>{let{texture:i}=Yl(wn("background",id?"christmas":"",s));i.matrixAutoUpdate=!1,i.matrix.set(-1,0,1,0,1,0,0,0,1),i.wrapS=he.ClampToEdgeWrapping,i.wrapT=he.ClampToEdgeWrapping,i.minFilter=he.LinearFilter,i.magFilter=he.LinearFilter;let c=new he.MeshBasicMaterial({map:i,transparent:!0,side:he.DoubleSide,depthWrite:!1,opacity:0});this.startTimes.set(c,Date.now()),t.push(c)})();let r=new he.Mesh(e,t);r.onBeforeRender=()=>{this.time+=.01,r.rotation.y=Math.PI+this.time*.01,r.rotation.z=Math.sin(-this.time*.001)*.001;for(let s of t){let n=this.startTimes.get(s);if(n){let i=Date.now()-n,c=Math.min(1,i/o);s.opacity=c}}};let a=new he.Object3D;if(a.add(r),!id)for(let s=0;s<20;s++){let n=new Ut("1.16.4","squid").mesh;n.position.set(Math.random()*30-15,Math.random()*20-10,Math.random()*10-17),n.rotation.set(0,Math.PI+Math.random(),-Math.PI/4,"ZYX");let i=Math.random()*.01;n.children[0].onBeforeRender=()=>{n.rotation.y+=i,n.rotation.z=Math.cos(r.rotation.y*3)*Math.PI/4-Math.PI/2},a.add(n)}this.scene.add(a),this.panoramaGroup=a}async worldBlocksPanorama(){let e=sd,t=new Dt;if(t.currentConfig={version:e,noInventoryGui:!0},await t.updateAssetsData?.({}),this.abortController.signal.aborted)return;let o=ad(e),a=fd("prismarine-block")(e),n=globalThis.mcData.blocksArray.filter(v=>{if(!v.name.includes("stained_glass"))return!1;let x=a.fromStateId(v.defaultState,0);if(x.shapes?.length!==1)return!1;let R=x.shapes[0];return R[0]===0&&R[1]===0&&R[2]===0&&R[3]===1&&R[4]===1&&R[5]===1}),i=-15,c=100,_=100;for(let v=-c;v<c;v++)for(let x=-_;x<_;x++){let R=n[Math.floor(Math.random()*n.length)];o.setBlockStateId(new nd(v,x,i),R.defaultState)}this.camera.updateProjectionMatrix(),this.camera.position.set(.5,_/2+.5,.5),this.camera.rotation.set(0,0,0);let u=new nd(...this.camera.position.toArray()),b=new ko(o,2,u);if(this.abortController.signal.aborted||(this.worldRenderer=new this.WorldRendererClass(this.documentRenderer.renderer,this.options,{version:e,worldView:b,inWorldRenderingConfig:Hr,playerStateReactive:Qi().reactive,rendererState:po().reactive,nonReactiveState:po().nonReactive,resourcesManager:t}),this.worldRenderer instanceof Vo&&(this.scene=this.worldRenderer.scene),b.init(u),await this.worldRenderer.waitForChunksToRender(),this.abortController.signal.aborted))return;let{camera:h}=this,k=h.position.x,f=h.position.y,y;document.body.addEventListener("pointermove",v=>{if(v.pointerType!=="mouse")return;let x=new he.Vector2(v.clientX,v.clientY),R=.2,M=x.x/window.innerWidth-.5,O=-(x.y/window.innerHeight-.5);y?.stop();let T={x:k+M*R,y:f+O*R};y=new Le(h.position).to(T,0),y.start(),h.updateProjectionMatrix()},{signal:this.abortController.signal})}dispose(){this.scene.clear(),this.worldRenderer?.destroy(),this.abortController.abort()}};kl.ColorManagement.enabled=!1;globalThis.THREE=kl;var cd=l=>({updateMap:l.entities.updateMap.bind(l.entities),updateCustomBlock:l.updateCustomBlock.bind(l),getBlockInfo:l.getBlockInfo.bind(l),playEntityAnimation:l.entities.playAnimation.bind(l.entities),damageEntity:l.entities.handleDamageEvent.bind(l.entities),updatePlayerSkin:l.entities.updatePlayerSkin.bind(l.entities),changeHandSwingingState:l.changeHandSwingingState.bind(l),getHighestBlocks:l.getHighestBlocks.bind(l),reloadWorld:l.reloadWorld.bind(l),updateEntityModel:l.entities.updateEntityModel.bind(l.entities),playEntityModelAnimation:l.entities.playEntityModelAnimation.bind(l.entities),addMedia:l.media.addMedia.bind(l.media),destroyMedia:l.media.destroyMedia.bind(l.media),setControlMode:l.media.setControlMode.bind(l.media),setVideoPlaying:l.media.setVideoPlaying.bind(l.media),setVideoSeeking:l.media.setVideoSeeking.bind(l.media),setVideoVolume:l.media.setVideoVolume.bind(l.media),setVideoSpeed:l.media.setVideoSpeed.bind(l.media),handleUserClick:l.media.handleUserClick.bind(l.media),addSectionAnimation(e,t){l.sectionsOffsetsAnimations[e]=t},removeSectionAnimation(e){delete l.sectionsOffsetsAnimations[e]},shakeFromDamage:l.cameraShake.shakeFromDamage.bind(l.cameraShake),onPageInteraction:l.media.onPageInteraction.bind(l.media),downloadMesherLog:l.downloadMesherLog.bind(l),explodeFirework:l.fireworksLegacy.explode.bind(l.fireworksLegacy),explodeFireworkFacingCamera:l.fireworksLegacy.explodeFacingCamera.bind(l.fireworksLegacy),addWaypoint:l.waypoints.addWaypoint.bind(l.waypoints),removeWaypoint:l.waypoints.removeWaypoint.bind(l.waypoints),startCinimaticScript:l.cinimaticScript.startScript.bind(l.cinimaticScript),stopCinimaticScript:l.cinimaticScript.stopScript.bind(l.cinimaticScript),launchFirework:l.fireworks.launchFirework.bind(l.fireworks),setSkyboxImage:l.skyboxRenderer.setSkyboxImage.bind(l.skyboxRenderer),setRain:e=>l.toggleModule("rain",e),async loadGeometryExport(e){let{applyWorldGeometryExport:t}=await Promise.resolve().then(()=>(sn(),Fu));return t(l,e)}}),Tf=[],Ta=(l,...e)=>{for(let t of Object.values(globalThis.loadedMods??{}))try{t.threeJsBackendModule?.[l]?.(...e)}catch(o){let r=`[mod three.js] Error calling ${l} on ${t.name}: ${o}`;throw new Error(r)}},_d=()=>{let l,e=null,t=null,o=null,r=null,a=(_,u)=>{Oe?l=Nl(_,Tf,globalThis):l=_,e=new Zr(l,u?.canvas),globalThis.renderer=e.renderer,globalThis.documentRenderer=e,globalThis.threeJsBackend=c,Ta("default",c)},s=async()=>{if(!e)throw new Error("Document renderer not initialized");if(!o&&!t){let _={...l};t=new Ca(e,_,!!H.env.SINGLE_FILE_BUILD_MODE),globalThis.panoramaRenderer=t,Ta("panoramaCreated",t),await t.start(),Ta("panoramaReady",t)}},n=async _=>{let b=Oe?Nl(_,[Dt,ho],globalThis):_;if(!e)throw new Error("Document renderer not initialized");e.nonReactiveState=b.nonReactiveState,globalThis.resourcesManager=b.resourcesManager,t&&(t.dispose(),t=null),o=new Vo(e.renderer,l,b),await o.worldReadyPromise,r=new Gl(b.nonReactiveState),globalThis.frameTimingCollector=r;let h=e.render;e.render=function(k){h.call(this,k),r?.markFrameStart(),b.inWorldRenderingConfig.paused||o?.render(k),r?.markFrameEnd(),r?.markFrameDisplay()},e.inWorldRenderingConfig=b.inWorldRenderingConfig,globalThis.world=o,Ta("worldReady",o)},i=()=>{t&&(t.dispose(),t=null),e&&e.dispose(),o&&(o.destroy(),o=null)},c={id:"threejs",displayName:`three.js ${kl.REVISION}`,startPanorama:s,startWorld:n,disconnect:i,setRendering(_){e.setPaused(!_),o&&(o.renderingActive=_)},getDebugOverlay:()=>({get entitiesString(){return o?.entities.getDebugString()}}),updateCamera(_,u,b){r?.markCameraUpdate(!_),o?.setFirstPersonCamera(_,u,b)},get soundSystem(){return o?.soundSystem},get backendMethods(){if(o)return cd(o)}};return{main:{init:a,backend:c},workerProxy(){return Dc({init(_,u){a(_,{canvas:u})},updateSizeExternal(_,u,b){e?.updateSizeExternal(_,u,b)},startPanorama:s,startWorld:n,disconnect:i,setRendering:c.setRendering,updateCamera(_,u,b){let h=_?new Cf(_.x,_.y,_.z):null;r?.markCameraUpdate(!h),c.updateCamera(h,u,b)},async callBackendMethod(_,...u){if(!o)throw new Error("World renderer not initialized");let h=cd(o)[_];if(!h)throw new Error(`Backend method ${String(_)} is unavailable`);return h(...u)}})}}};var Pa=l=>{let{main:e}=_d();return e.init(l),e.backend};Pa.id="threejs";Pa.displayName="three.js Blocking";Pa.description="Simple, old and stable main thread graphics backend providing balanced performance on top of WebGL2.";I();A();E();z();import*as ud from"three";function Pf(l){let e="threeWorker.js",t;if(H.env.SINGLE_FILE_BUILD){let o=document.getElementById("three-worker-code").textContent,r=new Blob([o],{type:"text/javascript"});t=new Worker(window.URL.createObjectURL(r))}else t=new Worker(e);return t.onmessage=({data:o})=>{l(o)},t.on&&t.on("message",o=>{t.onmessage({data:o})}),t}var Ba=async l=>{let e=Pf(()=>{}),t=Nc(e),o=rs();o.onSizeChanged((n,i)=>{t.updateSizeExternal(n,i,window.devicePixelRatio||1)});let r=Dl(l,e);try{t.init(r,o.canvas)}catch(n){throw Fr(r),n}let a=new Proxy({},{get(n,i){if(typeof i=="string")return async(...c)=>t.callBackendMethod(i,...c)}});return{id:"threejs",displayName:`three.js ${ud.REVISION}`,async startPanorama(){},async startWorld(n){let i={...$r,items:"itemsArray",entities:"entitiesArray"};ms([e],n.version,i,n.resourcesManager.currentResources.mcData),n.inWorldRenderingConfig.__syncToWorker=!0,n.playerStateReactive&&(n.playerStateReactive.__syncToWorker=!0),n.rendererState&&(n.rendererState.__syncFromWorker=!0),n.nonReactiveState&&(n.nonReactiveState.__syncFromWorker=!0),n.nonReactiveState.__syncFromWorkerInterval=200;let c=Dl(n,e);try{await t.startWorld(structuredClone(c))}catch(u){throw Fr(c),u}t.updateSizeExternal(o.size.width,o.size.height,window.devicePixelRatio||1);let _=_r("fps");setInterval(()=>{let{fps:u,avgRenderTime:b,worstRenderTime:h}=n.nonReactiveState;_.updateText(`FPS: ${u.toFixed(0)} (${b.toFixed(0)}ms/${h.toFixed(0)}ms)`),n.nonReactiveState.fps=0},1e3)},disconnect(){o.destroy(),t.disconnect(),e.terminate()},setRendering(n){t.setRendering(n)},updateCamera(n,i,c){t.updateCamera(n?{x:n.x,y:n.y,z:n.z}:null,i,c)},soundSystem:void 0,backendMethods:a}};Ba.id="threejs-off-thread";Ba.displayName="three.js Multi-thread";Ba.description=["Edge-cutting technology that uses a dedicated thread for graphics.","Slightly higher power and RAM usage.","More stable FPS (mid-range devices), but possible inputlag if TPS is low.","On low-end devices it might result in device throttling and stuttering."].join(" ");export{Sc as AppViewer,Zr as DocumentRenderer,ir as LoadedResourcesTransferrable,Dt as ResourcesManager,ko as WorldView,ho as WorldViewWorker,rs as addCanvasForWorker,Xo as chunkPos,Ba as createGraphicsBackendOffThread,Pa as createGraphicsBackendSingleThread,u5 as createWorldRendererConfig,Ji as defaultGraphicsBackendConfig,Hr as defaultWorldRendererConfig,tc as delayedIterator,po as getDefaultRendererState,Cc as getInitialPlayerState,pm as getInitialPlayerStateRenderer,dm as getPlayerStateUtils,Oe as isWebWorker,Ad as sectionPos};
|
|
21790
|
+
}`})}},bn=class{constructor(e){this.worldRenderer=e;p(this,"points");p(this,"clock",new Se.Clock);p(this,"enabled",!1);p(this,"currentTime");p(this,"enablementCheck",()=>this.currentTime?this.currentTime>13500&&this.currentTime<23e3:!1);p(this,"render",e=>{this.points&&(this.points.position.copy(this.worldRenderer.getCameraPosition()),this.points.material.uniforms.time.value=this.clock.getElapsedTime()*.2)})}enable(){this.enabled||(this.enabled=!0,this.updateVisibility())}disable(){this.enabled&&(this.enabled=!1,this.removeStars())}toggle(){return this.enabled?this.disable():this.enable(),this.enabled}updateTimeOfDay(e){this.currentTime=e,this.enabled&&this.updateVisibility()}updateVisibility(){if(!this.enabled)return;let e=this.enablementCheck?.()??!1;e&&!this.points?this.createStars():!e&&this.points&&this.removeStars()}createStars(){if(this.points)return;let e=80,t=50,o=7e3,r=7,a=10,s=new Se.BufferGeometry,n=f=>new Se.Vector3().setFromSpherical(new Se.Spherical(f,Math.acos(1-Math.random()*2),Math.random()*2*Math.PI)),i=[],c=[],_=Array.from({length:o},()=>(.5+.5*Math.random())*r),u=new Se.Color,b=e+t,h=t/o;for(let f=0;f<o;f++)b-=h*Math.random(),i.push(...n(b).toArray()),u.setHSL(f/o,a,.9),c.push(u.r,u.g,u.b);s.setAttribute("position",new Se.Float32BufferAttribute(i,3)),s.setAttribute("color",new Se.Float32BufferAttribute(c,3)),s.setAttribute("size",new Se.Float32BufferAttribute(_,1));let k=new mn;k.blending=Se.AdditiveBlending,k.depthTest=!1,k.transparent=!0,this.points=new Se.Points(s,k),this.points.renderOrder=-1,this.worldRenderer.scene.add(this.points)}dispose(){this.removeStars()}removeStars(){this.points&&(this.points.geometry.dispose(),this.points.material.dispose(),this.worldRenderer.scene.remove(this.points),this.points=void 0)}},ed={id:"starfield",controller:bn,enabledDefault:!0,cannotBeDisabled:!0};var td={starfield:ed,futuristicReveal:Qu,rain:Ju};var Vo=class l extends Zl{constructor(t,o,r){if(!r.resourcesManager)throw new Error("resourcesManager is required in displayOptions");super(r.resourcesManager,r,o);this.renderer=t;this.initOptions=o;this.displayOptions=r;p(this,"outputFormat","threeJs");p(this,"worldBlockGeometry");p(this,"chunkTextures",new Map);p(this,"signsCache",new Map);p(this,"cameraSectionPos",new ao(0,0,0));p(this,"holdingBlock");p(this,"holdingBlockLeft");p(this,"scene",new ee.Scene);p(this,"ambientLight",new ee.AmbientLight(13421772));p(this,"directionalLight",new ee.DirectionalLight(16777215,.5));p(this,"entities",new pa(this,globalThis.mcData));p(this,"cameraGroupVr");p(this,"material",new ee.MeshLambertMaterial({vertexColors:!0,transparent:!0,alphaTest:.1}));p(this,"itemsTexture");p(this,"cursorBlock");p(this,"onRender",[]);p(this,"lastRenderTime",0);p(this,"cameraShake");p(this,"cameraContainer");p(this,"media");p(this,"waypoints");p(this,"cinimaticScript");p(this,"camera");p(this,"renderTimeAvg",0);p(this,"modules",{});p(this,"sectionsOffsetsAnimations",{});p(this,"fountains",[]);p(this,"fireworksLegacy");p(this,"DEBUG_RAYCAST",!1);p(this,"skyboxRenderer");p(this,"fireworks");p(this,"currentPosTween");p(this,"currentRotTween");p(this,"debugOverlayAdded",!1);p(this,"debugRaycastHelper");p(this,"debugHitPoint");p(this,"prevFramePerspective",null);this.renderer=t,r.rendererState.renderer=l.getRendererInfo(t)??"...",this.worldBlockGeometry=new Ma(this,this.scene,this.material,r),this.cursorBlock=new ma(this),this.holdingBlock=new fr(this),this.holdingBlockLeft=new fr(this,!0);for(let a of Object.values(td))this.registerModule(a);this.skyboxRenderer=new wa(this.scene,!1,null),this.skyboxRenderer.init(),this.addDebugOverlay(),this.resetScene(),this.init(),this.soundSystem=new ha(this),this.cameraShake=new ka(this,this.onRender),this.media=new fa(this),this.fireworksLegacy=new xa(this),this.waypoints=new va(this),this.cinimaticScript=new ya(this,(a,s,n)=>this.setCinimaticCamera(a,s,n),a=>this.setCinimaticFov(a),()=>({position:new ao(this.cameraObject.position.x,this.cameraObject.position.y,this.cameraObject.position.z),yaw:this.cameraShake.getBaseRotation().yaw,pitch:this.cameraShake.getBaseRotation().pitch,fov:this.camera.fov})),this.fireworks=new Ia(this.scene),this.renderUpdateEmitter.on("chunkFinished",a=>{this.finishChunk(a)}),this.worldSwitchActions(),this.initializeModules()}get sectionObjects(){return this.worldBlockGeometry.sectionObjects}get waitingChunksToDisplay(){return this.worldBlockGeometry.waitingChunksToDisplay}get estimatedMemoryUsage(){return this.worldBlockGeometry.estimatedMemoryUsage}get tilesRendered(){return Object.values(this.sectionObjects).reduce((t,o)=>t+o.tilesCount,0)}get blocksRendered(){return Object.values(this.sectionObjects).reduce((t,o)=>t+o.blocksCount,0)}registerModule(t){if(t.id in this.modules)return;let o=new t.controller(this),r={manifest:t,controller:o,enabled:!1,toggle:()=>this.toggleModule(t.id)};this.modules[t.id]=r,t.enabledDefault&&this.toggleModule(t.id,!0)}enableModule(t){let o=this.modules[t];o&&(o.enabled||(o.enabled=!0,o.controller.enable(),o.controller.render&&this.onRender.push(o.controller.render)))}disableModule(t){let o=this.modules[t];if(o&&!o.manifest.cannotBeDisabled&&o.enabled&&(o.enabled=!1,o.controller.disable(),o.controller.render)){let r=this.onRender.indexOf(o.controller.render);r>-1&&this.onRender.splice(r,1)}}toggleModule(t,o){let r=this.modules[t];if(!r)return!1;let a=o!==void 0?o:!r.enabled;if(a===r.enabled)return r.enabled;if(!a&&r.manifest.cannotBeDisabled)return!0;if(r.enabled=a,a)r.controller.enable(),r.controller.render&&!this.onRender.includes(r.controller.render)&&this.onRender.push(r.controller.render);else if(r.controller.disable(),r.controller.render){let s=this.onRender.indexOf(r.controller.render);s>-1&&this.onRender.splice(s,1)}return a}disposeModules(){for(let t of Object.values(this.modules))t.controller.dispose();this.modules={}}initializeModules(){this.updateModulesFromConfig()}getModule(t){return this.modules[t]?.controller}anyModuleRequiresHeightmap(){return Object.values(this.modules).some(t=>t.enabled&&t.manifest.requiresHeightmap)}get cameraObject(){return this.cameraGroupVr??this.cameraContainer}worldSwitchActions(){this.onWorldSwitched.push(()=>{this.protocolCustomBlocks.clear(),this.sectionsOffsetsAnimations={},this.waypoints.clear(),this.cinimaticScript.stopScript(),this.fireworks.clear()})}downloadWorldGeometry(){an(this,this.cameraObject.position,this.cameraShake.getBaseRotation(),"world-geometry.json")}updateEntity(t,o=!1){let r={rotation:{head:{x:t.headPitch??t.pitch,y:t.headYaw,z:0}}};o?this.entities.updateEntityPosition(t,!1,r):this.entities.update(t,r)}updatePlayerEntity(t){this.entities.handlePlayerEntity(t)}resetScene(){this.scene.matrixAutoUpdate=!1,this.scene.background=new ee.Color(this.initOptions.config.sceneBackground),this.scene.add(this.ambientLight),this.directionalLight.position.set(1,1,.5).normalize(),this.directionalLight.castShadow=!0,this.scene.add(this.directionalLight);let t=this.renderer.getSize(new ee.Vector2);this.camera=new ee.PerspectiveCamera(75,t.x/t.y,.1,1e3),this.cameraContainer=new ee.Object3D,this.cameraContainer.add(this.camera),this.scene.add(this.cameraContainer)}watchReactivePlayerState(){super.watchReactivePlayerState(),this.onReactivePlayerStateUpdated("inWater",t=>{this.skyboxRenderer.updateWaterState(t,this.playerStateReactive.waterBreathing)}),this.onReactivePlayerStateUpdated("waterBreathing",t=>{this.skyboxRenderer.updateWaterState(this.playerStateReactive.inWater,t)}),this.onReactivePlayerStateUpdated("ambientLight",t=>{t&&(this.ambientLight.intensity=t)}),this.onReactivePlayerStateUpdated("directionalLight",t=>{t&&(this.directionalLight.intensity=t)}),this.onReactivePlayerStateUpdated("lookingAtBlock",t=>{this.cursorBlock.setHighlightCursorBlock(t?new ao(t.x,t.y,t.z):null,t?.shapes)}),this.onReactivePlayerStateUpdated("diggingBlock",t=>{this.cursorBlock.updateBreakAnimation(t?{x:t.x,y:t.y,z:t.z}:void 0,t?.stage??null,t?.mergedShape)}),this.onReactivePlayerStateUpdated("perspective",t=>{let o=new ao(this.cameraObject.position.x,this.cameraObject.position.y,this.cameraObject.position.z);this.updateCamera(o,this.cameraShake.getBaseRotation().yaw,this.cameraShake.getBaseRotation().pitch)})}watchReactiveConfig(){super.watchReactiveConfig(),this.onReactiveConfigUpdated("showChunkBorders",t=>{this.updateShowChunksBorder(t)}),this.onReactiveConfigUpdated("defaultSkybox",t=>{this.skyboxRenderer.updateDefaultSkybox(t)}),this.onReactiveConfigUpdated("*",()=>{this.updateModulesFromConfig()}),this.updateModulesFromConfig()}updateModulesFromConfig(){let{moduleStates:t}=this.worldRendererConfig;for(let[o,r]of Object.entries(this.modules)){let a=t[o];if(a==="enabled"){r.enabled||this.toggleModule(o,!0);continue}if(a==="disabled"){r.enabled&&!r.manifest.cannotBeDisabled&&this.toggleModule(o,!1);continue}if(a==="auto"||a===void 0)if(r.controller.autoEnableCheck){let s=r.controller.autoEnableCheck();s&&!r.enabled?this.toggleModule(o,!0):!s&&r.enabled&&!r.manifest.cannotBeDisabled&&this.toggleModule(o,!1)}else{let s=r.manifest.enabledDefault??!1;s&&!r.enabled?this.toggleModule(o,!0):!s&&r.enabled&&!r.manifest.cannotBeDisabled&&this.toggleModule(o,!1)}}}changeHandSwingingState(t,o=!1){let r=o?this.holdingBlockLeft:this.holdingBlock;t?r.startSwing():r.stopSwing()}async updateAssetsData(){let t=this.resourcesManager.currentResources,o=this.material.map,r=this.itemsTexture,a=ds(t.blocksAtlasImage);a.needsUpdate=!0,a.flipY=!1,this.material.map=a;let s=ds(t.itemsAtlasImage);s.needsUpdate=!0,s.flipY=!1,this.itemsTexture=s,o&&o.dispose(),r&&r.dispose(),await super.updateAssetsData(),this.onAllTexturesLoaded(),Object.keys(this.loadedChunks).length>0&&this.rerenderAllChunks()}onAllTexturesLoaded(){this.holdingBlock.ready=!0,this.holdingBlock.updateItem(),this.holdingBlockLeft.ready=!0,this.holdingBlockLeft.updateItem()}changeBackgroundColor(t){this.scene.background=new ee.Color(t[0],t[1],t[2])}timeUpdated(t){let o=this.getModule("starfield");o?.updateTimeOfDay&&o.updateTimeOfDay(t),this.skyboxRenderer.updateTime(t)}biomeUpdated(t){t?.temperature!==void 0&&this.skyboxRenderer.updateTemperature(t.temperature)}biomeReset(){this.skyboxRenderer.updateTemperature(on)}getItemRenderData(t,o){return Nu(t,o,this.resourcesManager,this.playerStateReactive)}async demoModel(){let t=cursorBlockRel(0,1,0).position,o=await sl();s_(o,t);let r=new ee.BoxHelper(o,16776960);o.add(r),this.scene.add(o)}demoItem(){let t=cursorBlockRel(0,1,0).position,{mesh:o}=this.entities.getItemMesh({itemId:541},{});o.position.set(t.x+.5,t.y+.5,t.z+.5);let r=new ee.BoxHelper(o,16776960);o.add(r),this.scene.add(o)}addDebugOverlay(){if(this.debugOverlayAdded)return;this.debugOverlayAdded=!0;let t=_r("debug-overlay");setInterval(()=>{if(t.setVisibility(this.displayAdvancedStats),this.displayAdvancedStats){let o=a=>new Intl.NumberFormat("en-US",{}).format(a),r="";r+=`C: ${o(this.renderer.info.render.calls)} `,r+=`TR: ${o(this.renderer.info.render.triangles)} `,r+=`TE: ${o(this.renderer.info.memory.textures)} `,r+=`F: ${o(this.tilesRendered)} `,r+=`B: ${o(this.blocksRendered)} `,r+=`MEM: ${this.worldBlockGeometry.getEstimatedMemoryUsage().readable}`,t.updateText(r),this.backendInfoReport=r}},200)}updatePosDataChunk(t){let[o,r,a]=t.split(",").map(i=>Math.floor(+i/16)),s=Math.abs(o-this.cameraSectionPos.x)+Math.abs(r-this.cameraSectionPos.y)+Math.abs(a-this.cameraSectionPos.z),n=this.sectionObjects[t].children.find(i=>i.name==="mesh");n.renderOrder=500-s}updateViewerPosition(t){this.viewerChunkPosition=t}cameraSectionPositionUpdate(){for(let t in this.sectionObjects)this.sectionObjects[t]&&this.updatePosDataChunk(t)}getDir(t,o){return t===o?0:t<o?1:-1}finishChunk(t){this.worldBlockGeometry.finishChunk(t)}handleWorkerMessage(t){t.type==="geometry"&&this.worldBlockGeometry.handleWorkerGeometryMessage(t)}getSignTexture(t,o,r,a=!1){let s=Wl(t),n=this.chunkTextures.get(`${s[0]},${s[1]}`);n||(n={},this.chunkTextures.set(`${s[0]},${s[1]}`,n));let i=`${t.x},${t.y},${t.z}`;if(n[i])return n[i];let c=dk(this.version),_=Uc(o,r,c);if(!_)return;let u=new ee.Texture(_);return u.magFilter=ee.NearestFilter,u.minFilter=ee.NearestFilter,u.needsUpdate=!0,n[i]=u,u}getCameraPosition(){let t=new ee.Vector3;return this.camera.getWorldPosition(t),t}getSectionCameraPosition(){let t=this.getCameraPosition();return new ao(Math.floor(t.x/16),Math.floor(t.y/16),Math.floor(t.z/16))}updateCameraSectionPos(){let t=this.getSectionCameraPosition();this.cameraSectionPos.equals(t)||(this.cameraSectionPos=t,this.cameraSectionPositionUpdate())}setFirstPersonCamera(t,o,r){let a=this.playerStateReactive.eyeHeight;this.updateCamera(t?.offset(0,a,0)??null,o,r),this.media.tryIntersectMedia(),this.updateCameraSectionPos()}getThirdPersonCamera(t,o,r){t??(t=this.cameraObject.position);let a=this.playerStateReactive.perspective==="third_person_back",s=4,n=new ee.Vector3(0,0,-1),i=new ee.Quaternion().setFromAxisAngle(new ee.Vector3(1,0,0),r),c=new ee.Quaternion().setFromAxisAngle(new ee.Vector3(0,1,0),o),_=new ee.Quaternion().multiplyQuaternions(c,i);n.applyQuaternion(_),a&&n.multiplyScalar(-1),this.DEBUG_RAYCAST&&this.debugRaycast(t,n,s);let u=new ee.Raycaster;u.set(t,n),u.far=s;let b=Object.values(this.sectionObjects).filter(v=>v.name==="chunk"&&v.visible).filter(v=>{let x=v.children.find(O=>O.name==="mesh");if(!x)return!1;let R=new ee.Vector3;return x.getWorldPosition(R),t.distanceTo(R)<80}),h=[];for(let v of b){let x=v.children.find(R=>R.name==="mesh");x&&h.push(x)}let k=u.intersectObjects(h,!1),f=s;return k.length>0&&(f=Math.max(.5,k[0].distance-.2)),new ao(t.x+n.x*f,t.y+n.y*f,t.z+n.z*f)}debugRaycast(t,o,r){this.debugRaycastHelper&&(this.scene.remove(this.debugRaycastHelper),this.debugRaycastHelper=void 0),this.debugHitPoint&&(this.scene.remove(this.debugHitPoint),this.debugHitPoint=void 0),this.debugRaycastHelper=new ee.ArrowHelper(o.clone().normalize(),t,r,16711680,r*.1,r*.05),this.scene.add(this.debugRaycastHelper);let a=new ee.SphereGeometry(.2,8,8),s=new ee.MeshBasicMaterial({color:65280});this.debugHitPoint=new ee.Mesh(a,s),this.debugHitPoint.position.copy(t).add(o.clone().multiplyScalar(r)),this.scene.add(this.debugHitPoint)}setCinimaticCamera(t,o,r){this.cameraObject.position.set(t.x,t.y,t.z),this.cameraShake.setBaseRotation(r,o),this.updateCameraSectionPos()}setCinimaticFov(t){this.camera.fov=t,this.camera.updateProjectionMatrix()}updateCamera(t,o,r){if(!this.cinimaticScript.running){if(t){this.renderer.xr.isPresenting&&(t.y-=this.camera.position.y),this.currentPosTween?.stop();let a=this.displayOptions.inWorldRenderingConfig.instantCameraUpdate?0:this.playerStateUtils.isSpectatingEntity()?150:50;this.currentPosTween=new Le(this.cameraObject.position).to({x:t.x,y:t.y,z:t.z},a).start()}if(this.playerStateUtils.isSpectatingEntity()){let a=this.cameraShake.getBaseRotation(),s=0,n=Math.PI/2;a.yaw<n&&o>Math.PI+n?s=-Math.PI*2:o<n&&a.yaw>Math.PI+n&&(s=Math.PI*2),this.currentRotTween?.stop(),this.currentRotTween=new Le(a).to({pitch:r,yaw:o+s},100).onUpdate(i=>this.cameraShake.setBaseRotation(i.pitch,i.yaw-s)).start()}else{this.currentRotTween?.stop(),this.cameraShake.setBaseRotation(r,o);let{perspective:a}=this.playerStateReactive;if(a==="third_person_back"||a==="third_person_front"){let s=this.cameraObject.position,n=this.getThirdPersonCamera(new ee.Vector3(s.x,s.y,s.z),o,r),i=s.distanceTo(new ee.Vector3(n.x,n.y,n.z)),c=a==="third_person_back"?i:-i;this.camera.position.set(0,0,c),a==="third_person_front"?this.camera.rotation.set(0,Math.PI,0):this.camera.rotation.set(0,0,0)}else this.camera.position.set(0,0,0),this.camera.rotation.set(0,0,0),this.debugRaycastHelper&&(this.scene.remove(this.debugRaycastHelper),this.debugRaycastHelper=void 0),this.debugHitPoint&&(this.scene.remove(this.debugHitPoint),this.debugHitPoint=void 0)}this.updateCameraSectionPos()}}debugChunksVisibilityOverride(){let{chunksRenderAboveOverride:t,chunksRenderBelowOverride:o,chunksRenderDistanceOverride:r,chunksRenderAboveEnabled:a,chunksRenderBelowEnabled:s,chunksRenderDistanceEnabled:n}=this.reactiveDebugParams,i=this.getSectionHeight(),c=this.cameraSectionPos.y*i;if(this.displayOptions.inWorldRenderingConfig.enableDebugOverlay&&t!==void 0||o!==void 0||r!==void 0)for(let[_,u]of Object.entries(this.sectionObjects)){let[b,h,k]=_.split(",").map(Number),f=a&&t!==void 0?h<=c+t:s&&o!==void 0?h>=c-o:n&&r!==void 0?Math.abs(h-c)<=r:!0;u.visible=f}else for(let _ of Object.values(this.sectionObjects))_.visible=!0}render(t=!1){if(this.currentRenderedFrames++,this.reactiveDebugParams.stopRendering)return;this.debugChunksVisibilityOverride();let o=performance.now();this.lastRendered=performance.now();let r=this.lastRenderTime>0?Math.min(Math.max((o-this.lastRenderTime)/1e3,0),.1):1/60;this.lastRenderTime=o,this.cursorBlock.render(),this.updateSectionOffsets();let a=this.getCameraPosition();if(this.skyboxRenderer.update(a,this.viewDistance),t||this.displayOptions.inWorldRenderingConfig.fov!==this.camera.fov){let _=this.renderer.getSize(new ee.Vector2);this.camera.aspect=_.width/_.height,this.camera.fov=this.displayOptions.inWorldRenderingConfig.fov,this.camera.updateProjectionMatrix()}this.reactiveDebugParams.disableEntities||this.entities.render();let n=this.cameraGroupVr instanceof ee.Group?this.cameraGroupVr.children.find(_=>_ instanceof ee.PerspectiveCamera):this.camera;this.renderer.render(this.scene,n),this.displayOptions.inWorldRenderingConfig.showHand&&this.playerStateReactive.gameMode!=="spectator"&&this.playerStateReactive.perspective==="first_person"&&!this.renderer.xr.isPresenting&&(this.holdingBlock.render(this.camera,this.renderer,this.ambientLight,this.directionalLight),this.holdingBlockLeft.render(this.camera,this.renderer,this.ambientLight,this.directionalLight));for(let _ of this.fountains)this.sectionObjects[_.sectionId]&&!this.sectionObjects[_.sectionId].foutain&&(_.createParticles(this.sectionObjects[_.sectionId]),this.sectionObjects[_.sectionId].foutain=!0),_.render();this.waypoints.render(),this.fireworks.update();for(let _ of this.onRender)_(r);let c=performance.now()-o;this.renderTimeAvgCount++,this.renderTimeAvg=(this.renderTimeAvg*(this.renderTimeAvgCount-1)+c)/this.renderTimeAvgCount,this.renderTimeMax=Math.max(this.renderTimeMax,c)}renderHead(t,o,r,a){let s;if(a.SkullOwner?s=a.SkullOwner.Properties?.textures?.[0]?.Value:s=a.profile?.properties?.find(n=>n.name==="textures")?.value,!!s)try{let i=JSON.parse(D.from(s,"base64").toString()).textures?.SKIN?.url,{skinTexturesProxy:c}=this.worldRendererConfig;c&&(i=i?.replace("http://textures.minecraft.net/",c).replace("https://textures.minecraft.net/",c));let _=yr(this,i,Ir.head),u=new ee.Group;return r&&_.position.set(0,.3125,.3125),_.position.y-=23/16,u.add(_),u.position.set(t.x+.5,t.y+.045,t.z+.5),u.rotation.set(0,-ee.MathUtils.degToRad(o*(r?90:45/2)),0),u.scale.set(.8,.8,.8),u}catch{}}renderSign(t,o,r,a,s){let n=this.getSignTexture(t,s,a);if(!n)return;let i=new ee.Mesh(new ee.PlaneGeometry(1,1),new ee.MeshBasicMaterial({map:n,transparent:!0}));i.renderOrder=999;let c=7/16,_=a?1.3:1;i.scale.set(1*_,c*_,1*_);let u=(a?2:1.5)/16,b=.25/16;r&&!a?i.position.set(0,0,-.5+u+b+1e-4):i.position.set(0,0,u/2+1e-4);let h=new ee.Group;h.rotation.set(0,-ee.MathUtils.degToRad(o*(r?90:45/2)),0),h.add(i);let k=(a?10:8)/16,f=(a?0:r?4.333:9.333)/16,y=k/2+f;return h.position.set(t.x+.5,t.y+y,t.z+.5),h}lightUpdate(t,o){for(let r=this.worldSizeParams.minY;r<this.worldSizeParams.worldHeight;r+=16)this.setSectionDirty(new ao(t,r,o))}rerenderAllChunks(){for(let t of Object.keys(this.sectionObjects)){let[o,r,a]=t.split(",").map(Number);this.setSectionDirty(new ao(o,r,a))}}updateShowChunksBorder(t){for(let o of Object.values(this.sectionObjects))for(let r of o.children)r.name==="helper"&&(r.visible=t)}resetWorld(){super.resetWorld(),this.worldBlockGeometry.resetWorld(),this.debugRaycastHelper&&(this.scene.remove(this.debugRaycastHelper),this.debugRaycastHelper=void 0),this.debugHitPoint&&(this.scene.remove(this.debugHitPoint),this.debugHitPoint=void 0)}getLoadedChunksRelative(t,o=!1){let[r,a,s]=Xa(t);return Object.fromEntries(Object.entries(this.sectionObjects).map(([n,i])=>{let[c,_,u]=n.split(",").map(Number),[b,h,k]=Xa({x:c,y:_,z:u});return[o?`${b-r},${h-a},${k-s}`:`${b-r},${k-s}`,i]}))}cleanChunkTextures(t,o){let r=this.chunkTextures.get(`${Math.floor(t/16)},${Math.floor(o/16)}`)??{};for(let a of Object.keys(r))r[a].dispose(),delete r[a]}readdChunks(){for(let t of Object.keys(this.sectionObjects))this.scene.remove(this.sectionObjects[t]);setTimeout(()=>{for(let t of Object.keys(this.sectionObjects))this.scene.add(this.sectionObjects[t])},500)}disableUpdates(t=this.scene.children){for(let o of t)o.matrixWorldNeedsUpdate=!1,this.disableUpdates(o.children??[])}removeColumn(t,o){super.removeColumn(t,o),this.cleanChunkTextures(t,o),this.worldBlockGeometry.removeColumn(t,o)}setSectionDirty(...t){let[o]=t;this.cleanChunkTextures(o.x,o.z),super.setSectionDirty(...t)}static getRendererInfo(t){try{let o=t.getContext();return`${o.getParameter(o.getExtension("WEBGL_debug_renderer_info").UNMASKED_RENDERER_WEBGL)}`}catch{}}worldStop(){this.media.onWorldStop()}destroy(){this.disposeModules(),this.fireworksLegacy.destroy(),super.destroy(),this.skyboxRenderer.dispose(),this.fireworks.dispose()}shouldObjectVisible(t){let r=this.getSectionHeight(),a=Math.floor(t.position.x/16)*16,s=Math.floor(t.position.z/16)*16,n=Math.floor(t.position.y/r)*r,i=`${a},${s}`,c=`${a},${n},${s}`;return!!this.finishedChunks[i]||!!this.sectionObjects[c]}handleUserClick(t){this.media.handleUserClick(t)}updateSectionOffsets(){let t=performance.now();for(let[o,r]of Object.entries(this.sectionsOffsetsAnimations)){let a=(t-r.time)/1e3;r.time=t,r.currentOffsetX+=r.speedX*a,r.currentOffsetY+=r.speedY*a,r.currentOffsetZ+=r.speedZ*a,r.limitX!==void 0&&(r.speedX>0?r.currentOffsetX=Math.min(r.currentOffsetX,r.limitX):r.currentOffsetX=Math.max(r.currentOffsetX,r.limitX)),r.limitY!==void 0&&(r.speedY>0?r.currentOffsetY=Math.min(r.currentOffsetY,r.limitY):r.currentOffsetY=Math.max(r.currentOffsetY,r.limitY)),r.limitZ!==void 0&&(r.speedZ>0?r.currentOffsetZ=Math.min(r.currentOffsetZ,r.limitZ):r.currentOffsetZ=Math.max(r.currentOffsetZ,r.limitZ));let s=this.sectionObjects[o];s&&(s.position.set(r.currentOffsetX,r.currentOffsetY,r.currentOffsetZ),s.updateMatrix())}}reloadWorld(){this.entities.reloadEntities()}};I();A();E();z();I();A();E();z();I();A();E();z();I();A();E();z();function gn(l){throw new Error("Node.js process "+l+" is not supported by JSPM core outside of Node.js")}var Ft=[],Or=!1,Yo,Sa=-1;function pk(){!Or||!Yo||(Or=!1,Yo.length?Ft=Yo.concat(Ft):Sa=-1,Ft.length&&od())}function od(){if(!Or){var l=setTimeout(pk,0);Or=!0;for(var e=Ft.length;e;){for(Yo=Ft,Ft=[];++Sa<e;)Yo&&Yo[Sa].run();Sa=-1,e=Ft.length}Yo=null,Or=!1,clearTimeout(l)}}function mk(l){var e=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)e[t-1]=arguments[t];Ft.push(new rd(l,e)),Ft.length===1&&!Or&&setTimeout(od,0)}function rd(l,e){this.fun=l,this.array=e}rd.prototype.run=function(){this.fun.apply(null,this.array)};var bk="browser",hk="x64",kk="browser",fk={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},gk=["/usr/bin/node"],vk=[],xk="v16.8.0",yk={},wk=function(l,e){},Ik=function(l){gn("binding")},Ak=function(l){return 0},zk=function(){return"/"},Ek=function(l){},Mk={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};function Ke(){}var Rk=Ke,Ok=[];function Sk(l){gn("_linkedBinding")}var Ck={},Tk=!1,Pk={};function Bk(l){gn("dlopen")}function jk(){return[]}function Hk(){return[]}var Dk=Ke,Nk=Ke,vn=function(){return{}},Gk=vn,Lk=vn,Wk=Ke,Uk=Ke,qk=Ke,Fk={};function Vk(l,e){if(!l)throw new Error(e||"assertion error")}var Yk={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},$k=Ke,Zk=Ke;function Kk(){return!1}var Jk=Ke,Xk=Ke,Qk=Ke,ef=Ke,tf=Ke,of=void 0,rf=void 0,lf=void 0,af=Ke,sf=2,nf=1,cf="/bin/usr/node",_f=9229,uf="node",df=[],pf=Ke,so={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};so.now===void 0&&(hn=Date.now(),so.timing&&so.timing.navigationStart&&(hn=so.timing.navigationStart),so.now=()=>Date.now()-hn);var hn;function mf(){return so.now()/1e3}var kn=1e9;function fn(l){var e=Math.floor((Date.now()-so.now())*.001),t=so.now()*.001,o=Math.floor(t)+e,r=Math.floor(t%1*1e9);return l&&(o=o-l[0],r=r-l[1],r<0&&(o--,r+=kn)),[o,r]}fn.bigint=function(l){var e=fn(l);return typeof BigInt>"u"?e[0]*kn+e[1]:BigInt(e[0]*kn)+BigInt(e[1])};var bf=10,hf={},kf=0;function no(){return xn}var ff=no,gf=no,vf=no,xf=no,yf=no,wf=Ke,If=no,Af=no;function zf(l){return[]}var xn={version:xk,versions:yk,arch:hk,platform:kk,release:Mk,_rawDebug:Rk,moduleLoadList:Ok,binding:Ik,_linkedBinding:Sk,_events:hf,_eventsCount:kf,_maxListeners:bf,on:no,addListener:ff,once:gf,off:vf,removeListener:xf,removeAllListeners:yf,emit:wf,prependListener:If,prependOnceListener:Af,listeners:zf,domain:Ck,_exiting:Tk,config:Pk,dlopen:Bk,uptime:mf,_getActiveRequests:jk,_getActiveHandles:Hk,reallyExit:Dk,_kill:Nk,cpuUsage:vn,resourceUsage:Gk,memoryUsage:Lk,kill:Wk,exit:Uk,openStdin:qk,allowedNodeEnvironmentFlags:Fk,assert:Vk,features:Yk,_fatalExceptions:$k,setUncaughtExceptionCaptureCallback:Zk,hasUncaughtExceptionCaptureCallback:Kk,emitWarning:wk,nextTick:mk,_tickCallback:Jk,_debugProcess:Xk,_debugEnd:Qk,_startProfilerIdleNotifier:ef,_stopProfilerIdleNotifier:tf,stdout:of,stdin:lf,stderr:rf,abort:af,umask:Ak,chdir:Ek,cwd:zk,env:fk,title:bk,argv:gk,execArgv:vk,pid:sf,ppid:nf,execPath:cf,debugPort:_f,hrtime:fn,argv0:uf,_preload_modules:df,setSourceMapsEnabled:pf};var yn={},ld=!1;function Ef(){if(ld)return yn;ld=!0;var l=xn;function e(a){if(typeof a!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(a))}function t(a,s){for(var n="",i=0,c=-1,_=0,u,b=0;b<=a.length;++b){if(b<a.length)u=a.charCodeAt(b);else{if(u===47)break;u=47}if(u===47){if(!(c===b-1||_===1))if(c!==b-1&&_===2){if(n.length<2||i!==2||n.charCodeAt(n.length-1)!==46||n.charCodeAt(n.length-2)!==46){if(n.length>2){var h=n.lastIndexOf("/");if(h!==n.length-1){h===-1?(n="",i=0):(n=n.slice(0,h),i=n.length-1-n.lastIndexOf("/")),c=b,_=0;continue}}else if(n.length===2||n.length===1){n="",i=0,c=b,_=0;continue}}s&&(n.length>0?n+="/..":n="..",i=2)}else n.length>0?n+="/"+a.slice(c+1,b):n=a.slice(c+1,b),i=b-c-1;c=b,_=0}else u===46&&_!==-1?++_:_=-1}return n}function o(a,s){var n=s.dir||s.root,i=s.base||(s.name||"")+(s.ext||"");return n?n===s.root?n+i:n+a+i:i}var r={resolve:function(){for(var s="",n=!1,i,c=arguments.length-1;c>=-1&&!n;c--){var _;c>=0?_=arguments[c]:(i===void 0&&(i=l.cwd()),_=i),e(_),_.length!==0&&(s=_+"/"+s,n=_.charCodeAt(0)===47)}return s=t(s,!n),n?s.length>0?"/"+s:"/":s.length>0?s:"."},normalize:function(s){if(e(s),s.length===0)return".";var n=s.charCodeAt(0)===47,i=s.charCodeAt(s.length-1)===47;return s=t(s,!n),s.length===0&&!n&&(s="."),s.length>0&&i&&(s+="/"),n?"/"+s:s},isAbsolute:function(s){return e(s),s.length>0&&s.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var s,n=0;n<arguments.length;++n){var i=arguments[n];e(i),i.length>0&&(s===void 0?s=i:s+="/"+i)}return s===void 0?".":r.normalize(s)},relative:function(s,n){if(e(s),e(n),s===n||(s=r.resolve(s),n=r.resolve(n),s===n))return"";for(var i=1;i<s.length&&s.charCodeAt(i)===47;++i);for(var c=s.length,_=c-i,u=1;u<n.length&&n.charCodeAt(u)===47;++u);for(var b=n.length,h=b-u,k=_<h?_:h,f=-1,y=0;y<=k;++y){if(y===k){if(h>k){if(n.charCodeAt(u+y)===47)return n.slice(u+y+1);if(y===0)return n.slice(u+y)}else _>k&&(s.charCodeAt(i+y)===47?f=y:y===0&&(f=0));break}var v=s.charCodeAt(i+y),x=n.charCodeAt(u+y);if(v!==x)break;v===47&&(f=y)}var R="";for(y=i+f+1;y<=c;++y)(y===c||s.charCodeAt(y)===47)&&(R.length===0?R+="..":R+="/..");return R.length>0?R+n.slice(u+f):(u+=f,n.charCodeAt(u)===47&&++u,n.slice(u))},_makeLong:function(s){return s},dirname:function(s){if(e(s),s.length===0)return".";for(var n=s.charCodeAt(0),i=n===47,c=-1,_=!0,u=s.length-1;u>=1;--u)if(n=s.charCodeAt(u),n===47){if(!_){c=u;break}}else _=!1;return c===-1?i?"/":".":i&&c===1?"//":s.slice(0,c)},basename:function(s,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');e(s);var i=0,c=-1,_=!0,u;if(n!==void 0&&n.length>0&&n.length<=s.length){if(n.length===s.length&&n===s)return"";var b=n.length-1,h=-1;for(u=s.length-1;u>=0;--u){var k=s.charCodeAt(u);if(k===47){if(!_){i=u+1;break}}else h===-1&&(_=!1,h=u+1),b>=0&&(k===n.charCodeAt(b)?--b===-1&&(c=u):(b=-1,c=h))}return i===c?c=h:c===-1&&(c=s.length),s.slice(i,c)}else{for(u=s.length-1;u>=0;--u)if(s.charCodeAt(u)===47){if(!_){i=u+1;break}}else c===-1&&(_=!1,c=u+1);return c===-1?"":s.slice(i,c)}},extname:function(s){e(s);for(var n=-1,i=0,c=-1,_=!0,u=0,b=s.length-1;b>=0;--b){var h=s.charCodeAt(b);if(h===47){if(!_){i=b+1;break}continue}c===-1&&(_=!1,c=b+1),h===46?n===-1?n=b:u!==1&&(u=1):n!==-1&&(u=-1)}return n===-1||c===-1||u===0||u===1&&n===c-1&&n===i+1?"":s.slice(n,c)},format:function(s){if(s===null||typeof s!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof s);return o("/",s)},parse:function(s){e(s);var n={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return n;var i=s.charCodeAt(0),c=i===47,_;c?(n.root="/",_=1):_=0;for(var u=-1,b=0,h=-1,k=!0,f=s.length-1,y=0;f>=_;--f){if(i=s.charCodeAt(f),i===47){if(!k){b=f+1;break}continue}h===-1&&(k=!1,h=f+1),i===46?u===-1?u=f:y!==1&&(y=1):u!==-1&&(y=-1)}return u===-1||h===-1||y===0||y===1&&u===h-1&&u===b+1?h!==-1&&(b===0&&c?n.base=n.name=s.slice(1,h):n.base=n.name=s.slice(b,h)):(b===0&&c?(n.name=s.slice(1,u),n.base=s.slice(1,h)):(n.name=s.slice(b,u),n.base=s.slice(b,h)),n.ext=s.slice(u,h)),b>0?n.dir=s.slice(0,b-1):c&&(n.dir="/"),n},sep:"/",delimiter:":",win32:null,posix:null};return r.posix=r,yn=r,yn}var Je=Ef();var jO=Je._makeLong,HO=Je.basename,DO=Je.delimiter,NO=Je.dirname,GO=Je.extname,LO=Je.format,WO=Je.isAbsolute,wn=Je.join,UO=Je.normalize,qO=Je.parse,FO=Je.posix,VO=Je.relative,YO=Je.resolve,$O=Je.sep,ZO=Je.win32;import*as he from"three";I();A();E();z();import Mf from"prismarine-world";import Rf from"prismarine-chunk";var ad=l=>{let e=Mf(l),t=Rf(l),o=new e(l).sync,r=Of(o);for(let a of r)if(a.startsWith("set")&&a!=="setColumn"){let s=o[a].bind(o);o[a]=(...n)=>{let i=n[0];i.x!==void 0&&!o.getColumnAt(i)&&o.setColumn(Math.floor(i.x/16),Math.floor(i.z/16),new t(void 0)),s(...n)}}return o};function Of(l){let e=new Set,t=l;do for(let o of Object.getOwnPropertyNames(t))typeof l[o]=="function"&&o!=="constructor"&&e.add(o);while(t=Object.getPrototypeOf(t));return[...e]}import{Vec3 as nd}from"vec3";I();A();E();z();var sd="1.21.4";var In=new Date,id=In.getMonth()===11&&In.getDate()>=24&&In.getDate()<=26,Sf=["panorama_3.webp","panorama_1.webp","panorama_4.webp","panorama_5.webp","panorama_0.webp","panorama_2.webp"],Ca=class{constructor(e,t,o=!1){this.documentRenderer=e;this.options=t;this.doWorldBlocksPanorama=o;p(this,"camera");p(this,"scene");p(this,"ambientLight");p(this,"directionalLight");p(this,"panoramaGroup",null);p(this,"time",0);p(this,"abortController",new AbortController);p(this,"worldRenderer");p(this,"WorldRendererClass",Vo);p(this,"startTimes",new Map);this.scene=new he.Scene,this.scene.background=new he.Color(3294568),this.ambientLight=new he.AmbientLight(13421772),this.scene.add(this.ambientLight),this.directionalLight=new he.DirectionalLight(16777215,.5),this.directionalLight.position.set(1,1,.5).normalize(),this.directionalLight.castShadow=!0,this.scene.add(this.directionalLight),this.camera=new he.PerspectiveCamera(85,this.documentRenderer.canvas.width/this.documentRenderer.canvas.height,.05,1e3),this.camera.position.set(0,0,0),this.camera.rotation.set(0,0,0)}async start(){this.doWorldBlocksPanorama?await this.worldBlocksPanorama():this.addClassicPanorama(),this.documentRenderer.render=(e=!1)=>{e&&(this.camera.aspect=this.documentRenderer.canvas.width/this.documentRenderer.canvas.height,this.camera.updateProjectionMatrix()),this.documentRenderer.renderer.render(this.scene,this.camera)}}async debugImageInFrontOfCamera(){let e=await to(wn("background","panorama_0.webp")),t=new he.Mesh(new he.PlaneGeometry(1e3,1e3),new he.MeshBasicMaterial({map:e}));t.position.set(0,0,-500),t.rotation.set(0,0,0),this.scene.add(t)}addClassicPanorama(){let e=new he.BoxGeometry(1e3,1e3,1e3),t=[],o=200;for(let s of Sf)(async()=>{let{texture:i}=Yl(wn("background",id?"christmas":"",s));i.matrixAutoUpdate=!1,i.matrix.set(-1,0,1,0,1,0,0,0,1),i.wrapS=he.ClampToEdgeWrapping,i.wrapT=he.ClampToEdgeWrapping,i.minFilter=he.LinearFilter,i.magFilter=he.LinearFilter;let c=new he.MeshBasicMaterial({map:i,transparent:!0,side:he.DoubleSide,depthWrite:!1,opacity:0});this.startTimes.set(c,Date.now()),t.push(c)})();let r=new he.Mesh(e,t);r.onBeforeRender=()=>{this.time+=.01,r.rotation.y=Math.PI+this.time*.01,r.rotation.z=Math.sin(-this.time*.001)*.001;for(let s of t){let n=this.startTimes.get(s);if(n){let i=Date.now()-n,c=Math.min(1,i/o);s.opacity=c}}};let a=new he.Object3D;if(a.add(r),!id)for(let s=0;s<20;s++){let n=new Ut("1.16.4","squid").mesh;n.position.set(Math.random()*30-15,Math.random()*20-10,Math.random()*10-17),n.rotation.set(0,Math.PI+Math.random(),-Math.PI/4,"ZYX");let i=Math.random()*.01;n.children[0].onBeforeRender=()=>{n.rotation.y+=i,n.rotation.z=Math.cos(r.rotation.y*3)*Math.PI/4-Math.PI/2},a.add(n)}this.scene.add(a),this.panoramaGroup=a}async worldBlocksPanorama(){let e=sd,t=new Dt;if(t.currentConfig={version:e,noInventoryGui:!0},await t.updateAssetsData?.({}),this.abortController.signal.aborted)return;let o=ad(e),a=fd("prismarine-block")(e),n=globalThis.mcData.blocksArray.filter(v=>{if(!v.name.includes("stained_glass"))return!1;let x=a.fromStateId(v.defaultState,0);if(x.shapes?.length!==1)return!1;let R=x.shapes[0];return R[0]===0&&R[1]===0&&R[2]===0&&R[3]===1&&R[4]===1&&R[5]===1}),i=-15,c=100,_=100;for(let v=-c;v<c;v++)for(let x=-_;x<_;x++){let R=n[Math.floor(Math.random()*n.length)];o.setBlockStateId(new nd(v,x,i),R.defaultState)}this.camera.updateProjectionMatrix(),this.camera.position.set(.5,_/2+.5,.5),this.camera.rotation.set(0,0,0);let u=new nd(...this.camera.position.toArray()),b=new ko(o,2,u);if(this.abortController.signal.aborted||(this.worldRenderer=new this.WorldRendererClass(this.documentRenderer.renderer,this.options,{version:e,worldView:b,inWorldRenderingConfig:Hr,playerStateReactive:Qi().reactive,rendererState:po().reactive,nonReactiveState:po().nonReactive,resourcesManager:t}),this.worldRenderer instanceof Vo&&(this.scene=this.worldRenderer.scene),b.init(u),await this.worldRenderer.waitForChunksToRender(),this.abortController.signal.aborted))return;let{camera:h}=this,k=h.position.x,f=h.position.y,y;document.body.addEventListener("pointermove",v=>{if(v.pointerType!=="mouse")return;let x=new he.Vector2(v.clientX,v.clientY),R=.2,M=x.x/window.innerWidth-.5,O=-(x.y/window.innerHeight-.5);y?.stop();let T={x:k+M*R,y:f+O*R};y=new Le(h.position).to(T,0),y.start(),h.updateProjectionMatrix()},{signal:this.abortController.signal})}dispose(){this.scene.clear(),this.worldRenderer?.destroy(),this.abortController.abort()}};kl.ColorManagement.enabled=!1;globalThis.THREE=kl;var cd=l=>({updateMap:l.entities.updateMap.bind(l.entities),updateCustomBlock:l.updateCustomBlock.bind(l),getBlockInfo:l.getBlockInfo.bind(l),playEntityAnimation:l.entities.playAnimation.bind(l.entities),damageEntity:l.entities.handleDamageEvent.bind(l.entities),updatePlayerSkin:l.entities.updatePlayerSkin.bind(l.entities),changeHandSwingingState:l.changeHandSwingingState.bind(l),getHighestBlocks:l.getHighestBlocks.bind(l),reloadWorld:l.reloadWorld.bind(l),updateEntityModel:l.entities.updateEntityModel.bind(l.entities),playEntityModelAnimation:l.entities.playEntityModelAnimation.bind(l.entities),addMedia:l.media.addMedia.bind(l.media),destroyMedia:l.media.destroyMedia.bind(l.media),setControlMode:l.media.setControlMode.bind(l.media),setVideoPlaying:l.media.setVideoPlaying.bind(l.media),setVideoSeeking:l.media.setVideoSeeking.bind(l.media),setVideoVolume:l.media.setVideoVolume.bind(l.media),setVideoSpeed:l.media.setVideoSpeed.bind(l.media),handleUserClick:l.media.handleUserClick.bind(l.media),addSectionAnimation(e,t){l.sectionsOffsetsAnimations[e]=t},removeSectionAnimation(e){delete l.sectionsOffsetsAnimations[e]},shakeFromDamage:l.cameraShake.shakeFromDamage.bind(l.cameraShake),onPageInteraction:l.media.onPageInteraction.bind(l.media),downloadMesherLog:l.downloadMesherLog.bind(l),explodeFirework:l.fireworksLegacy.explode.bind(l.fireworksLegacy),explodeFireworkFacingCamera:l.fireworksLegacy.explodeFacingCamera.bind(l.fireworksLegacy),addWaypoint:l.waypoints.addWaypoint.bind(l.waypoints),removeWaypoint:l.waypoints.removeWaypoint.bind(l.waypoints),startCinimaticScript:l.cinimaticScript.startScript.bind(l.cinimaticScript),stopCinimaticScript:l.cinimaticScript.stopScript.bind(l.cinimaticScript),launchFirework:l.fireworks.launchFirework.bind(l.fireworks),setSkyboxImage:l.skyboxRenderer.setSkyboxImage.bind(l.skyboxRenderer),setRain:e=>l.toggleModule("rain",e),async loadGeometryExport(e){let{applyWorldGeometryExport:t}=await Promise.resolve().then(()=>(sn(),Fu));return t(l,e)}}),Tf=[],Ta=(l,...e)=>{for(let t of Object.values(globalThis.loadedMods??{}))try{t.threeJsBackendModule?.[l]?.(...e)}catch(o){let r=`[mod three.js] Error calling ${l} on ${t.name}: ${o}`;throw new Error(r)}},_d=()=>{let l,e=null,t=null,o=null,r=null,a=(_,u)=>{Oe?l=Nl(_,Tf,globalThis):l=_,e=new Zr(l,u?.canvas),globalThis.renderer=e.renderer,globalThis.documentRenderer=e,globalThis.threeJsBackend=c,Ta("default",c)},s=async()=>{if(!e)throw new Error("Document renderer not initialized");if(!o&&!t){let _={...l};t=new Ca(e,_,!!H.env.SINGLE_FILE_BUILD_MODE),globalThis.panoramaRenderer=t,Ta("panoramaCreated",t),await t.start(),Ta("panoramaReady",t)}},n=async _=>{let b=Oe?Nl(_,[Dt,ho],globalThis):_;if(!e)throw new Error("Document renderer not initialized");e.nonReactiveState=b.nonReactiveState,globalThis.resourcesManager=b.resourcesManager,t&&(t.dispose(),t=null),o=new Vo(e.renderer,l,b),await o.worldReadyPromise,r=new Gl(b.nonReactiveState),globalThis.frameTimingCollector=r;let h=e.render;e.render=function(k){h.call(this,k),r?.markFrameStart(),b.inWorldRenderingConfig.paused||o?.render(k),r?.markFrameEnd(),r?.markFrameDisplay()},e.inWorldRenderingConfig=b.inWorldRenderingConfig,globalThis.world=o,Ta("worldReady",o)},i=()=>{t&&(t.dispose(),t=null),e&&e.dispose(),o&&(o.destroy(),o=null)},c={id:"threejs",displayName:`three.js ${kl.REVISION}`,startPanorama:s,startWorld:n,disconnect:i,setRendering(_){e.setPaused(!_),o&&(o.renderingActive=_)},getDebugOverlay:()=>({get entitiesString(){return o?.entities.getDebugString()}}),updateCamera(_,u,b){r?.markCameraUpdate(!_),o?.setFirstPersonCamera(_,u,b)},get soundSystem(){return o?.soundSystem},get backendMethods(){if(o)return cd(o)}};return{main:{init:a,backend:c},workerProxy(){return Dc({init(_,u){a(_,{canvas:u})},updateSizeExternal(_,u,b){e?.updateSizeExternal(_,u,b)},startPanorama:s,startWorld:n,disconnect:i,setRendering:c.setRendering,updateCamera(_,u,b){let h=_?new Cf(_.x,_.y,_.z):null;r?.markCameraUpdate(!h),c.updateCamera(h,u,b)},async callBackendMethod(_,...u){if(!o)throw new Error("World renderer not initialized");let h=cd(o)[_];if(!h)throw new Error(`Backend method ${String(_)} is unavailable`);return h(...u)}})}}};var Pa=l=>{let{main:e}=_d();return e.init(l),e.backend};Pa.id="threejs";Pa.displayName="three.js Blocking";Pa.description="Simple, old and stable main thread graphics backend providing balanced performance on top of WebGL2.";I();A();E();z();import*as ud from"three";function Pf(l){let e="threeWorker.js",t;if(H.env.SINGLE_FILE_BUILD){let o=document.getElementById("three-worker-code").textContent,r=new Blob([o],{type:"text/javascript"});t=new Worker(window.URL.createObjectURL(r))}else t=new Worker(e);return t.onmessage=({data:o})=>{l(o)},t.on&&t.on("message",o=>{t.onmessage({data:o})}),t}var Ba=async l=>{let e=Pf(()=>{}),t=Nc(e),o=rs();o.onSizeChanged((n,i)=>{t.updateSizeExternal(n,i,window.devicePixelRatio||1)});let r=Dl(l,e);try{t.init(r,o.canvas)}catch(n){throw Fr(r),n}let a=new Proxy({},{get(n,i){if(typeof i=="string")return async(...c)=>t.callBackendMethod(i,...c)}});return{id:"threejs",displayName:`three.js ${ud.REVISION}`,async startPanorama(){},async startWorld(n){let i={...$r,items:"itemsArray",entities:"entitiesArray"};ms([e],n.version,i,n.resourcesManager.currentResources.mcData),n.inWorldRenderingConfig.__syncToWorker=!0,n.playerStateReactive&&(n.playerStateReactive.__syncToWorker=!0),n.rendererState&&(n.rendererState.__syncFromWorker=!0),n.nonReactiveState&&(n.nonReactiveState.__syncFromWorker=!0),n.nonReactiveState.__syncFromWorkerInterval=200;let c=Dl(n,e);try{await t.startWorld(structuredClone(c))}catch(u){throw Fr(c),u}t.updateSizeExternal(o.size.width,o.size.height,window.devicePixelRatio||1);let _=_r("fps");setInterval(()=>{let{fps:u,avgRenderTime:b,worstRenderTime:h}=n.nonReactiveState;_.updateText(`FPS: ${u.toFixed(0)} (${b.toFixed(0)}ms/${h.toFixed(0)}ms)`),n.nonReactiveState.fps=0},1e3)},disconnect(){o.destroy(),t.disconnect(),e.terminate()},setRendering(n){t.setRendering(n)},updateCamera(n,i,c){t.updateCamera(n?{x:n.x,y:n.y,z:n.z}:null,i,c)},soundSystem:void 0,backendMethods:a}};Ba.id="threejs-off-thread";Ba.displayName="three.js Multi-thread";Ba.description=["Edge-cutting technology that uses a dedicated thread for graphics.","Slightly higher power and RAM usage.","More stable FPS (mid-range devices), but possible inputlag if TPS is low.","On low-end devices it might result in device throttling and stuttering."].join(" ");export{Sc as AppViewer,Zr as DocumentRenderer,ir as LoadedResourcesTransferrable,Dt as ResourcesManager,ko as WorldView,ho as WorldViewWorker,rs as addCanvasForWorker,Xo as chunkPos,Ba as createGraphicsBackendOffThread,Pa as createGraphicsBackendSingleThread,u5 as createWorldRendererConfig,Ji as defaultGraphicsBackendConfig,Hr as defaultWorldRendererConfig,tc as delayedIterator,po as getDefaultRendererState,Cc as getInitialPlayerState,pm as getInitialPlayerStateRenderer,dm as getPlayerStateUtils,Oe as isWebWorker,Ad as sectionPos};
|
|
21791
21791
|
/*! Bundled license information:
|
|
21792
21792
|
|
|
21793
21793
|
@jspm/core/nodelibs/browser/chunk-DtuTasat.js:
|
package/dist/threeWorker.js
CHANGED
|
@@ -29090,7 +29090,7 @@ void main() {
|
|
|
29090
29090
|
vec4 texColor = texture2D(texture, gl_PointCoord);
|
|
29091
29091
|
gl_FragColor = vColor * texColor;
|
|
29092
29092
|
}
|
|
29093
|
-
`,zr={textureSize:128,gravity:new Z(0,-.005,0),friction:.998,defaultParticleSize:300,maxActiveFireworks:5},Mp=i=>{let t=i*3;return{x:t,y:t+1,z:t+2}},Tp=i=>{let t=i*4;return{r:t,g:t+1,b:t+2,a:t+3}},tu=(i=0,e=0)=>Math.floor(Math.random()*(i+1-e))+e,Hze=(i,e,t,n)=>{i.save();let r=i.createRadialGradient(e,e,0,e,e,e);r.addColorStop(0,"rgba(255,255,255,1.0)"),r.addColorStop(.5,"rgba(255,255,255,0.5)"),r.addColorStop(1,"rgba(255,255,255,0)"),i.fillStyle=r,i.fillRect(0,0,t,n),i.restore()},Gze=()=>{let i=zr.textureSize,e=Dr(i,i),t=e.getContext("2d"),n=i/2;Hze(t,n,e.width,e.height);let r=new Ht(e);return r.needsUpdate=!0,r},Wze=(i,e,t,n,r=zr.defaultParticleSize)=>{let s=new at,a=[],o=[],l=[],c=[],u=[],f=Math.random()>.3?"single":"multiple",v=tu(100,20)*.01,m=()=>tu(100,1)*.01,y="red",b=Math.random();b>.66?y="red":b>.33?y="green":y="blue";for(let g=0;g<i;g++){let x=new Z(0,0,0);if(a.push(x.x,x.y,x.z),o.push(e[g].x,e[g].y,e[g].z),t==="seed"){let w=e[g].y**2*.04;g===0&&(w*=1.1),c.push(w),u.push(w*.017),l.push(1,1,1,1)}else if(t==="trail"){let w=Math.random()*.1+.1;c.push(w),u.push(w*.017),l.push(1,1,1,1)}else{let w=tu(r,10)*.001;if(c.push(w),u.push(w*.017),f==="multiple")l.push(m(),m(),m(),1);else switch(y){case"red":l.push(v,.1,.1,1);break;case"green":l.push(.1,v,.1,1);break;case"blue":l.push(.1,.1,v,1);break}}}s.setAttribute("position",new He(a,3)),s.setAttribute("velocity",new He(o,3)),s.setAttribute("color",new He(l,4)),s.setAttribute("adjustSize",new He(c,1)),s.setAttribute("mass",new He(u,1));let _=new h1({uniforms:{size:{value:zr.textureSize},texture:{value:n}},transparent:!0,depthWrite:!1,blending:sa,vertexShader:zze,fragmentShader:qze});return new Rr(s,_)},Rp=class{particleNum;timerStartFading;mesh;constructor(e,t,n,r,s){this.particleNum=e,this.timerStartFading=10,this.mesh=Wze(e,t,n,r,s)}update(e){this.timerStartFading>0&&(this.timerStartFading-=.3);let t=this.mesh.geometry.attributes.position,n=this.mesh.geometry.attributes.velocity,r=this.mesh.geometry.attributes.color,s=this.mesh.geometry.attributes.mass,a=()=>Math.random()>.5?.98:.96,o=l=>Math.random()>.5?0:(1-l)*.1;for(let l=0;l<this.particleNum;l++){let{x:c,y:u,z:f}=Mp(l);n.array[u]+=e.y-s.array[l],n.array[c]*=zr.friction,n.array[f]*=zr.friction,n.array[u]*=zr.friction,t.array[c]+=n.array[c],t.array[u]+=n.array[u],t.array[f]+=n.array[f];let{a:v}=Tp(l);this.timerStartFading<=0&&(r.array[v]*=a()-o(r.array[v]),r.array[v]<.001&&(r.array[v]=0))}t.needsUpdate=!0,n.needsUpdate=!0,r.needsUpdate=!0}disposeAll(){this.mesh.geometry.dispose(),this.mesh.material.dispose()}},dT=class extends Rp{constructor(e,t,n){super(e,t,"seed",n)}update(e){let t=this.mesh.geometry.attributes.position,n=this.mesh.geometry.attributes.velocity,r=this.mesh.geometry.attributes.color,s=this.mesh.geometry.attributes.mass,a=()=>Math.random()>.3?.99:.96,o=f=>Math.random()>.3?0:(1-f)*.1,l=()=>Math.random()>.5?.05:-.05,c=()=>Math.random()>.1,u=zr.friction*.98;for(let f=0;f<this.particleNum;f++){let{x:v,y:m,z:y}=Mp(f);n.array[m]+=e.y-s.array[f],n.array[v]*=u,n.array[y]*=u,n.array[m]*=u,t.array[v]+=n.array[v],t.array[m]+=n.array[m],t.array[y]+=n.array[y],c()&&(t.array[v]+=l()),c()&&(t.array[y]+=l());let{a:b}=Tp(f);r.array[b]*=a()-o(r.array[b]),r.array[b]<.001&&(r.array[b]=0)}t.needsUpdate=!0,n.needsUpdate=!0,r.needsUpdate=!0}},pT=class extends Rp{constructor(e,t,n){super(e,t,"trail",n)}update(e){let t=this.mesh.geometry.attributes.position,n=this.mesh.geometry.attributes.velocity,r=this.mesh.geometry.attributes.color,s=this.mesh.geometry.attributes.mass,a=()=>Math.random()>.3?.98:.95,o=()=>Math.random()>.5?.05:-.05,l=()=>Math.random()>.2;for(let c=0;c<this.particleNum;c++){let{x:u,y:f,z:v}=Mp(c);n.array[f]+=e.y-s.array[c],n.array[u]*=zr.friction,n.array[v]*=zr.friction,n.array[f]*=zr.friction,t.array[u]+=n.array[u],t.array[f]+=n.array[f],t.array[v]+=n.array[v],l()&&(t.array[u]+=o()),l()&&(t.array[v]+=o());let{a:m}=Tp(c);r.array[m]*=a(),r.array[m]<.001&&(r.array[m]=0)}t.needsUpdate=!0,n.needsUpdate=!0,r.needsUpdate=!0}},kp=class{meshGroup;isExplode;petalsNum;life;seed;flowerSizeRate;flower;texture;particleSize;constructor(e,t=zr.defaultParticleSize,n){this.meshGroup=new ft,this.isExplode=!1,this.texture=e,this.particleSize=t;let r=400,s=150;this.petalsNum=tu(r,s),this.life=150,this.seed=this.getSeed(n),this.meshGroup.add(this.seed.mesh),this.flowerSizeRate=Pt.mapLinear(this.petalsNum,s,r,.4,.7)}getSeed(e){let n=[];for(let s=0;s<40;s++){let o=s===0?Math.random()*2.5+.9:Math.random()*2+.4,l=0;n.push(new Z(0,o,l))}let r=new dT(40,n,this.texture);if(e)r.mesh.position.set(e.x,e.y,e.z);else{let s=Math.random()*80-40,a=-50,o=Math.random()*80-40;r.mesh.position.set(s,a,o)}return r}explode(e){this.isExplode=!0,this.flower=this.getFlower(e),this.meshGroup.add(this.flower.mesh),this.meshGroup.remove(this.seed.mesh),this.seed.disposeAll()}getFlower(e){let t=this.petalsNum,n=[],r;if(Math.random()>.5)for(let o=0;o<t;o++){r=tu(120,60)*.01;let l=Pt.degToRad(Math.random()*180),c=Pt.degToRad(Math.random()*360),u=Math.sin(l)*Math.cos(c)*r,f=Math.sin(l)*Math.sin(c)*r,v=Math.cos(l)*r,m=new Z(u,f,v);m.multiplyScalar(this.flowerSizeRate),n.push(m)}else{let o=180/t,l=360*(Math.random()*20+1)/t,c=l,u=l;r=tu(120,60)*.01;for(let f=0;f<t;f++){let v=Math.sin(Pt.degToRad(o*f)),m=Math.cos(Pt.degToRad(o*f))*r,y=Math.cos(Pt.degToRad(c*f))*v*r,b=Math.sin(Pt.degToRad(u*f))*v*r,_=new Z(y,b,m);_.multiplyScalar(this.flowerSizeRate),n.push(_)}}let a=new Rp(t,n,"default",this.texture,this.particleSize);return a.mesh.position.set(e.x,e.y,e.z),a}update(e){this.isExplode?(this.flower.update(e),this.life>0&&(this.life-=1)):this.drawTail()}drawTail(){this.seed.update(zr.gravity);let e=this.seed.mesh.geometry.attributes.position,t=this.seed.mesh.geometry.attributes.velocity,n=0;for(let f=0,v=t.array.length;f<v;f++){let m=t.array[f];f%3===1&&m>0&&n++}if(!(n===0))return;let{x:s,y:a,z:o}=this.seed.mesh.position,l=new Z(s,a,o),c=0,u;for(let f=0,v=e.array.length;f<v;f++){let m=e.array[f];f%3===1&&m>c&&(c=m,u=new Z(e.array[f-1],m,e.array[f+2]))}u&&(l.add(u),this.explode(l))}},Fh=class extends kp{tailMeshGroup;tails;constructor(e,t=zr.defaultParticleSize,n){super(e,t,n);let r=150,s=100;this.petalsNum=tu(r,s),this.flowerSizeRate=Pt.mapLinear(this.petalsNum,s,r,.4,.7),this.tailMeshGroup=new ft,this.tails=[]}explode(e){this.isExplode=!0,this.flower=this.getFlower(e),this.tails=this.getTail(),this.meshGroup.add(this.flower.mesh),this.meshGroup.add(this.tailMeshGroup)}getTail(){let e=[],n=this.flower.mesh.geometry.attributes.color;for(let r=0;r<this.petalsNum;r++){let s=[];for(let S=0;S<20;S++)s.push(new Z(0,0,0));let a=new pT(20,s,this.texture),{r:o,g:l,b:c,a:u}=Tp(r),f=n.array[o],v=n.array[l],m=n.array[c],y=n.array[u],b=a.mesh.geometry.attributes.position,_=a.mesh.geometry.attributes.color;for(let S=0;S<b.count;S++){let A=Tp(S);_.array[A.r]=f,_.array[A.g]=v,_.array[A.b]=m,_.array[A.a]=y}let{x:g,y:x,z:w}=this.flower.mesh.position;a.mesh.position.set(g,x,w),e.push(a),this.tailMeshGroup.add(a.mesh)}return e}update(e){if(this.isExplode){this.flower.update(e);let t=this.flower.mesh.geometry.attributes.position;for(let n=0,r=this.tails.length;n<r;n++){let s=this.tails[n];s.update(e);let{x:a,y:o,z:l}=Mp(n),c=new Z(t.array[a],t.array[o],t.array[l]),u=s.mesh.geometry.attributes.position,f=s.mesh.geometry.attributes.velocity;for(let v=0;v<u.count;v++){let m=Mp(v),y=new Z,b=new Z(u.array[m.x],u.array[m.y],u.array[m.z]),_=new Z(f.array[m.x],f.array[m.y],f.array[m.z]);y.subVectors(c,b);let g=y.sub(_);g.normalize(),g.multiplyScalar(Math.random()*3e-4*this.life),f.array[m.x]+=g.x,f.array[m.y]+=g.y,f.array[m.z]+=g.z}f.needsUpdate=!0}this.life>0&&(this.life-=1.2)}else this.drawTail()}},c4=class{fireworksInstances;scene;texture;particleSize;maxFireworks;constructor(e,t){this.fireworksInstances=[],this.scene=e,this.texture=Gze(),this.particleSize=t?.defaultParticleSize??zr.defaultParticleSize,this.maxFireworks=t?.maxActiveFireworks??zr.maxActiveFireworks}launchFirework(e){if(this.fireworksInstances.length>=this.maxFireworks)return;let t=e?.particleSize??this.particleSize,n=e?.position,r;e?.forceRich?r=new Fh(this.texture,t,n):e?.forceBasic?r=new kp(this.texture,t,n):r=Math.random()>.5?new kp(this.texture,t,n):new Fh(this.texture,t,n),this.fireworksInstances.push(r),this.scene.add(r.meshGroup)}update(){let e=[];for(let t=this.fireworksInstances.length-1;t>=0;t--){let n=this.fireworksInstances[t];n.update(zr.gravity),n.isExplode&&e.push(t)}for(let t=0,n=e.length;t<n;t++){let r=e[t],s=this.fireworksInstances[r];if(s&&(s.meshGroup.remove(s.seed.mesh),s.seed.disposeAll(),s.life<=0)){if(this.scene.remove(s.meshGroup),s instanceof Fh&&s.tailMeshGroup)for(let a of s.tails)a.disposeAll();s.flower?.disposeAll(),this.fireworksInstances.splice(r,1)}}}clear(){for(let e of this.fireworksInstances)if(this.scene.remove(e.meshGroup),e.seed.disposeAll(),e.flower&&e.flower.disposeAll(),e instanceof Fh)for(let t of e.tails)t.disposeAll();this.fireworksInstances=[]}dispose(){this.clear(),this.texture.dispose()}};vT();h();p();d();zt();var d4=Wr(ni(),1);h();p();d();zt();var gT=20,yT=40,Yze={white_banner:15,orange_banner:14,magenta_banner:13,light_blue_banner:12,yellow_banner:11,lime_banner:10,pink_banner:9,gray_banner:8,light_gray_banner:7,cyan_banner:6,purple_banner:5,blue_banner:4,brown_banner:3,green_banner:2,red_banner:1,black_banner:0},u4={0:"#1d1d21",1:"#b02e26",2:"#5e7c16",3:"#835432",4:"#3c44aa",5:"#8932b8",6:"#169c9c",7:"#9d9d97",8:"#474f52",9:"#f38baa",10:"#80c71f",11:"#fed83d",12:"#3ab3da",13:"#c74ebd",14:"#f9801d",15:"#f9fffe"};function Jze(i){let e=i.replace("_wall_banner","_banner");return Yze[e]??15}var Kze=(i,e,t,n,r,s,a)=>{switch(i.fillStyle=t,e){case"bs":i.fillRect(n,r,s,a);break;case"ls":i.fillRect(n,r,s/3,a);break;case"rs":i.fillRect(n+s*2/3,r,s/3,a);break;case"ts":i.fillRect(n,r,s,a/3);break;case"ms":i.fillRect(n,r+a/3,s,a/3);break;case"drs":i.fillRect(n,r,s/2,a/2);break;case"dls":i.fillRect(n+s/2,r,s/2,a/2);break;case"ss":for(let o=0;o<s;o+=2)i.fillRect(n+o,r,1,a);break;case"cr":i.fillRect(n,r+a/3,s,a/3),i.fillRect(n+s/3,r,s/3,a);break;case"sc":i.fillRect(n,r+a/2-1,s,2),i.fillRect(n+s/2-1,r,2,a);break;default:i.fillRect(n,r,s,a)}};function Zze(i,e){if(!e||e.length===0)return`banner_${i}_empty`;let t=e.map(n=>`${n.Pattern??"bs"}_${n.Color??0}`).join(",");return`banner_${i}_${t}`}var Qze=(i,e,t=(n,r)=>Dr(n,r))=>{let r=t(gT*1,yT*1),s=r.getContext("2d");if(!s){console.warn("Failed to get 2d context for banner rendering");return}s.imageSmoothingEnabled=!1;let a=u4[i]||u4[15];if(s.fillStyle=a,s.fillRect(0,0,gT*1,yT*1),e?.Patterns&&e.Patterns.length>0)for(let o of e.Patterns){let l=o.Color??0,c=o.Pattern??"bs",u=u4[l]||u4[0];Kze(s,c,u,0,0,gT*1,yT*1)}return r},f4=new Map;function Ipe(i,e,t){let n=Jze(e),r=Zze(n,t?.Patterns),s=f4.get(r);if(s)return s.refCount++,s.texture;let a=Qze(n,t);if(!a)return;let o=new Ht(a);return o.magFilter=et,o.minFilter=et,o.needsUpdate=!0,f4.set(r,{texture:o,refCount:1}),o}function h4(i){for(let[e,t]of f4.entries())if(t.texture===i){t.refCount--,t.refCount<=0&&(t.texture.dispose(),f4.delete(e));return}}function Lpe(i,e,t,n){let o,l,c;t?(o=(-14.6+13.4)/2/16-.5,l=1-14.75/16-.5,c=1/2):(o=(1.4+29.4)/2/16,l=1-7.25/16-.5,c=0);let u=new Ye(new Qn(.85,1.75),new ot({map:n,transparent:!0}));u.renderOrder=999;let f=.5/16,v=.25/16;t?u.position.set(0,o,l+v+.004):u.position.set(0,o,l+f/2+.004);let m=new ft;return m.rotation.set(0,-Pt.degToRad(e*(t?90:45/2)),0),m.add(u),m.bannerTexture=n,m.position.set(i.x+.5,i.y+c,i.z+.5),m}var p4=class{constructor(e,t,n,r){this.worldRenderer=e;this.scene=t;this.material=n;this.displayOptions=r}sectionObjects={};waitingChunksToDisplay={};estimatedMemoryUsage=0;handleWorkerGeometryMessage(e){let t=this.sectionObjects[e.key];t&&(this.removeSectionMemoryUsage(t),t.traverse(b=>{b.bannerTexture&&h4(b.bannerTexture)}),this.scene.remove(t),Hi(t),delete this.sectionObjects[e.key]);let n=e.key.split(",");if(!this.worldRenderer.loadedChunks[n[0]+","+n[2]]||!e.geometry.positions.length||!this.worldRenderer.active)return;let r=new at,s=new gt(e.geometry.positions,3),a=new gt(e.geometry.normals,3),o=new gt(e.geometry.colors,3),l=new gt(e.geometry.uvs,2),c=new gt(e.geometry.indices,1);r.setAttribute("position",s),r.setAttribute("normal",a),r.setAttribute("color",o),r.setAttribute("uv",l),r.index=c,this.addSectionMemoryUsage(r);let u=new Ye(r,this.material);u.position.set(e.geometry.sx,e.geometry.sy,e.geometry.sz),u.name="mesh",t=new ft,t.add(u);let f=e.geometry.sectionEndY-e.geometry.sectionStartY,v=16,m=new Ye(new on(v,f,v),new ot({color:0,transparent:!0,opacity:0}));m.position.set(e.geometry.sx,e.geometry.sy,e.geometry.sz);let y=new ua(m,16776960);if(y.name="helper",t.add(y),t.name="chunk",t.tilesCount=e.geometry.positions.length/3/4,t.blocksCount=e.geometry.blocksCount,this.displayOptions.inWorldRenderingConfig.showChunkBorders||(y.visible=!1),Object.keys(e.geometry.signs).length)for(let[b,{isWall:_,isHanging:g,rotation:x}]of Object.entries(e.geometry.signs)){let w=this.worldRenderer.blockEntities[b];if(!w)continue;let[S,A,P]=b.split(","),C=this.worldRenderer.renderSign(new lt(+S,+A,+P),x,_,g,d4.default.simplify(w));C&&t.add(C)}if(Object.keys(e.geometry.heads).length)for(let[b,{isWall:_,rotation:g}]of Object.entries(e.geometry.heads)){let x=this.worldRenderer.blockEntities[b];if(!x)continue;let[w,S,A]=b.split(","),P=this.worldRenderer.renderHead(new lt(+w,+S,+A),g,_,d4.default.simplify(x));P&&t.add(P)}if(Object.keys(e.geometry.banners).length)for(let[b,{isWall:_,rotation:g,blockName:x}]of Object.entries(e.geometry.banners)){let w=this.worldRenderer.blockEntities[b];if(!w)continue;let[S,A,P]=b.split(","),C=Ipe(this.worldRenderer,x,d4.default.simplify(w));if(!C)continue;let L=Lpe(new lt(+S,+A,+P),g,_,C);t.add(L)}if(this.sectionObjects[e.key]=t,this.displayOptions.inWorldRenderingConfig._renderByChunks){t.visible=!1;let b=`${n[0]},${n[2]}`;this.waitingChunksToDisplay[b]??=[],this.waitingChunksToDisplay[b].push(e.key),this.worldRenderer.finishedChunks[b]&&this.finishChunk(b)}this.worldRenderer.updatePosDataChunk(e.key),t.matrixAutoUpdate=!1,u.onAfterRender=(b,_,g,x,w,S)=>{},this.scene.add(t)}finishChunk(e){for(let t of this.waitingChunksToDisplay[e]??[])this.sectionObjects[t].visible=!0;delete this.waitingChunksToDisplay[e]}estimateGeometryMemoryUsage(e){let t=0,{attributes:n}=e;for(let[r,s]of Object.entries(n))if(s?.array){let a=s.array.BYTES_PER_ELEMENT;t+=s.array.length*a}if(e.index?.array){let r=e.index.array.BYTES_PER_ELEMENT;t+=e.index.array.length*r}return t}addSectionMemoryUsage(e){let t=this.estimateGeometryMemoryUsage(e);this.estimatedMemoryUsage+=t}removeSectionMemoryUsage(e){let t=e.children.find(n=>n.name==="mesh");if(t?.geometry){let n=this.estimateGeometryMemoryUsage(t.geometry);this.estimatedMemoryUsage-=n,this.estimatedMemoryUsage=Math.max(0,this.estimatedMemoryUsage)}}getEstimatedMemoryUsage(){let e=this.estimatedMemoryUsage,n=`${(e/(1024*1024)).toFixed(2)} MB`;return{bytes:e,readable:n}}resetWorld(){for(let e of Object.values(this.sectionObjects))this.removeSectionMemoryUsage(e),this.scene.remove(e);this.sectionObjects={},this.waitingChunksToDisplay={},this.estimatedMemoryUsage=0}removeColumn(e,t){let n=this.worldRenderer.getSectionHeight(),r=this.worldRenderer.worldMinYRender;if(Lc){let s=r;this.worldRenderer.setSectionDirty(new lt(e,s,t),!1);let a=`${e},${s},${t}`,o=this.sectionObjects[a];o&&(this.removeSectionMemoryUsage(o),o.traverse(l=>{l.bannerTexture&&h4(l.bannerTexture)}),this.scene.remove(o),Hi(o)),delete this.sectionObjects[a]}else for(let s=r;s<this.worldRenderer.worldSizeParams.worldHeight;s+=n){this.worldRenderer.setSectionDirty(new lt(e,s,t),!1);let a=`${e},${s},${t}`,o=this.sectionObjects[a];o&&(this.removeSectionMemoryUsage(o),o.traverse(l=>{l.bannerTexture&&h4(l.bannerTexture)}),this.scene.remove(o),Hi(o)),delete this.sectionObjects[a]}}};h();p();d();h();p();d();zt();var _T=2e3,Bpe=32,Npe=32,m4=.2,Ope=.4,v4=.02,eqe=-5,bT=class{constructor(e){this.worldRenderer=e}instancedMesh;geometry;material;particles=[];enabled=!1;dummy=new pt;tempPosition=new Z;tempQuaternion=new jt;tempScale=new Z;enable(){this.enabled||(this.enabled=!0,this.instancedMesh?this.instancedMesh.visible=!0:this.createRain())}disable(){this.enabled&&(this.enabled=!1,this.instancedMesh&&(this.instancedMesh.visible=!1))}autoEnableCheck(){return this.worldRenderer.worldRendererConfig.isRaining===!0}render=()=>{if(!this.enabled||!this.instancedMesh)return;let e=this.worldRenderer.getCameraPosition();this.instancedMesh.position.copy(e);let t=this.worldRenderer.reactiveState.world.heightmaps,{dummy:n,tempPosition:r,tempQuaternion:s,tempScale:a}=this,o=NaN,l=NaN,c;for(let u=0;u<_T;u++){let f=this.particles[u];this.instancedMesh.getMatrixAt(u,n),n.decompose(r,s,a),r.add(f.velocity);let v=r.y,m=Math.sqrt(r.x*r.x+r.z*r.z),y=e.x+r.x,b=e.y+r.y,_=e.z+r.z,g=Math.floor(y/16),x=Math.floor(_/16);(g!==o||x!==l)&&(c=t.get(`${g},${x}`),o=g,l=x);let w=(Math.floor(y)%16+16)%16,S=(Math.floor(_)%16+16)%16,A=c?.[S*16+w];if(m>Bpe||A!==void 0&&A!==-32768&&b<=A+1+f.despawnOffset||v<eqe){this.respawnParticle(r);let C=m4+Math.random()*(Ope-m4);f.velocity.set((Math.random()-.5)*v4,-C,(Math.random()-.5)*v4),f.despawnOffset=Math.random()*.5}n.compose(r,s,a),this.instancedMesh.setMatrixAt(u,n)}this.instancedMesh.instanceMatrix.needsUpdate=!0};dispose(){this.instancedMesh&&this.worldRenderer.scene.remove(this.instancedMesh),this.geometry?.dispose(),this.material?.dispose(),this.instancedMesh=void 0,this.geometry=void 0,this.material=void 0,this.particles=[]}createRain(){this.geometry=new on(.03,.3,.03),this.material=new ot({color:4482713,transparent:!0,opacity:.6}),this.instancedMesh=new y0(this.geometry,this.material,_T),this.instancedMesh.name="rain-particles";let e=new pt,t=new Z;for(let n=0;n<_T;n++){this.respawnParticle(t),t.y=Math.random()*Npe,e.setPosition(t),this.instancedMesh.setMatrixAt(n,e);let r=m4+Math.random()*(Ope-m4);this.particles.push({velocity:new Z((Math.random()-.5)*v4,-r,(Math.random()-.5)*v4),age:0,despawnOffset:Math.random()*.5})}this.instancedMesh.instanceMatrix.needsUpdate=!0,this.worldRenderer.scene.add(this.instancedMesh)}respawnParticle(e){let t=Math.random()*Math.PI*2,n=Math.random()*Bpe;e.set(Math.cos(t)*n,Npe,Math.sin(t)*n)}},Dpe={id:"rain",controller:bT,enabledDefault:!1,requiresHeightmap:!0};h();p();d();zt();var Vpe=new Ge(13/255,234/255,238/255),tqe=9;var nqe=350,rqe=650;var iqe=120,sqe=280,wT=class{constructor(e){this.worldRenderer=e;this.configEnabled=this.worldRenderer.worldRendererConfig.futuristicReveal===!0,this.wireframeMaterial=new dn({color:Vpe,transparent:!0,opacity:1,blending:sa,depthWrite:!1}),this.wireframeGlowMaterial=new dn({color:Vpe,transparent:!0,opacity:.55,blending:sa,depthWrite:!1})}pendingGeometries=new Map;revealingSections=new Map;finishedChunkCount=0;revealTriggered=!1;revealStartTime=0;enabled=!1;onWorldSwitchedCb=null;patched=!1;initialWaveDone=!1;wireframeMaterial;wireframeGlowMaterial;pulseTime=0;revealedChunks=new Set;originalFinishChunk=null;originalDestroy=null;originalSceneAdd=null;originalHandleWorkerMessage=null;originalWbgHandle=null;configEnabled=!0;enable(){this.configEnabled&&(this.enabled||(this.enabled=!0,this.patchWorldRenderer()))}disable(){this.enabled&&(this.enabled=!1,this.unpatchWorldRenderer(),this.reset())}toggle(){return this.enabled?this.disable():this.enable(),this.enabled}render=()=>{this.enabled&&this.update(16)};dispose(){this.disable(),this.wireframeMaterial.dispose(),this.wireframeGlowMaterial.dispose()}patchWorldRenderer(){if(this.patched)return;this.patched=!0;let e=this.worldRenderer;this.onWorldSwitchedCb=()=>this.reset(),e.onWorldSwitched.push(this.onWorldSwitchedCb),this.originalFinishChunk=e.finishChunk.bind(e),e.finishChunk=n=>{this.originalFinishChunk(n),this.onChunkFinished(n)},this.originalDestroy=e.destroy.bind(e),e.destroy=()=>{this.dispose(),this.originalDestroy()};let t=e.worldBlockGeometry;this.originalWbgHandle=t.handleWorkerGeometryMessage.bind(t),t.handleWorkerGeometryMessage=n=>{let r=this.originalWbgHandle(n);return this.enabled&&n?.type==="geometry"&&Promise.resolve().then(()=>{try{this.registerSection(n.key,n.geometry)}catch(s){console.error("[SciFiReveal] registerSection failed",s)}}),r},this.originalSceneAdd=e.scene.add.bind(e.scene),e.scene.add=(...n)=>{let r=this.originalSceneAdd(...n);for(let s of n)this.checkAndPatchMesh(s);return r}}unpatchWorldRenderer(){let e=this.worldRenderer;if(this.originalFinishChunk&&(e.finishChunk=this.originalFinishChunk,this.originalFinishChunk=null),this.originalDestroy&&(e.destroy=this.originalDestroy,this.originalDestroy=null),this.originalHandleWorkerMessage&&(e.handleWorkerMessage=this.originalHandleWorkerMessage,this.originalHandleWorkerMessage=null),this.originalSceneAdd&&(e.scene.add=this.originalSceneAdd,this.originalSceneAdd=null),this.originalWbgHandle&&(e.worldBlockGeometry.handleWorkerGeometryMessage=this.originalWbgHandle,this.originalWbgHandle=null),this.onWorldSwitchedCb){let t=e.onWorldSwitched.indexOf(this.onWorldSwitchedCb);t!==-1&&e.onWorldSwitched.splice(t,1),this.onWorldSwitchedCb=null}this.patched=!1}checkAndPatchMesh(e){if(e instanceof Ye&&e.name==="mesh"){let t=this.findSectionKeyForMesh(e);t&&this.shouldUseRevealEffect(t)&&(e.visible=!1,e.hiddenByReveal=!0)}for(let t of e.children)this.checkAndPatchMesh(t)}findSectionKeyForMesh(e){let t=e;for(;t;){let{sectionKey:u}=t;if(u&&this.worldRenderer.worldBlockGeometry.sectionObjects[u]===t)return u;t=t.parent}let n=e.position,r=16,s=this.worldRenderer.getSectionHeight(),a=Math.floor(n.x/r)*r,o=Math.floor(n.y/s)*s,l=Math.floor(n.z/r)*r,c=`${a},${o},${l}`;return this.worldRenderer.worldBlockGeometry.sectionObjects[c]?c:null}get scene(){return this.worldRenderer.scene}getCameraPosition(){return this.worldRenderer.getCameraPosition()}getOriginalMesh(e){let t=this.worldRenderer.worldBlockGeometry.sectionObjects[e];return t?t.children.find(n=>n.name==="mesh"):null}onChunkFinished(e){this.finishedChunkCount++,!this.revealTriggered&&this.finishedChunkCount>=tqe&&this.triggerReveal()}registerSection(e,t){this.revealedChunks.has(e)||this.revealingSections.has(e)||(this.revealTriggered?this.startSectionReveal(e,t):this.pendingGeometries.set(e,t))}shouldUseRevealEffect(e){return this.enabled&&!this.revealedChunks.has(e)&&!this.revealingSections.has(e)}triggerReveal(){this.revealTriggered=!0,this.initialWaveDone=!0,this.revealStartTime=performance.now();let e=this.getCameraPosition(),t=[...this.pendingGeometries.entries()];this.pendingGeometries.clear();let n=t.map(([s,a])=>{let o=Math.hypot(a.sx-e.x,a.sy-e.y,a.sz-e.z);return{key:s,geometry:a,distance:o}}).sort((s,a)=>s.distance-a.distance),r=n.at(-1)?.distance||1;for(let{key:s,geometry:a,distance:o}of n){let l=o/r*1500;setTimeout(()=>{!this.revealedChunks.has(s)&&!this.revealingSections.has(s)&&this.startSectionReveal(s,a)},l)}}startSectionReveal(e,t){if(!t.positions?.length||this.revealingSections.has(e)||this.revealedChunks.has(e))return;let n=this.createWireframeGeometry(t),r=this.getOriginalMesh(e);r&&(r.visible=!1,r.hiddenByReveal=!0);let s=new Yn(n,this.wireframeMaterial.clone());s.position.set(t.sx,t.sy,t.sz),s.name="scifi-wireframe",s.renderOrder=1e3;let a=new Yn(n.clone(),this.wireframeGlowMaterial.clone());a.position.copy(s.position),a.scale.set(1.02,1.02,1.02),a.name="scifi-glow",a.renderOrder=999;let o=new ft;o.add(s),o.add(a),o.name="scifi-reveal-group",o.sectionKey=e,this.scene.add(o);let l=this.initialWaveDone?iqe:nqe,c=this.initialWaveDone?sqe:rqe,u={key:e,wireframeGroup:o,revealStartTime:performance.now(),phase:"wireframe",originalMeshRef:null,wireframeMs:l,revealMs:c};setTimeout(()=>{let f=this.getOriginalMesh(e);f&&!f.hiddenByReveal&&(f.visible=!1,f.hiddenByReveal=!0)},0),this.revealingSections.set(e,u)}createWireframeGeometry(e){let t=e.positions,n=e.indices,r=[],s=new Set;for(let o=0;o<n.length;o+=3){let l=n[o],c=n[o+1],u=n[o+2];this.addEdge(t,l,c,r,s),this.addEdge(t,c,u,r,s),this.addEdge(t,u,l,r,s)}let a=new at;return a.setAttribute("position",new He(r,3)),a}addEdge(e,t,n,r,s){let a=Math.min(t,n),o=Math.max(t,n),l=`${a}-${o}`;s.has(l)||(s.add(l),r.push(e[t*3],e[t*3+1],e[t*3+2],e[n*3],e[n*3+1],e[n*3+2]))}update(e){if(!this.enabled||this.revealingSections.size===0)return;this.pulseTime+=e*.001;let t=performance.now(),n=.6+.4*Math.sin(this.pulseTime*4),r=[];for(let[s,a]of this.revealingSections){let o=t-a.revealStartTime;if(a.phase==="wireframe"){let l=a.wireframeGroup.children[0],c=a.wireframeGroup.children[1];if(l?.material){let u=l.material;u.opacity=n;let f=.85+.15*Math.sin(this.pulseTime*6+o*.002);u.color.setRGB(13/255*f,234/255*f,238/255*f)}if(c?.material){let u=c.material;u.opacity=n*.4}if(o>a.wireframeMs&&(a.phase="transitioning",a.originalMeshRef=this.getOriginalMesh(s),a.originalMeshRef)){a.originalMeshRef.visible=!0;let u=a.originalMeshRef.material,f=u.clone();f.transparent=!0,f.opacity=0,f.needsUpdate=!0,a.originalMeshRef.originalMaterial=u,a.originalMeshRef.material=f}}else if(a.phase==="transitioning"){let l=o-a.wireframeMs,c=Math.min(1,l/a.revealMs),u=1-(1-c)**3,f=a.wireframeGroup.children[0],v=a.wireframeGroup.children[1];if(f?.material){let m=f.material;m.opacity=1-u}if(v?.material){let m=v.material;m.opacity=(1-u)*.55}if(a.originalMeshRef?.material){let m=a.originalMeshRef.material;m.opacity=u}c>=1&&(a.phase="complete",r.push(a))}}for(let s of r)this.completeReveal(s)}completeReveal(e){if(this.revealingSections.delete(e.key),this.revealedChunks.add(e.key),e.originalMeshRef){let t=e.originalMeshRef.originalMaterial;if(t){let n=e.originalMeshRef.material;e.originalMeshRef.material=t,n.dispose(),delete e.originalMeshRef.originalMaterial}e.originalMeshRef.visible=!0,delete e.originalMeshRef.hiddenByReveal}this.disposeWireframeGroup(e.wireframeGroup)}disposeWireframeGroup(e){this.scene.remove(e);let t=[];e.traverse(n=>{t.push(n)});for(let n of t){let r=n;if(r.geometry&&r.geometry.dispose(),r.material){let s=r.material;if(Array.isArray(s))for(let a of s)a.dispose();else s&&typeof s.dispose=="function"&&s.dispose()}}e.clear()}reset(){for(let e of this.revealingSections.values())this.disposeWireframeGroup(e.wireframeGroup);this.pendingGeometries.clear(),this.revealingSections.clear(),this.revealedChunks.clear(),this.finishedChunkCount=0,this.revealTriggered=!1,this.revealStartTime=0,this.pulseTime=0}forceCompleteAll(){let e=[...this.revealingSections.values()];for(let t of e){if(t.originalMeshRef||(t.originalMeshRef=this.getOriginalMesh(t.key)),t.originalMeshRef){let n=t.originalMeshRef.originalMaterial;n&&(t.originalMeshRef.material=n),t.originalMeshRef.visible=!0}this.completeReveal(t)}}debugGetWireframeGroups(){let e=[];return this.scene.traverse(t=>{t.name==="scifi-reveal-group"&&e.push(t)}),e}debugForceCleanup(){let e=this.debugGetWireframeGroups();console.log(`[SciFiReveal] Found ${e.length} wireframe groups in scene`);for(let t of e)console.log("[SciFiReveal] Removing group:",t),this.disposeWireframeGroup(t);for(let t of this.revealingSections.values())this.disposeWireframeGroup(t.wireframeGroup);this.revealingSections.clear(),console.log(`[SciFiReveal] Cleanup complete. Remaining groups: ${this.debugGetWireframeGroups().length}`)}debugStatus(){let e=this.debugGetWireframeGroups(),t=new Set(this.revealingSections.keys()),n=e.filter(r=>!t.has(r.sectionKey));return{revealTriggered:this.revealTriggered,finishedChunkCount:this.finishedChunkCount,pendingGeometries:this.pendingGeometries.size,revealingSections:this.revealingSections.size,revealedChunks:this.revealedChunks.size,wireframeGroupsInScene:e.length,orphanedWireframeGroups:n.length,orphanedKeys:n.map(r=>r.sectionKey),sections:[...this.revealingSections.entries()].map(([r,s])=>({key:r,phase:s.phase,hasOriginalMesh:!!s.originalMeshRef,wireframeInScene:s.wireframeGroup.parent!==null}))}}debugLog(){console.log("[SciFiReveal] Status:",this.debugStatus())}},Upe={id:"futuristicReveal",controller:wT,enabledDefault:!0};h();p();d();zt();var aqe=parseInt(fa.replaceAll(/\D+/g,""),10),xT=class extends Tr{constructor(){super({uniforms:{time:{value:0},fade:{value:1}},vertexShader:`
|
|
29093
|
+
`,zr={textureSize:128,gravity:new Z(0,-.005,0),friction:.998,defaultParticleSize:300,maxActiveFireworks:5},Mp=i=>{let t=i*3;return{x:t,y:t+1,z:t+2}},Tp=i=>{let t=i*4;return{r:t,g:t+1,b:t+2,a:t+3}},tu=(i=0,e=0)=>Math.floor(Math.random()*(i+1-e))+e,Hze=(i,e,t,n)=>{i.save();let r=i.createRadialGradient(e,e,0,e,e,e);r.addColorStop(0,"rgba(255,255,255,1.0)"),r.addColorStop(.5,"rgba(255,255,255,0.5)"),r.addColorStop(1,"rgba(255,255,255,0)"),i.fillStyle=r,i.fillRect(0,0,t,n),i.restore()},Gze=()=>{let i=zr.textureSize,e=Dr(i,i),t=e.getContext("2d"),n=i/2;Hze(t,n,e.width,e.height);let r=new Ht(e);return r.needsUpdate=!0,r},Wze=(i,e,t,n,r=zr.defaultParticleSize)=>{let s=new at,a=[],o=[],l=[],c=[],u=[],f=Math.random()>.3?"single":"multiple",v=tu(100,20)*.01,m=()=>tu(100,1)*.01,y="red",b=Math.random();b>.66?y="red":b>.33?y="green":y="blue";for(let g=0;g<i;g++){let x=new Z(0,0,0);if(a.push(x.x,x.y,x.z),o.push(e[g].x,e[g].y,e[g].z),t==="seed"){let w=e[g].y**2*.04;g===0&&(w*=1.1),c.push(w),u.push(w*.017),l.push(1,1,1,1)}else if(t==="trail"){let w=Math.random()*.1+.1;c.push(w),u.push(w*.017),l.push(1,1,1,1)}else{let w=tu(r,10)*.001;if(c.push(w),u.push(w*.017),f==="multiple")l.push(m(),m(),m(),1);else switch(y){case"red":l.push(v,.1,.1,1);break;case"green":l.push(.1,v,.1,1);break;case"blue":l.push(.1,.1,v,1);break}}}s.setAttribute("position",new He(a,3)),s.setAttribute("velocity",new He(o,3)),s.setAttribute("color",new He(l,4)),s.setAttribute("adjustSize",new He(c,1)),s.setAttribute("mass",new He(u,1));let _=new h1({uniforms:{size:{value:zr.textureSize},texture:{value:n}},transparent:!0,depthWrite:!1,blending:sa,vertexShader:zze,fragmentShader:qze});return new Rr(s,_)},Rp=class{particleNum;timerStartFading;mesh;constructor(e,t,n,r,s){this.particleNum=e,this.timerStartFading=10,this.mesh=Wze(e,t,n,r,s)}update(e){this.timerStartFading>0&&(this.timerStartFading-=.3);let t=this.mesh.geometry.attributes.position,n=this.mesh.geometry.attributes.velocity,r=this.mesh.geometry.attributes.color,s=this.mesh.geometry.attributes.mass,a=()=>Math.random()>.5?.98:.96,o=l=>Math.random()>.5?0:(1-l)*.1;for(let l=0;l<this.particleNum;l++){let{x:c,y:u,z:f}=Mp(l);n.array[u]+=e.y-s.array[l],n.array[c]*=zr.friction,n.array[f]*=zr.friction,n.array[u]*=zr.friction,t.array[c]+=n.array[c],t.array[u]+=n.array[u],t.array[f]+=n.array[f];let{a:v}=Tp(l);this.timerStartFading<=0&&(r.array[v]*=a()-o(r.array[v]),r.array[v]<.001&&(r.array[v]=0))}t.needsUpdate=!0,n.needsUpdate=!0,r.needsUpdate=!0}disposeAll(){this.mesh.geometry.dispose(),this.mesh.material.dispose()}},dT=class extends Rp{constructor(e,t,n){super(e,t,"seed",n)}update(e){let t=this.mesh.geometry.attributes.position,n=this.mesh.geometry.attributes.velocity,r=this.mesh.geometry.attributes.color,s=this.mesh.geometry.attributes.mass,a=()=>Math.random()>.3?.99:.96,o=f=>Math.random()>.3?0:(1-f)*.1,l=()=>Math.random()>.5?.05:-.05,c=()=>Math.random()>.1,u=zr.friction*.98;for(let f=0;f<this.particleNum;f++){let{x:v,y:m,z:y}=Mp(f);n.array[m]+=e.y-s.array[f],n.array[v]*=u,n.array[y]*=u,n.array[m]*=u,t.array[v]+=n.array[v],t.array[m]+=n.array[m],t.array[y]+=n.array[y],c()&&(t.array[v]+=l()),c()&&(t.array[y]+=l());let{a:b}=Tp(f);r.array[b]*=a()-o(r.array[b]),r.array[b]<.001&&(r.array[b]=0)}t.needsUpdate=!0,n.needsUpdate=!0,r.needsUpdate=!0}},pT=class extends Rp{constructor(e,t,n){super(e,t,"trail",n)}update(e){let t=this.mesh.geometry.attributes.position,n=this.mesh.geometry.attributes.velocity,r=this.mesh.geometry.attributes.color,s=this.mesh.geometry.attributes.mass,a=()=>Math.random()>.3?.98:.95,o=()=>Math.random()>.5?.05:-.05,l=()=>Math.random()>.2;for(let c=0;c<this.particleNum;c++){let{x:u,y:f,z:v}=Mp(c);n.array[f]+=e.y-s.array[c],n.array[u]*=zr.friction,n.array[v]*=zr.friction,n.array[f]*=zr.friction,t.array[u]+=n.array[u],t.array[f]+=n.array[f],t.array[v]+=n.array[v],l()&&(t.array[u]+=o()),l()&&(t.array[v]+=o());let{a:m}=Tp(c);r.array[m]*=a(),r.array[m]<.001&&(r.array[m]=0)}t.needsUpdate=!0,n.needsUpdate=!0,r.needsUpdate=!0}},kp=class{meshGroup;isExplode;petalsNum;life;seed;flowerSizeRate;flower;texture;particleSize;constructor(e,t=zr.defaultParticleSize,n){this.meshGroup=new ft,this.isExplode=!1,this.texture=e,this.particleSize=t;let r=400,s=150;this.petalsNum=tu(r,s),this.life=150,this.seed=this.getSeed(n),this.meshGroup.add(this.seed.mesh),this.flowerSizeRate=Pt.mapLinear(this.petalsNum,s,r,.4,.7)}getSeed(e){let n=[];for(let s=0;s<40;s++){let o=s===0?Math.random()*2.5+.9:Math.random()*2+.4,l=0;n.push(new Z(0,o,l))}let r=new dT(40,n,this.texture);if(e)r.mesh.position.set(e.x,e.y,e.z);else{let s=Math.random()*80-40,a=-50,o=Math.random()*80-40;r.mesh.position.set(s,a,o)}return r}explode(e){this.isExplode=!0,this.flower=this.getFlower(e),this.meshGroup.add(this.flower.mesh),this.meshGroup.remove(this.seed.mesh),this.seed.disposeAll()}getFlower(e){let t=this.petalsNum,n=[],r;if(Math.random()>.5)for(let o=0;o<t;o++){r=tu(120,60)*.01;let l=Pt.degToRad(Math.random()*180),c=Pt.degToRad(Math.random()*360),u=Math.sin(l)*Math.cos(c)*r,f=Math.sin(l)*Math.sin(c)*r,v=Math.cos(l)*r,m=new Z(u,f,v);m.multiplyScalar(this.flowerSizeRate),n.push(m)}else{let o=180/t,l=360*(Math.random()*20+1)/t,c=l,u=l;r=tu(120,60)*.01;for(let f=0;f<t;f++){let v=Math.sin(Pt.degToRad(o*f)),m=Math.cos(Pt.degToRad(o*f))*r,y=Math.cos(Pt.degToRad(c*f))*v*r,b=Math.sin(Pt.degToRad(u*f))*v*r,_=new Z(y,b,m);_.multiplyScalar(this.flowerSizeRate),n.push(_)}}let a=new Rp(t,n,"default",this.texture,this.particleSize);return a.mesh.position.set(e.x,e.y,e.z),a}update(e){this.isExplode?(this.flower.update(e),this.life>0&&(this.life-=1)):this.drawTail()}drawTail(){this.seed.update(zr.gravity);let e=this.seed.mesh.geometry.attributes.position,t=this.seed.mesh.geometry.attributes.velocity,n=0;for(let f=0,v=t.array.length;f<v;f++){let m=t.array[f];f%3===1&&m>0&&n++}if(!(n===0))return;let{x:s,y:a,z:o}=this.seed.mesh.position,l=new Z(s,a,o),c=0,u;for(let f=0,v=e.array.length;f<v;f++){let m=e.array[f];f%3===1&&m>c&&(c=m,u=new Z(e.array[f-1],m,e.array[f+2]))}u&&(l.add(u),this.explode(l))}},Fh=class extends kp{tailMeshGroup;tails;constructor(e,t=zr.defaultParticleSize,n){super(e,t,n);let r=150,s=100;this.petalsNum=tu(r,s),this.flowerSizeRate=Pt.mapLinear(this.petalsNum,s,r,.4,.7),this.tailMeshGroup=new ft,this.tails=[]}explode(e){this.isExplode=!0,this.flower=this.getFlower(e),this.tails=this.getTail(),this.meshGroup.add(this.flower.mesh),this.meshGroup.add(this.tailMeshGroup)}getTail(){let e=[],n=this.flower.mesh.geometry.attributes.color;for(let r=0;r<this.petalsNum;r++){let s=[];for(let S=0;S<20;S++)s.push(new Z(0,0,0));let a=new pT(20,s,this.texture),{r:o,g:l,b:c,a:u}=Tp(r),f=n.array[o],v=n.array[l],m=n.array[c],y=n.array[u],b=a.mesh.geometry.attributes.position,_=a.mesh.geometry.attributes.color;for(let S=0;S<b.count;S++){let A=Tp(S);_.array[A.r]=f,_.array[A.g]=v,_.array[A.b]=m,_.array[A.a]=y}let{x:g,y:x,z:w}=this.flower.mesh.position;a.mesh.position.set(g,x,w),e.push(a),this.tailMeshGroup.add(a.mesh)}return e}update(e){if(this.isExplode){this.flower.update(e);let t=this.flower.mesh.geometry.attributes.position;for(let n=0,r=this.tails.length;n<r;n++){let s=this.tails[n];s.update(e);let{x:a,y:o,z:l}=Mp(n),c=new Z(t.array[a],t.array[o],t.array[l]),u=s.mesh.geometry.attributes.position,f=s.mesh.geometry.attributes.velocity;for(let v=0;v<u.count;v++){let m=Mp(v),y=new Z,b=new Z(u.array[m.x],u.array[m.y],u.array[m.z]),_=new Z(f.array[m.x],f.array[m.y],f.array[m.z]);y.subVectors(c,b);let g=y.sub(_);g.normalize(),g.multiplyScalar(Math.random()*3e-4*this.life),f.array[m.x]+=g.x,f.array[m.y]+=g.y,f.array[m.z]+=g.z}f.needsUpdate=!0}this.life>0&&(this.life-=1.2)}else this.drawTail()}},c4=class{fireworksInstances;scene;texture;particleSize;maxFireworks;constructor(e,t){this.fireworksInstances=[],this.scene=e,this.texture=Gze(),this.particleSize=t?.defaultParticleSize??zr.defaultParticleSize,this.maxFireworks=t?.maxActiveFireworks??zr.maxActiveFireworks}launchFirework(e){if(this.fireworksInstances.length>=this.maxFireworks)return;let t=e?.particleSize??this.particleSize,n=e?.position,r;e?.forceRich?r=new Fh(this.texture,t,n):e?.forceBasic?r=new kp(this.texture,t,n):r=Math.random()>.5?new kp(this.texture,t,n):new Fh(this.texture,t,n),this.fireworksInstances.push(r),this.scene.add(r.meshGroup)}update(){let e=[];for(let t=this.fireworksInstances.length-1;t>=0;t--){let n=this.fireworksInstances[t];n.update(zr.gravity),n.isExplode&&e.push(t)}for(let t=0,n=e.length;t<n;t++){let r=e[t],s=this.fireworksInstances[r];if(s&&(s.meshGroup.remove(s.seed.mesh),s.seed.disposeAll(),s.life<=0)){if(this.scene.remove(s.meshGroup),s instanceof Fh&&s.tailMeshGroup)for(let a of s.tails)a.disposeAll();s.flower?.disposeAll(),this.fireworksInstances.splice(r,1)}}}clear(){for(let e of this.fireworksInstances)if(this.scene.remove(e.meshGroup),e.seed.disposeAll(),e.flower&&e.flower.disposeAll(),e instanceof Fh)for(let t of e.tails)t.disposeAll();this.fireworksInstances=[]}dispose(){this.clear(),this.texture.dispose()}};vT();h();p();d();zt();var d4=Wr(ni(),1);h();p();d();zt();var gT=20,yT=40,Yze={white_banner:15,orange_banner:14,magenta_banner:13,light_blue_banner:12,yellow_banner:11,lime_banner:10,pink_banner:9,gray_banner:8,light_gray_banner:7,cyan_banner:6,purple_banner:5,blue_banner:4,brown_banner:3,green_banner:2,red_banner:1,black_banner:0},u4={0:"#1d1d21",1:"#b02e26",2:"#5e7c16",3:"#835432",4:"#3c44aa",5:"#8932b8",6:"#169c9c",7:"#9d9d97",8:"#474f52",9:"#f38baa",10:"#80c71f",11:"#fed83d",12:"#3ab3da",13:"#c74ebd",14:"#f9801d",15:"#f9fffe"};function Jze(i){let e=i.replace("_wall_banner","_banner");return Yze[e]??15}var Kze=(i,e,t,n,r,s,a)=>{switch(i.fillStyle=t,e){case"bs":i.fillRect(n,r,s,a);break;case"ls":i.fillRect(n,r,s/3,a);break;case"rs":i.fillRect(n+s*2/3,r,s/3,a);break;case"ts":i.fillRect(n,r,s,a/3);break;case"ms":i.fillRect(n,r+a/3,s,a/3);break;case"drs":i.fillRect(n,r,s/2,a/2);break;case"dls":i.fillRect(n+s/2,r,s/2,a/2);break;case"ss":for(let o=0;o<s;o+=2)i.fillRect(n+o,r,1,a);break;case"cr":i.fillRect(n,r+a/3,s,a/3),i.fillRect(n+s/3,r,s/3,a);break;case"sc":i.fillRect(n,r+a/2-1,s,2),i.fillRect(n+s/2-1,r,2,a);break;default:i.fillRect(n,r,s,a)}};function Zze(i,e){if(!e||e.length===0)return`banner_${i}_empty`;let t=e.map(n=>`${n.Pattern??"bs"}_${n.Color??0}`).join(",");return`banner_${i}_${t}`}var Qze=(i,e,t=(n,r)=>Dr(n,r))=>{let r=t(gT*1,yT*1),s=r.getContext("2d");if(!s){console.warn("Failed to get 2d context for banner rendering");return}s.imageSmoothingEnabled=!1;let a=u4[i]||u4[15];if(s.fillStyle=a,s.fillRect(0,0,gT*1,yT*1),e?.Patterns&&e.Patterns.length>0)for(let o of e.Patterns){let l=o.Color??0,c=o.Pattern??"bs",u=u4[l]||u4[0];Kze(s,c,u,0,0,gT*1,yT*1)}return r},f4=new Map;function Ipe(i,e,t){let n=Jze(e),r=Zze(n,t?.Patterns),s=f4.get(r);if(s)return s.refCount++,s.texture;let a=Qze(n,t);if(!a)return;let o=new Ht(a);return o.magFilter=et,o.minFilter=et,o.needsUpdate=!0,f4.set(r,{texture:o,refCount:1}),o}function h4(i){for(let[e,t]of f4.entries())if(t.texture===i){t.refCount--,t.refCount<=0&&(t.texture.dispose(),f4.delete(e));return}}function Lpe(i,e,t,n){let o,l,c;t?(o=(-14.6+13.4)/2/16-.5,l=1-14.75/16-.5,c=1/2):(o=(1.4+29.4)/2/16,l=1-7.25/16-.5,c=0);let u=new Ye(new Qn(.85,1.75),new ot({map:n,transparent:!0}));u.renderOrder=999;let f=.5/16,v=.25/16;t?u.position.set(0,o,l+v+.004):u.position.set(0,o,l+f/2+.004);let m=new ft;return m.rotation.set(0,-Pt.degToRad(e*(t?90:45/2)),0),m.add(u),m.bannerTexture=n,m.position.set(i.x+.5,i.y+c,i.z+.5),m}var p4=class{constructor(e,t,n,r){this.worldRenderer=e;this.scene=t;this.material=n;this.displayOptions=r}sectionObjects={};waitingChunksToDisplay={};estimatedMemoryUsage=0;handleWorkerGeometryMessage(e){let t=this.sectionObjects[e.key];t&&(this.removeSectionMemoryUsage(t),t.traverse(b=>{b.bannerTexture&&h4(b.bannerTexture)}),this.scene.remove(t),Hi(t),delete this.sectionObjects[e.key]);let n=e.key.split(",");if(!this.worldRenderer.loadedChunks[n[0]+","+n[2]]||!e.geometry.positions.length||!this.worldRenderer.active)return;let r=new at,s=new gt(e.geometry.positions,3),a=new gt(e.geometry.normals,3),o=new gt(e.geometry.colors,3),l=new gt(e.geometry.uvs,2),c=new gt(e.geometry.indices,1);r.setAttribute("position",s),r.setAttribute("normal",a),r.setAttribute("color",o),r.setAttribute("uv",l),r.index=c,this.addSectionMemoryUsage(r);let u=new Ye(r,this.material);u.position.set(e.geometry.sx,e.geometry.sy,e.geometry.sz),u.name="mesh",t=new ft,t.add(u);let f=e.geometry.sectionEndY-e.geometry.sectionStartY,v=16,m=new Ye(new on(v,f,v),new ot({color:0,transparent:!0,opacity:0}));m.position.set(e.geometry.sx,e.geometry.sy,e.geometry.sz);let y=new ua(m,16776960);if(y.name="helper",t.add(y),t.name="chunk",t.tilesCount=e.geometry.positions.length/3/4,t.blocksCount=e.geometry.blocksCount,this.displayOptions.inWorldRenderingConfig.showChunkBorders||(y.visible=!1),Object.keys(e.geometry.signs).length)for(let[b,{isWall:_,isHanging:g,rotation:x}]of Object.entries(e.geometry.signs)){let w=this.worldRenderer.blockEntities[b];if(!w)continue;let[S,A,P]=b.split(","),C=this.worldRenderer.renderSign(new lt(+S,+A,+P),x,_,g,d4.default.simplify(w));C&&t.add(C)}if(Object.keys(e.geometry.heads).length)for(let[b,{isWall:_,rotation:g}]of Object.entries(e.geometry.heads)){let x=this.worldRenderer.blockEntities[b];if(!x)continue;let[w,S,A]=b.split(","),P=this.worldRenderer.renderHead(new lt(+w,+S,+A),g,_,d4.default.simplify(x));P&&t.add(P)}if(Object.keys(e.geometry.banners).length)for(let[b,{isWall:_,rotation:g,blockName:x}]of Object.entries(e.geometry.banners)){let w=this.worldRenderer.blockEntities[b];if(!w)continue;let[S,A,P]=b.split(","),C=Ipe(this.worldRenderer,x,d4.default.simplify(w));if(!C)continue;let L=Lpe(new lt(+S,+A,+P),g,_,C);t.add(L)}if(this.sectionObjects[e.key]=t,this.displayOptions.inWorldRenderingConfig._renderByChunks){t.visible=!1;let b=`${n[0]},${n[2]}`;this.waitingChunksToDisplay[b]??=[],this.waitingChunksToDisplay[b].push(e.key),this.worldRenderer.finishedChunks[b]&&this.finishChunk(b)}this.worldRenderer.updatePosDataChunk(e.key),t.matrixAutoUpdate=!1,u.onAfterRender=(b,_,g,x,w,S)=>{},this.scene.add(t)}finishChunk(e){for(let t of this.waitingChunksToDisplay[e]??[])this.sectionObjects[t].visible=!0;delete this.waitingChunksToDisplay[e]}estimateGeometryMemoryUsage(e){let t=0,{attributes:n}=e;for(let[r,s]of Object.entries(n))if(s?.array){let a=s.array.BYTES_PER_ELEMENT;t+=s.array.length*a}if(e.index?.array){let r=e.index.array.BYTES_PER_ELEMENT;t+=e.index.array.length*r}return t}addSectionMemoryUsage(e){let t=this.estimateGeometryMemoryUsage(e);this.estimatedMemoryUsage+=t}removeSectionMemoryUsage(e){let t=e.children.find(n=>n.name==="mesh");if(t?.geometry){let n=this.estimateGeometryMemoryUsage(t.geometry);this.estimatedMemoryUsage-=n,this.estimatedMemoryUsage=Math.max(0,this.estimatedMemoryUsage)}}getEstimatedMemoryUsage(){let e=this.estimatedMemoryUsage,n=`${(e/(1024*1024)).toFixed(2)} MB`;return{bytes:e,readable:n}}resetWorld(){for(let e of Object.values(this.sectionObjects))this.removeSectionMemoryUsage(e),this.scene.remove(e);this.sectionObjects={},this.waitingChunksToDisplay={},this.estimatedMemoryUsage=0}removeColumn(e,t){let n=this.worldRenderer.getSectionHeight(),r=this.worldRenderer.worldMinYRender;if(Lc){let s=r;this.worldRenderer.setSectionDirty(new lt(e,s,t),!1);let a=`${e},${s},${t}`,o=this.sectionObjects[a];o&&(this.removeSectionMemoryUsage(o),o.traverse(l=>{l.bannerTexture&&h4(l.bannerTexture)}),this.scene.remove(o),Hi(o)),delete this.sectionObjects[a]}else for(let s=r;s<this.worldRenderer.worldSizeParams.worldHeight;s+=n){this.worldRenderer.setSectionDirty(new lt(e,s,t),!1);let a=`${e},${s},${t}`,o=this.sectionObjects[a];o&&(this.removeSectionMemoryUsage(o),o.traverse(l=>{l.bannerTexture&&h4(l.bannerTexture)}),this.scene.remove(o),Hi(o)),delete this.sectionObjects[a]}}};h();p();d();h();p();d();zt();var _T=2e3,Bpe=32,Npe=32,m4=12,Ope=24,v4=1.2,eqe=-5,bT=class{constructor(e){this.worldRenderer=e}instancedMesh;geometry;material;particles=[];enabled=!1;dummy=new pt;tempPosition=new Z;tempQuaternion=new jt;tempScale=new Z;enable(){this.enabled||(this.enabled=!0,this.instancedMesh?this.instancedMesh.visible=!0:this.createRain())}disable(){this.enabled&&(this.enabled=!1,this.instancedMesh&&(this.instancedMesh.visible=!1))}autoEnableCheck(){return this.worldRenderer.worldRendererConfig.isRaining===!0}render=e=>{if(!this.enabled||!this.instancedMesh)return;let t=this.worldRenderer.getCameraPosition();this.instancedMesh.position.copy(t);let n=this.worldRenderer.reactiveState.world.heightmaps,{dummy:r,tempPosition:s,tempQuaternion:a,tempScale:o}=this,l=NaN,c=NaN,u;for(let f=0;f<_T;f++){let v=this.particles[f];this.instancedMesh.getMatrixAt(f,r),r.decompose(s,a,o),s.addScaledVector(v.velocity,e);let m=s.y,y=Math.sqrt(s.x*s.x+s.z*s.z),b=t.x+s.x,_=t.y+s.y,g=t.z+s.z,x=Math.floor(b/16),w=Math.floor(g/16);(x!==l||w!==c)&&(u=n.get(`${x},${w}`),l=x,c=w);let S=(Math.floor(b)%16+16)%16,A=(Math.floor(g)%16+16)%16,P=u?.[A*16+S];if(y>Bpe||P!==void 0&&P!==-32768&&_<=P+1+v.despawnOffset||m<eqe){this.respawnParticle(s);let L=m4+Math.random()*(Ope-m4);v.velocity.set((Math.random()-.5)*v4,-L,(Math.random()-.5)*v4),v.despawnOffset=Math.random()*.5}r.compose(s,a,o),this.instancedMesh.setMatrixAt(f,r)}this.instancedMesh.instanceMatrix.needsUpdate=!0};dispose(){this.instancedMesh&&this.worldRenderer.scene.remove(this.instancedMesh),this.geometry?.dispose(),this.material?.dispose(),this.instancedMesh=void 0,this.geometry=void 0,this.material=void 0,this.particles=[]}createRain(){this.geometry=new on(.03,.3,.03),this.material=new ot({color:4482713,transparent:!0,opacity:.6}),this.instancedMesh=new y0(this.geometry,this.material,_T),this.instancedMesh.name="rain-particles";let e=new pt,t=new Z;for(let n=0;n<_T;n++){this.respawnParticle(t),t.y=Math.random()*Npe,e.setPosition(t),this.instancedMesh.setMatrixAt(n,e);let r=m4+Math.random()*(Ope-m4);this.particles.push({velocity:new Z((Math.random()-.5)*v4,-r,(Math.random()-.5)*v4),age:0,despawnOffset:Math.random()*.5})}this.instancedMesh.instanceMatrix.needsUpdate=!0,this.worldRenderer.scene.add(this.instancedMesh)}respawnParticle(e){let t=Math.random()*Math.PI*2,n=Math.random()*Bpe;e.set(Math.cos(t)*n,Npe,Math.sin(t)*n)}},Dpe={id:"rain",controller:bT,enabledDefault:!1,requiresHeightmap:!0};h();p();d();zt();var Vpe=new Ge(13/255,234/255,238/255),tqe=9;var nqe=350,rqe=650;var iqe=120,sqe=280,wT=class{constructor(e){this.worldRenderer=e;this.configEnabled=this.worldRenderer.worldRendererConfig.futuristicReveal===!0,this.wireframeMaterial=new dn({color:Vpe,transparent:!0,opacity:1,blending:sa,depthWrite:!1}),this.wireframeGlowMaterial=new dn({color:Vpe,transparent:!0,opacity:.55,blending:sa,depthWrite:!1})}pendingGeometries=new Map;revealingSections=new Map;finishedChunkCount=0;revealTriggered=!1;revealStartTime=0;enabled=!1;onWorldSwitchedCb=null;patched=!1;initialWaveDone=!1;wireframeMaterial;wireframeGlowMaterial;pulseTime=0;revealedChunks=new Set;originalFinishChunk=null;originalDestroy=null;originalSceneAdd=null;originalHandleWorkerMessage=null;originalWbgHandle=null;configEnabled=!0;enable(){this.configEnabled&&(this.enabled||(this.enabled=!0,this.patchWorldRenderer()))}disable(){this.enabled&&(this.enabled=!1,this.unpatchWorldRenderer(),this.reset())}toggle(){return this.enabled?this.disable():this.enable(),this.enabled}render=e=>{this.enabled&&this.update(e*1e3)};dispose(){this.disable(),this.wireframeMaterial.dispose(),this.wireframeGlowMaterial.dispose()}patchWorldRenderer(){if(this.patched)return;this.patched=!0;let e=this.worldRenderer;this.onWorldSwitchedCb=()=>this.reset(),e.onWorldSwitched.push(this.onWorldSwitchedCb),this.originalFinishChunk=e.finishChunk.bind(e),e.finishChunk=n=>{this.originalFinishChunk(n),this.onChunkFinished(n)},this.originalDestroy=e.destroy.bind(e),e.destroy=()=>{this.dispose(),this.originalDestroy()};let t=e.worldBlockGeometry;this.originalWbgHandle=t.handleWorkerGeometryMessage.bind(t),t.handleWorkerGeometryMessage=n=>{let r=this.originalWbgHandle(n);return this.enabled&&n?.type==="geometry"&&Promise.resolve().then(()=>{try{this.registerSection(n.key,n.geometry)}catch(s){console.error("[SciFiReveal] registerSection failed",s)}}),r},this.originalSceneAdd=e.scene.add.bind(e.scene),e.scene.add=(...n)=>{let r=this.originalSceneAdd(...n);for(let s of n)this.checkAndPatchMesh(s);return r}}unpatchWorldRenderer(){let e=this.worldRenderer;if(this.originalFinishChunk&&(e.finishChunk=this.originalFinishChunk,this.originalFinishChunk=null),this.originalDestroy&&(e.destroy=this.originalDestroy,this.originalDestroy=null),this.originalHandleWorkerMessage&&(e.handleWorkerMessage=this.originalHandleWorkerMessage,this.originalHandleWorkerMessage=null),this.originalSceneAdd&&(e.scene.add=this.originalSceneAdd,this.originalSceneAdd=null),this.originalWbgHandle&&(e.worldBlockGeometry.handleWorkerGeometryMessage=this.originalWbgHandle,this.originalWbgHandle=null),this.onWorldSwitchedCb){let t=e.onWorldSwitched.indexOf(this.onWorldSwitchedCb);t!==-1&&e.onWorldSwitched.splice(t,1),this.onWorldSwitchedCb=null}this.patched=!1}checkAndPatchMesh(e){if(e instanceof Ye&&e.name==="mesh"){let t=this.findSectionKeyForMesh(e);t&&this.shouldUseRevealEffect(t)&&(e.visible=!1,e.hiddenByReveal=!0)}for(let t of e.children)this.checkAndPatchMesh(t)}findSectionKeyForMesh(e){let t=e;for(;t;){let{sectionKey:u}=t;if(u&&this.worldRenderer.worldBlockGeometry.sectionObjects[u]===t)return u;t=t.parent}let n=e.position,r=16,s=this.worldRenderer.getSectionHeight(),a=Math.floor(n.x/r)*r,o=Math.floor(n.y/s)*s,l=Math.floor(n.z/r)*r,c=`${a},${o},${l}`;return this.worldRenderer.worldBlockGeometry.sectionObjects[c]?c:null}get scene(){return this.worldRenderer.scene}getCameraPosition(){return this.worldRenderer.getCameraPosition()}getOriginalMesh(e){let t=this.worldRenderer.worldBlockGeometry.sectionObjects[e];return t?t.children.find(n=>n.name==="mesh"):null}onChunkFinished(e){this.finishedChunkCount++,!this.revealTriggered&&this.finishedChunkCount>=tqe&&this.triggerReveal()}registerSection(e,t){this.revealedChunks.has(e)||this.revealingSections.has(e)||(this.revealTriggered?this.startSectionReveal(e,t):this.pendingGeometries.set(e,t))}shouldUseRevealEffect(e){return this.enabled&&!this.revealedChunks.has(e)&&!this.revealingSections.has(e)}triggerReveal(){this.revealTriggered=!0,this.initialWaveDone=!0,this.revealStartTime=performance.now();let e=this.getCameraPosition(),t=[...this.pendingGeometries.entries()];this.pendingGeometries.clear();let n=t.map(([s,a])=>{let o=Math.hypot(a.sx-e.x,a.sy-e.y,a.sz-e.z);return{key:s,geometry:a,distance:o}}).sort((s,a)=>s.distance-a.distance),r=n.at(-1)?.distance||1;for(let{key:s,geometry:a,distance:o}of n){let l=o/r*1500;setTimeout(()=>{!this.revealedChunks.has(s)&&!this.revealingSections.has(s)&&this.startSectionReveal(s,a)},l)}}startSectionReveal(e,t){if(!t.positions?.length||this.revealingSections.has(e)||this.revealedChunks.has(e))return;let n=this.createWireframeGeometry(t),r=this.getOriginalMesh(e);r&&(r.visible=!1,r.hiddenByReveal=!0);let s=new Yn(n,this.wireframeMaterial.clone());s.position.set(t.sx,t.sy,t.sz),s.name="scifi-wireframe",s.renderOrder=1e3;let a=new Yn(n.clone(),this.wireframeGlowMaterial.clone());a.position.copy(s.position),a.scale.set(1.02,1.02,1.02),a.name="scifi-glow",a.renderOrder=999;let o=new ft;o.add(s),o.add(a),o.name="scifi-reveal-group",o.sectionKey=e,this.scene.add(o);let l=this.initialWaveDone?iqe:nqe,c=this.initialWaveDone?sqe:rqe,u={key:e,wireframeGroup:o,revealStartTime:performance.now(),phase:"wireframe",originalMeshRef:null,wireframeMs:l,revealMs:c};setTimeout(()=>{let f=this.getOriginalMesh(e);f&&!f.hiddenByReveal&&(f.visible=!1,f.hiddenByReveal=!0)},0),this.revealingSections.set(e,u)}createWireframeGeometry(e){let t=e.positions,n=e.indices,r=[],s=new Set;for(let o=0;o<n.length;o+=3){let l=n[o],c=n[o+1],u=n[o+2];this.addEdge(t,l,c,r,s),this.addEdge(t,c,u,r,s),this.addEdge(t,u,l,r,s)}let a=new at;return a.setAttribute("position",new He(r,3)),a}addEdge(e,t,n,r,s){let a=Math.min(t,n),o=Math.max(t,n),l=`${a}-${o}`;s.has(l)||(s.add(l),r.push(e[t*3],e[t*3+1],e[t*3+2],e[n*3],e[n*3+1],e[n*3+2]))}update(e){if(!this.enabled||this.revealingSections.size===0)return;this.pulseTime+=e*.001;let t=performance.now(),n=.6+.4*Math.sin(this.pulseTime*4),r=[];for(let[s,a]of this.revealingSections){let o=t-a.revealStartTime;if(a.phase==="wireframe"){let l=a.wireframeGroup.children[0],c=a.wireframeGroup.children[1];if(l?.material){let u=l.material;u.opacity=n;let f=.85+.15*Math.sin(this.pulseTime*6+o*.002);u.color.setRGB(13/255*f,234/255*f,238/255*f)}if(c?.material){let u=c.material;u.opacity=n*.4}if(o>a.wireframeMs&&(a.phase="transitioning",a.originalMeshRef=this.getOriginalMesh(s),a.originalMeshRef)){a.originalMeshRef.visible=!0;let u=a.originalMeshRef.material,f=u.clone();f.transparent=!0,f.opacity=0,f.needsUpdate=!0,a.originalMeshRef.originalMaterial=u,a.originalMeshRef.material=f}}else if(a.phase==="transitioning"){let l=o-a.wireframeMs,c=Math.min(1,l/a.revealMs),u=1-(1-c)**3,f=a.wireframeGroup.children[0],v=a.wireframeGroup.children[1];if(f?.material){let m=f.material;m.opacity=1-u}if(v?.material){let m=v.material;m.opacity=(1-u)*.55}if(a.originalMeshRef?.material){let m=a.originalMeshRef.material;m.opacity=u}c>=1&&(a.phase="complete",r.push(a))}}for(let s of r)this.completeReveal(s)}completeReveal(e){if(this.revealingSections.delete(e.key),this.revealedChunks.add(e.key),e.originalMeshRef){let t=e.originalMeshRef.originalMaterial;if(t){let n=e.originalMeshRef.material;e.originalMeshRef.material=t,n.dispose(),delete e.originalMeshRef.originalMaterial}e.originalMeshRef.visible=!0,delete e.originalMeshRef.hiddenByReveal}this.disposeWireframeGroup(e.wireframeGroup)}disposeWireframeGroup(e){this.scene.remove(e);let t=[];e.traverse(n=>{t.push(n)});for(let n of t){let r=n;if(r.geometry&&r.geometry.dispose(),r.material){let s=r.material;if(Array.isArray(s))for(let a of s)a.dispose();else s&&typeof s.dispose=="function"&&s.dispose()}}e.clear()}reset(){for(let e of this.revealingSections.values())this.disposeWireframeGroup(e.wireframeGroup);this.pendingGeometries.clear(),this.revealingSections.clear(),this.revealedChunks.clear(),this.finishedChunkCount=0,this.revealTriggered=!1,this.revealStartTime=0,this.pulseTime=0}forceCompleteAll(){let e=[...this.revealingSections.values()];for(let t of e){if(t.originalMeshRef||(t.originalMeshRef=this.getOriginalMesh(t.key)),t.originalMeshRef){let n=t.originalMeshRef.originalMaterial;n&&(t.originalMeshRef.material=n),t.originalMeshRef.visible=!0}this.completeReveal(t)}}debugGetWireframeGroups(){let e=[];return this.scene.traverse(t=>{t.name==="scifi-reveal-group"&&e.push(t)}),e}debugForceCleanup(){let e=this.debugGetWireframeGroups();console.log(`[SciFiReveal] Found ${e.length} wireframe groups in scene`);for(let t of e)console.log("[SciFiReveal] Removing group:",t),this.disposeWireframeGroup(t);for(let t of this.revealingSections.values())this.disposeWireframeGroup(t.wireframeGroup);this.revealingSections.clear(),console.log(`[SciFiReveal] Cleanup complete. Remaining groups: ${this.debugGetWireframeGroups().length}`)}debugStatus(){let e=this.debugGetWireframeGroups(),t=new Set(this.revealingSections.keys()),n=e.filter(r=>!t.has(r.sectionKey));return{revealTriggered:this.revealTriggered,finishedChunkCount:this.finishedChunkCount,pendingGeometries:this.pendingGeometries.size,revealingSections:this.revealingSections.size,revealedChunks:this.revealedChunks.size,wireframeGroupsInScene:e.length,orphanedWireframeGroups:n.length,orphanedKeys:n.map(r=>r.sectionKey),sections:[...this.revealingSections.entries()].map(([r,s])=>({key:r,phase:s.phase,hasOriginalMesh:!!s.originalMeshRef,wireframeInScene:s.wireframeGroup.parent!==null}))}}debugLog(){console.log("[SciFiReveal] Status:",this.debugStatus())}},Upe={id:"futuristicReveal",controller:wT,enabledDefault:!0};h();p();d();zt();var aqe=parseInt(fa.replaceAll(/\D+/g,""),10),xT=class extends Tr{constructor(){super({uniforms:{time:{value:0},fade:{value:1}},vertexShader:`
|
|
29094
29094
|
uniform float time;
|
|
29095
29095
|
attribute float size;
|
|
29096
29096
|
varying vec3 vColor;
|
|
@@ -29110,7 +29110,7 @@ void main() {
|
|
|
29110
29110
|
|
|
29111
29111
|
#include <tonemapping_fragment>
|
|
29112
29112
|
#include <${aqe>=154?"colorspace_fragment":"encodings_fragment"}>
|
|
29113
|
-
}`})}},ST=class{constructor(e){this.worldRenderer=e}points;clock=new Es;enabled=!1;currentTime;enable(){this.enabled||(this.enabled=!0,this.updateVisibility())}disable(){this.enabled&&(this.enabled=!1,this.removeStars())}toggle(){return this.enabled?this.disable():this.enable(),this.enabled}enablementCheck=()=>this.currentTime?this.currentTime>13500&&this.currentTime<23e3:!1;render=()=>{this.points&&(this.points.position.copy(this.worldRenderer.getCameraPosition()),this.points.material.uniforms.time.value=this.clock.getElapsedTime()*.2)};updateTimeOfDay(e){this.currentTime=e,this.enabled&&this.updateVisibility()}updateVisibility(){if(!this.enabled)return;let e=this.enablementCheck?.()??!1;e&&!this.points?this.createStars():!e&&this.points&&this.removeStars()}createStars(){if(this.points)return;let e=80,t=50,n=7e3,r=7,s=10,a=new at,o=b=>new Z().setFromSpherical(new Qd(b,Math.acos(1-Math.random()*2),Math.random()*2*Math.PI)),l=[],c=[],u=Array.from({length:n},()=>(.5+.5*Math.random())*r),f=new Ge,v=e+t,m=t/n;for(let b=0;b<n;b++)v-=m*Math.random(),l.push(...o(v).toArray()),f.setHSL(b/n,s,.9),c.push(f.r,f.g,f.b);a.setAttribute("position",new He(l,3)),a.setAttribute("color",new He(c,3)),a.setAttribute("size",new He(u,1));let y=new xT;y.blending=sa,y.depthTest=!1,y.transparent=!0,this.points=new Rr(a,y),this.points.renderOrder=-1,this.worldRenderer.scene.add(this.points)}dispose(){this.removeStars()}removeStars(){this.points&&(this.points.geometry.dispose(),this.points.material.dispose(),this.worldRenderer.scene.remove(this.points),this.points=void 0)}},Fpe={id:"starfield",controller:ST,enabledDefault:!0,cannotBeDisabled:!0};var zpe={starfield:Fpe,futuristicReveal:Upe,rain:Dpe};var nu=class i extends e7{constructor(t,n,r){if(!r.resourcesManager)throw new Error("resourcesManager is required in displayOptions");super(r.resourcesManager,r,n);this.renderer=t;this.initOptions=n;this.displayOptions=r;this.renderer=t,r.rendererState.renderer=i.getRendererInfo(t)??"...",this.worldBlockGeometry=new p4(this,this.scene,this.material,r),this.cursorBlock=new Q7(this),this.holdingBlock=new Ph(this),this.holdingBlockLeft=new Ph(this,!0);for(let s of Object.values(zpe))this.registerModule(s);this.skyboxRenderer=new l4(this.scene,!1,null),this.skyboxRenderer.init(),this.addDebugOverlay(),this.resetScene(),this.init(),this.soundSystem=new t4(this),this.cameraShake=new n4(this,this.onRender),this.media=new r4(this),this.fireworksLegacy=new a4(this),this.waypoints=new s4(this),this.cinimaticScript=new o4(this,(s,a,o)=>this.setCinimaticCamera(s,a,o),s=>this.setCinimaticFov(s),()=>({position:new lt(this.cameraObject.position.x,this.cameraObject.position.y,this.cameraObject.position.z),yaw:this.cameraShake.getBaseRotation().yaw,pitch:this.cameraShake.getBaseRotation().pitch,fov:this.camera.fov})),this.fireworks=new c4(this.scene),this.renderUpdateEmitter.on("chunkFinished",s=>{this.finishChunk(s)}),this.worldSwitchActions(),this.initializeModules()}outputFormat="threeJs";worldBlockGeometry;get sectionObjects(){return this.worldBlockGeometry.sectionObjects}chunkTextures=new Map;signsCache=new Map;cameraSectionPos=new lt(0,0,0);holdingBlock;holdingBlockLeft;scene=new Qi;ambientLight=new b0(13421772);directionalLight=new ca(16777215,.5);entities=new Z7(this,globalThis.mcData);cameraGroupVr;material=new di({vertexColors:!0,transparent:!0,alphaTest:.1});itemsTexture;cursorBlock;onRender=[];cameraShake;cameraContainer;media;get waitingChunksToDisplay(){return this.worldBlockGeometry.waitingChunksToDisplay}waypoints;cinimaticScript;camera;renderTimeAvg=0;get estimatedMemoryUsage(){return this.worldBlockGeometry.estimatedMemoryUsage}modules={};sectionsOffsetsAnimations={};fountains=[];fireworksLegacy;DEBUG_RAYCAST=!1;skyboxRenderer;fireworks;currentPosTween;currentRotTween;get tilesRendered(){return Object.values(this.sectionObjects).reduce((t,n)=>t+n.tilesCount,0)}get blocksRendered(){return Object.values(this.sectionObjects).reduce((t,n)=>t+n.blocksCount,0)}registerModule(t){if(t.id in this.modules){console.warn(`Module ${t.id} is already registered`);return}let n=new t.controller(this),r={manifest:t,controller:n,enabled:!1,toggle:()=>this.toggleModule(t.id)};this.modules[t.id]=r,t.enabledDefault&&this.toggleModule(t.id,!0)}enableModule(t){let n=this.modules[t];if(!n){console.warn(`Module ${t} not found`);return}n.enabled||(n.enabled=!0,n.controller.enable(),n.controller.render&&this.onRender.push(n.controller.render))}disableModule(t){let n=this.modules[t];if(!n){console.warn(`Module ${t} not found`);return}if(n.manifest.cannotBeDisabled){console.warn(`Module ${t} cannot be disabled`);return}if(n.enabled&&(n.enabled=!1,n.controller.disable(),n.controller.render)){let r=this.onRender.indexOf(n.controller.render);r>-1&&this.onRender.splice(r,1)}}toggleModule(t,n){let r=this.modules[t];if(!r)return console.warn(`Module ${t} not found`),!1;let s=n!==void 0?n:!r.enabled;if(s===r.enabled)return r.enabled;if(!s&&r.manifest.cannotBeDisabled)return console.warn(`Module ${t} cannot be disabled`),!0;if(r.enabled=s,s)r.controller.enable(),r.controller.render&&!this.onRender.includes(r.controller.render)&&this.onRender.push(r.controller.render);else if(r.controller.disable(),r.controller.render){let a=this.onRender.indexOf(r.controller.render);a>-1&&this.onRender.splice(a,1)}return s}disposeModules(){for(let t of Object.values(this.modules))t.controller.dispose();this.modules={}}initializeModules(){this.updateModulesFromConfig()}getModule(t){return this.modules[t]?.controller}anyModuleRequiresHeightmap(){return Object.values(this.modules).some(t=>t.enabled&&t.manifest.requiresHeightmap)}get cameraObject(){return this.cameraGroupVr??this.cameraContainer}worldSwitchActions(){this.onWorldSwitched.push(()=>{this.protocolCustomBlocks.clear(),this.sectionsOffsetsAnimations={},this.waypoints.clear(),this.cinimaticScript.stopScript(),this.fireworks.clear()})}downloadWorldGeometry(){mT(this,this.cameraObject.position,this.cameraShake.getBaseRotation(),"world-geometry.json")}updateEntity(t,n=!1){let r={rotation:{head:{x:t.headPitch??t.pitch,y:t.headYaw,z:0}}};n?this.entities.updateEntityPosition(t,!1,r):this.entities.update(t,r)}updatePlayerEntity(t){this.entities.handlePlayerEntity(t)}resetScene(){this.scene.matrixAutoUpdate=!1,this.scene.background=new Ge(this.initOptions.config.sceneBackground),this.scene.add(this.ambientLight),this.directionalLight.position.set(1,1,.5).normalize(),this.directionalLight.castShadow=!0,this.scene.add(this.directionalLight);let t=this.renderer.getSize(new Ve);this.camera=new cn(75,t.x/t.y,.1,1e3),this.cameraContainer=new St,this.cameraContainer.add(this.camera),this.scene.add(this.cameraContainer)}watchReactivePlayerState(){super.watchReactivePlayerState(),this.onReactivePlayerStateUpdated("inWater",t=>{this.skyboxRenderer.updateWaterState(t,this.playerStateReactive.waterBreathing)}),this.onReactivePlayerStateUpdated("waterBreathing",t=>{this.skyboxRenderer.updateWaterState(this.playerStateReactive.inWater,t)}),this.onReactivePlayerStateUpdated("ambientLight",t=>{t&&(this.ambientLight.intensity=t)}),this.onReactivePlayerStateUpdated("directionalLight",t=>{t&&(this.directionalLight.intensity=t)}),this.onReactivePlayerStateUpdated("lookingAtBlock",t=>{this.cursorBlock.setHighlightCursorBlock(t?new lt(t.x,t.y,t.z):null,t?.shapes)}),this.onReactivePlayerStateUpdated("diggingBlock",t=>{this.cursorBlock.updateBreakAnimation(t?{x:t.x,y:t.y,z:t.z}:void 0,t?.stage??null,t?.mergedShape)}),this.onReactivePlayerStateUpdated("perspective",t=>{let n=new lt(this.cameraObject.position.x,this.cameraObject.position.y,this.cameraObject.position.z);this.updateCamera(n,this.cameraShake.getBaseRotation().yaw,this.cameraShake.getBaseRotation().pitch)})}watchReactiveConfig(){super.watchReactiveConfig(),this.onReactiveConfigUpdated("showChunkBorders",t=>{this.updateShowChunksBorder(t)}),this.onReactiveConfigUpdated("defaultSkybox",t=>{this.skyboxRenderer.updateDefaultSkybox(t)}),this.onReactiveConfigUpdated("*",()=>{this.updateModulesFromConfig()}),this.updateModulesFromConfig()}updateModulesFromConfig(){let{moduleStates:t}=this.worldRendererConfig;for(let[n,r]of Object.entries(this.modules)){let s=t[n];if(s==="enabled"){r.enabled||this.toggleModule(n,!0);continue}if(s==="disabled"){r.enabled&&!r.manifest.cannotBeDisabled&&this.toggleModule(n,!1);continue}if(s==="auto"||s===void 0)if(r.controller.autoEnableCheck){let a=r.controller.autoEnableCheck();a&&!r.enabled?this.toggleModule(n,!0):!a&&r.enabled&&!r.manifest.cannotBeDisabled&&this.toggleModule(n,!1)}else{let a=r.manifest.enabledDefault??!1;a&&!r.enabled?this.toggleModule(n,!0):!a&&r.enabled&&!r.manifest.cannotBeDisabled&&this.toggleModule(n,!1)}}}changeHandSwingingState(t,n=!1){let r=n?this.holdingBlockLeft:this.holdingBlock;t?r.startSwing():r.stopSwing()}async updateAssetsData(){let t=this.resourcesManager.currentResources,n=this.material.map,r=this.itemsTexture,s=DE(t.blocksAtlasImage);s.needsUpdate=!0,s.flipY=!1,this.material.map=s;let a=DE(t.itemsAtlasImage);a.needsUpdate=!0,a.flipY=!1,this.itemsTexture=a,n&&n.dispose(),r&&r.dispose(),await super.updateAssetsData(),this.onAllTexturesLoaded(),Object.keys(this.loadedChunks).length>0&&(console.log("rerendering chunks because of texture update"),this.rerenderAllChunks())}onAllTexturesLoaded(){this.holdingBlock.ready=!0,this.holdingBlock.updateItem(),this.holdingBlockLeft.ready=!0,this.holdingBlockLeft.updateItem()}changeBackgroundColor(t){this.scene.background=new Ge(t[0],t[1],t[2])}timeUpdated(t){let n=this.getModule("starfield");n?.updateTimeOfDay&&n.updateTimeOfDay(t),this.skyboxRenderer.updateTime(t)}biomeUpdated(t){t?.temperature!==void 0&&this.skyboxRenderer.updateTemperature(t.temperature)}biomeReset(){this.skyboxRenderer.updateTemperature(hT)}getItemRenderData(t,n){return Ape(t,n,this.resourcesManager,this.playerStateReactive)}async demoModel(){let t=cursorBlockRel(0,1,0).position,n=await wp();bhe(n,t);let r=new ua(n,16776960);n.add(r),this.scene.add(n)}demoItem(){let t=cursorBlockRel(0,1,0).position,{mesh:n}=this.entities.getItemMesh({itemId:541},{});n.position.set(t.x+.5,t.y+.5,t.z+.5);let r=new ua(n,16776960);n.add(r),this.scene.add(n)}debugOverlayAdded=!1;addDebugOverlay(){if(this.debugOverlayAdded)return;this.debugOverlayAdded=!0;let t=Jg("debug-overlay");setInterval(()=>{if(t.setVisibility(this.displayAdvancedStats),this.displayAdvancedStats){let n=s=>new Intl.NumberFormat("en-US",{}).format(s),r="";r+=`C: ${n(this.renderer.info.render.calls)} `,r+=`TR: ${n(this.renderer.info.render.triangles)} `,r+=`TE: ${n(this.renderer.info.memory.textures)} `,r+=`F: ${n(this.tilesRendered)} `,r+=`B: ${n(this.blocksRendered)} `,r+=`MEM: ${this.worldBlockGeometry.getEstimatedMemoryUsage().readable}`,t.updateText(r),this.backendInfoReport=r}},200)}updatePosDataChunk(t){let[n,r,s]=t.split(",").map(l=>Math.floor(+l/16)),a=Math.abs(n-this.cameraSectionPos.x)+Math.abs(r-this.cameraSectionPos.y)+Math.abs(s-this.cameraSectionPos.z),o=this.sectionObjects[t].children.find(l=>l.name==="mesh");o.renderOrder=500-a}updateViewerPosition(t){this.viewerChunkPosition=t}cameraSectionPositionUpdate(){for(let t in this.sectionObjects)this.sectionObjects[t]&&this.updatePosDataChunk(t)}getDir(t,n){return t===n?0:t<n?1:-1}finishChunk(t){this.worldBlockGeometry.finishChunk(t)}handleWorkerMessage(t){t.type==="geometry"&&this.worldBlockGeometry.handleWorkerGeometryMessage(t)}getSignTexture(t,n,r,s=!1){let a=jg(t),o=this.chunkTextures.get(`${a[0]},${a[1]}`);o||(o={},this.chunkTextures.set(`${a[0]},${a[1]}`,o));let l=`${t.x},${t.y},${t.z}`;if(o[l])return o[l];let c=(0,qpe.default)(this.version),u=nhe(n,r,c);if(!u)return;let f=new Ht(u);return f.magFilter=et,f.minFilter=et,f.needsUpdate=!0,o[l]=f,f}getCameraPosition(){let t=new Z;return this.camera.getWorldPosition(t),t}getSectionCameraPosition(){let t=this.getCameraPosition();return new lt(Math.floor(t.x/16),Math.floor(t.y/16),Math.floor(t.z/16))}updateCameraSectionPos(){let t=this.getSectionCameraPosition();this.cameraSectionPos.equals(t)||(this.cameraSectionPos=t,this.cameraSectionPositionUpdate())}setFirstPersonCamera(t,n,r){let s=this.playerStateReactive.eyeHeight;this.updateCamera(t?.offset(0,s,0)??null,n,r),this.media.tryIntersectMedia(),this.updateCameraSectionPos()}getThirdPersonCamera(t,n,r){t??=this.cameraObject.position;let s=this.playerStateReactive.perspective==="third_person_back",a=4,o=new Z(0,0,-1),l=new jt().setFromAxisAngle(new Z(1,0,0),r),c=new jt().setFromAxisAngle(new Z(0,1,0),n),u=new jt().multiplyQuaternions(c,l);o.applyQuaternion(u),s&&o.multiplyScalar(-1),this.DEBUG_RAYCAST&&this.debugRaycast(t,o,a);let f=new oo;f.set(t,o),f.far=a;let v=Object.values(this.sectionObjects).filter(g=>g.name==="chunk"&&g.visible).filter(g=>{let x=g.children.find(A=>A.name==="mesh");if(!x)return!1;let w=new Z;return x.getWorldPosition(w),t.distanceTo(w)<80}),m=[];for(let g of v){let x=g.children.find(w=>w.name==="mesh");x&&m.push(x)}let y=f.intersectObjects(m,!1),b=a;return y.length>0&&(b=Math.max(.5,y[0].distance-.2)),new lt(t.x+o.x*b,t.y+o.y*b,t.z+o.z*b)}debugRaycastHelper;debugHitPoint;debugRaycast(t,n,r){this.debugRaycastHelper&&(this.scene.remove(this.debugRaycastHelper),this.debugRaycastHelper=void 0),this.debugHitPoint&&(this.scene.remove(this.debugHitPoint),this.debugHitPoint=void 0),this.debugRaycastHelper=new ac(n.clone().normalize(),t,r,16711680,r*.1,r*.05),this.scene.add(this.debugRaycastHelper);let s=new ns(.2,8,8),a=new ot({color:65280});this.debugHitPoint=new Ye(s,a),this.debugHitPoint.position.copy(t).add(n.clone().multiplyScalar(r)),this.scene.add(this.debugHitPoint)}prevFramePerspective=null;setCinimaticCamera(t,n,r){this.cameraObject.position.set(t.x,t.y,t.z),this.cameraShake.setBaseRotation(r,n),this.updateCameraSectionPos()}setCinimaticFov(t){this.camera.fov=t,this.camera.updateProjectionMatrix()}updateCamera(t,n,r){if(!this.cinimaticScript.running){if(t){this.renderer.xr.isPresenting&&(t.y-=this.camera.position.y),this.currentPosTween?.stop();let s=this.displayOptions.inWorldRenderingConfig.instantCameraUpdate?0:this.playerStateUtils.isSpectatingEntity()?150:50;this.currentPosTween=new br(this.cameraObject.position).to({x:t.x,y:t.y,z:t.z},s).start()}if(this.playerStateUtils.isSpectatingEntity()){let s=this.cameraShake.getBaseRotation(),a=0,o=Math.PI/2;s.yaw<o&&n>Math.PI+o?a=-Math.PI*2:n<o&&s.yaw>Math.PI+o&&(a=Math.PI*2),this.currentRotTween?.stop(),this.currentRotTween=new br(s).to({pitch:r,yaw:n+a},100).onUpdate(l=>this.cameraShake.setBaseRotation(l.pitch,l.yaw-a)).start()}else{this.currentRotTween?.stop(),this.cameraShake.setBaseRotation(r,n);let{perspective:s}=this.playerStateReactive;if(s==="third_person_back"||s==="third_person_front"){let a=this.cameraObject.position,o=this.getThirdPersonCamera(new Z(a.x,a.y,a.z),n,r),l=a.distanceTo(new Z(o.x,o.y,o.z)),c=s==="third_person_back"?l:-l;this.camera.position.set(0,0,c),s==="third_person_front"?this.camera.rotation.set(0,Math.PI,0):this.camera.rotation.set(0,0,0)}else this.camera.position.set(0,0,0),this.camera.rotation.set(0,0,0),this.debugRaycastHelper&&(this.scene.remove(this.debugRaycastHelper),this.debugRaycastHelper=void 0),this.debugHitPoint&&(this.scene.remove(this.debugHitPoint),this.debugHitPoint=void 0)}this.updateCameraSectionPos()}}debugChunksVisibilityOverride(){let{chunksRenderAboveOverride:t,chunksRenderBelowOverride:n,chunksRenderDistanceOverride:r,chunksRenderAboveEnabled:s,chunksRenderBelowEnabled:a,chunksRenderDistanceEnabled:o}=this.reactiveDebugParams,l=this.getSectionHeight(),c=this.cameraSectionPos.y*l;if(this.displayOptions.inWorldRenderingConfig.enableDebugOverlay&&t!==void 0||n!==void 0||r!==void 0)for(let[u,f]of Object.entries(this.sectionObjects)){let[v,m,y]=u.split(",").map(Number),b=s&&t!==void 0?m<=c+t:a&&n!==void 0?m>=c-n:o&&r!==void 0?Math.abs(m-c)<=r:!0;f.visible=b}else for(let u of Object.values(this.sectionObjects))u.visible=!0}render(t=!1){if(this.currentRenderedFrames++,this.reactiveDebugParams.stopRendering)return;this.debugChunksVisibilityOverride();let n=performance.now();this.lastRendered=performance.now(),this.cursorBlock.render(),this.updateSectionOffsets();let r=this.getCameraPosition();if(this.skyboxRenderer.update(r,this.viewDistance),t||this.displayOptions.inWorldRenderingConfig.fov!==this.camera.fov){let c=this.renderer.getSize(new Ve);this.camera.aspect=c.width/c.height,this.camera.fov=this.displayOptions.inWorldRenderingConfig.fov,this.camera.updateProjectionMatrix()}this.reactiveDebugParams.disableEntities||this.entities.render();let a=this.cameraGroupVr instanceof ft?this.cameraGroupVr.children.find(c=>c instanceof cn):this.camera;this.renderer.render(this.scene,a),this.displayOptions.inWorldRenderingConfig.showHand&&this.playerStateReactive.gameMode!=="spectator"&&this.playerStateReactive.perspective==="first_person"&&!this.renderer.xr.isPresenting&&(this.holdingBlock.render(this.camera,this.renderer,this.ambientLight,this.directionalLight),this.holdingBlockLeft.render(this.camera,this.renderer,this.ambientLight,this.directionalLight));for(let c of this.fountains)this.sectionObjects[c.sectionId]&&!this.sectionObjects[c.sectionId].foutain&&(c.createParticles(this.sectionObjects[c.sectionId]),this.sectionObjects[c.sectionId].foutain=!0),c.render();this.waypoints.render(),this.fireworks.update();for(let c of this.onRender)c();let l=performance.now()-n;this.renderTimeAvgCount++,this.renderTimeAvg=(this.renderTimeAvg*(this.renderTimeAvgCount-1)+l)/this.renderTimeAvgCount,this.renderTimeMax=Math.max(this.renderTimeMax,l)}renderHead(t,n,r,s){let a;if(s.SkullOwner?a=s.SkullOwner.Properties?.textures?.[0]?.Value:a=s.profile?.properties?.find(o=>o.name==="textures")?.value,!!a)try{let l=JSON.parse(Buffer.from(a,"base64").toString()).textures?.SKIN?.url,{skinTexturesProxy:c}=this.worldRendererConfig;c&&(l=l?.replace("http://textures.minecraft.net/",c).replace("https://textures.minecraft.net/",c));let u=Bh(this,l,Oh.head),f=new ft;return r&&u.position.set(0,.3125,.3125),u.position.y-=23/16,f.add(u),f.position.set(t.x+.5,t.y+.045,t.z+.5),f.rotation.set(0,-Pt.degToRad(n*(r?90:45/2)),0),f.scale.set(.8,.8,.8),f}catch(o){console.error("Error decoding player texture:",o)}}renderSign(t,n,r,s,a){let o=this.getSignTexture(t,a,s);if(!o)return;let l=new Ye(new Qn(1,1),new ot({map:o,transparent:!0}));l.renderOrder=999;let c=7/16,u=s?1.3:1;l.scale.set(1*u,c*u,1*u);let f=(s?2:1.5)/16,v=.25/16;r&&!s?l.position.set(0,0,-.5+f+v+1e-4):l.position.set(0,0,f/2+1e-4);let m=new ft;m.rotation.set(0,-Pt.degToRad(n*(r?90:45/2)),0),m.add(l);let y=(s?10:8)/16,b=(s?0:r?4.333:9.333)/16,_=y/2+b;return m.position.set(t.x+.5,t.y+_,t.z+.5),m}lightUpdate(t,n){for(let r=this.worldSizeParams.minY;r<this.worldSizeParams.worldHeight;r+=16)this.setSectionDirty(new lt(t,r,n))}rerenderAllChunks(){for(let t of Object.keys(this.sectionObjects)){let[n,r,s]=t.split(",").map(Number);this.setSectionDirty(new lt(n,r,s))}}updateShowChunksBorder(t){for(let n of Object.values(this.sectionObjects))for(let r of n.children)r.name==="helper"&&(r.visible=t)}resetWorld(){super.resetWorld(),this.worldBlockGeometry.resetWorld(),this.debugRaycastHelper&&(this.scene.remove(this.debugRaycastHelper),this.debugRaycastHelper=void 0),this.debugHitPoint&&(this.scene.remove(this.debugHitPoint),this.debugHitPoint=void 0)}getLoadedChunksRelative(t,n=!1){let[r,s,a]=SE(t);return Object.fromEntries(Object.entries(this.sectionObjects).map(([o,l])=>{let[c,u,f]=o.split(",").map(Number),[v,m,y]=SE({x:c,y:u,z:f});return[n?`${v-r},${m-s},${y-a}`:`${v-r},${y-a}`,l]}))}cleanChunkTextures(t,n){let r=this.chunkTextures.get(`${Math.floor(t/16)},${Math.floor(n/16)}`)??{};for(let s of Object.keys(r))r[s].dispose(),delete r[s]}readdChunks(){for(let t of Object.keys(this.sectionObjects))this.scene.remove(this.sectionObjects[t]);setTimeout(()=>{for(let t of Object.keys(this.sectionObjects))this.scene.add(this.sectionObjects[t])},500)}disableUpdates(t=this.scene.children){for(let n of t)n.matrixWorldNeedsUpdate=!1,this.disableUpdates(n.children??[])}removeColumn(t,n){super.removeColumn(t,n),this.cleanChunkTextures(t,n),this.worldBlockGeometry.removeColumn(t,n)}setSectionDirty(...t){let[n]=t;this.cleanChunkTextures(n.x,n.z),super.setSectionDirty(...t)}static getRendererInfo(t){try{let n=t.getContext();return`${n.getParameter(n.getExtension("WEBGL_debug_renderer_info").UNMASKED_RENDERER_WEBGL)}`}catch(n){console.warn("Failed to get renderer info",n)}}worldStop(){this.media.onWorldStop()}destroy(){this.disposeModules(),this.fireworksLegacy.destroy(),super.destroy(),this.skyboxRenderer.dispose(),this.fireworks.dispose()}shouldObjectVisible(t){let r=this.getSectionHeight(),s=Math.floor(t.position.x/16)*16,a=Math.floor(t.position.z/16)*16,o=Math.floor(t.position.y/r)*r,l=`${s},${a}`,c=`${s},${o},${a}`;return!!this.finishedChunks[l]||!!this.sectionObjects[c]}handleUserClick(t){this.media.handleUserClick(t)}updateSectionOffsets(){let t=performance.now();for(let[n,r]of Object.entries(this.sectionsOffsetsAnimations)){let s=(t-r.time)/1e3;r.time=t,r.currentOffsetX+=r.speedX*s,r.currentOffsetY+=r.speedY*s,r.currentOffsetZ+=r.speedZ*s,r.limitX!==void 0&&(r.speedX>0?r.currentOffsetX=Math.min(r.currentOffsetX,r.limitX):r.currentOffsetX=Math.max(r.currentOffsetX,r.limitX)),r.limitY!==void 0&&(r.speedY>0?r.currentOffsetY=Math.min(r.currentOffsetY,r.limitY):r.currentOffsetY=Math.max(r.currentOffsetY,r.limitY)),r.limitZ!==void 0&&(r.speedZ>0?r.currentOffsetZ=Math.min(r.currentOffsetZ,r.limitZ):r.currentOffsetZ=Math.max(r.currentOffsetZ,r.limitZ));let a=this.sectionObjects[n];a&&(a.position.set(r.currentOffsetX,r.currentOffsetY,r.currentOffsetZ),a.updateMatrix())}}reloadWorld(){this.entities.reloadEntities()}};h();p();d();h();p();d();h();p();d();k2();var ET={},Hpe=!1;function oqe(){if(Hpe)return ET;Hpe=!0;var i=Y0;function e(s){if(typeof s!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(s))}function t(s,a){for(var o="",l=0,c=-1,u=0,f,v=0;v<=s.length;++v){if(v<s.length)f=s.charCodeAt(v);else{if(f===47)break;f=47}if(f===47){if(!(c===v-1||u===1))if(c!==v-1&&u===2){if(o.length<2||l!==2||o.charCodeAt(o.length-1)!==46||o.charCodeAt(o.length-2)!==46){if(o.length>2){var m=o.lastIndexOf("/");if(m!==o.length-1){m===-1?(o="",l=0):(o=o.slice(0,m),l=o.length-1-o.lastIndexOf("/")),c=v,u=0;continue}}else if(o.length===2||o.length===1){o="",l=0,c=v,u=0;continue}}a&&(o.length>0?o+="/..":o="..",l=2)}else o.length>0?o+="/"+s.slice(c+1,v):o=s.slice(c+1,v),l=v-c-1;c=v,u=0}else f===46&&u!==-1?++u:u=-1}return o}function n(s,a){var o=a.dir||a.root,l=a.base||(a.name||"")+(a.ext||"");return o?o===a.root?o+l:o+s+l:l}var r={resolve:function(){for(var a="",o=!1,l,c=arguments.length-1;c>=-1&&!o;c--){var u;c>=0?u=arguments[c]:(l===void 0&&(l=i.cwd()),u=l),e(u),u.length!==0&&(a=u+"/"+a,o=u.charCodeAt(0)===47)}return a=t(a,!o),o?a.length>0?"/"+a:"/":a.length>0?a:"."},normalize:function(a){if(e(a),a.length===0)return".";var o=a.charCodeAt(0)===47,l=a.charCodeAt(a.length-1)===47;return a=t(a,!o),a.length===0&&!o&&(a="."),a.length>0&&l&&(a+="/"),o?"/"+a:a},isAbsolute:function(a){return e(a),a.length>0&&a.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var a,o=0;o<arguments.length;++o){var l=arguments[o];e(l),l.length>0&&(a===void 0?a=l:a+="/"+l)}return a===void 0?".":r.normalize(a)},relative:function(a,o){if(e(a),e(o),a===o||(a=r.resolve(a),o=r.resolve(o),a===o))return"";for(var l=1;l<a.length&&a.charCodeAt(l)===47;++l);for(var c=a.length,u=c-l,f=1;f<o.length&&o.charCodeAt(f)===47;++f);for(var v=o.length,m=v-f,y=u<m?u:m,b=-1,_=0;_<=y;++_){if(_===y){if(m>y){if(o.charCodeAt(f+_)===47)return o.slice(f+_+1);if(_===0)return o.slice(f+_)}else u>y&&(a.charCodeAt(l+_)===47?b=_:_===0&&(b=0));break}var g=a.charCodeAt(l+_),x=o.charCodeAt(f+_);if(g!==x)break;g===47&&(b=_)}var w="";for(_=l+b+1;_<=c;++_)(_===c||a.charCodeAt(_)===47)&&(w.length===0?w+="..":w+="/..");return w.length>0?w+o.slice(f+b):(f+=b,o.charCodeAt(f)===47&&++f,o.slice(f))},_makeLong:function(a){return a},dirname:function(a){if(e(a),a.length===0)return".";for(var o=a.charCodeAt(0),l=o===47,c=-1,u=!0,f=a.length-1;f>=1;--f)if(o=a.charCodeAt(f),o===47){if(!u){c=f;break}}else u=!1;return c===-1?l?"/":".":l&&c===1?"//":a.slice(0,c)},basename:function(a,o){if(o!==void 0&&typeof o!="string")throw new TypeError('"ext" argument must be a string');e(a);var l=0,c=-1,u=!0,f;if(o!==void 0&&o.length>0&&o.length<=a.length){if(o.length===a.length&&o===a)return"";var v=o.length-1,m=-1;for(f=a.length-1;f>=0;--f){var y=a.charCodeAt(f);if(y===47){if(!u){l=f+1;break}}else m===-1&&(u=!1,m=f+1),v>=0&&(y===o.charCodeAt(v)?--v===-1&&(c=f):(v=-1,c=m))}return l===c?c=m:c===-1&&(c=a.length),a.slice(l,c)}else{for(f=a.length-1;f>=0;--f)if(a.charCodeAt(f)===47){if(!u){l=f+1;break}}else c===-1&&(u=!1,c=f+1);return c===-1?"":a.slice(l,c)}},extname:function(a){e(a);for(var o=-1,l=0,c=-1,u=!0,f=0,v=a.length-1;v>=0;--v){var m=a.charCodeAt(v);if(m===47){if(!u){l=v+1;break}continue}c===-1&&(u=!1,c=v+1),m===46?o===-1?o=v:f!==1&&(f=1):o!==-1&&(f=-1)}return o===-1||c===-1||f===0||f===1&&o===c-1&&o===l+1?"":a.slice(o,c)},format:function(a){if(a===null||typeof a!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof a);return n("/",a)},parse:function(a){e(a);var o={root:"",dir:"",base:"",ext:"",name:""};if(a.length===0)return o;var l=a.charCodeAt(0),c=l===47,u;c?(o.root="/",u=1):u=0;for(var f=-1,v=0,m=-1,y=!0,b=a.length-1,_=0;b>=u;--b){if(l=a.charCodeAt(b),l===47){if(!y){v=b+1;break}continue}m===-1&&(y=!1,m=b+1),l===46?f===-1?f=b:_!==1&&(_=1):f!==-1&&(_=-1)}return f===-1||m===-1||_===0||_===1&&f===m-1&&f===v+1?m!==-1&&(v===0&&c?o.base=o.name=a.slice(1,m):o.base=o.name=a.slice(v,m)):(v===0&&c?(o.name=a.slice(1,f),o.base=a.slice(1,m)):(o.name=a.slice(v,f),o.base=a.slice(v,m)),o.ext=a.slice(f,m)),v>0?o.dir=a.slice(0,v-1):c&&(o.dir="/"),o},sep:"/",delimiter:":",win32:null,posix:null};return r.posix=r,ET=r,ET}var qr=oqe();k2();var Ohn=qr._makeLong,Dhn=qr.basename,Vhn=qr.delimiter,Uhn=qr.dirname,Fhn=qr.extname,zhn=qr.format,qhn=qr.isAbsolute,AT=qr.join,Hhn=qr.normalize,Ghn=qr.parse,Whn=qr.posix,jhn=qr.relative,$hn=qr.resolve,Xhn=qr.sep,Yhn=qr.win32;zt();h();p();d();var Sve=Wr(Jpe(),1),Eve=Wr(xve(),1);var Ave=i=>{let e=(0,Sve.default)(i),t=(0,Eve.default)(i),n=new e(i).sync,r=NHe(n);for(let s of r)if(s.startsWith("set")&&s!=="setColumn"){let a=n[s].bind(n);n[s]=(...o)=>{let l=o[0];l.x!==void 0&&!n.getColumnAt(l)&&n.setColumn(Math.floor(l.x/16),Math.floor(l.z/16),new t(void 0)),a(...o)}}return n};function NHe(i){let e=new Set,t=i;do for(let n of Object.getOwnPropertyNames(t))typeof i[n]=="function"&&n!=="constructor"&&e.add(n);while(t=Object.getPrototypeOf(t));return[...e]}h();p();d();var Mve={paused:!1,showChunkBorders:!1,enableDebugOverlay:!1,debugModelVariant:void 0,futuristicReveal:!1,wasmMesher:!1,mesherWorkers:1,addChunksBatchWaitTime:200,_experimentalSmoothChunkLoading:!0,_renderByChunks:!1,dayCycle:!0,smoothLighting:!0,enableLighting:!0,starfield:!0,defaultSkybox:!0,renderEntities:!0,extraBlockRenderers:!0,foreground:!0,fov:75,volume:1,showHand:!1,viewBobbing:!1,renderEars:!0,highlightBlockColor:"blue",fetchPlayerSkins:!0,skinTexturesProxy:void 0,vrSupport:!0,vrPageGameRendering:!0,clipWorldBelowY:void 0,isPlayground:!1,instantCameraUpdate:!1,isRaining:!1,moduleStates:{}};var kR=()=>({reactive:co({world:{chunksLoaded:new Set,heightmaps:new Map,allChunksLoaded:!1,mesherWork:!1,intersectMedia:null},renderer:"...",preventEscapeMenu:!1}),nonReactive:{fps:0,worstRenderTime:0,avgRenderTime:0,world:{chunksLoaded:new Set,chunksTotalNumber:0},renderer:{timeline:{live:[],frozen:[],lastSecond:[]}}}});h();p();d();var Tve="1.21.4";h();p();d();h();p();d();h();p();d();As();var r3=i=>[Math.floor(i.x/16),Math.floor(i.z/16)];var OHe=async(i,e,t,n=1)=>{for(let r=0;r<i.length;r+=n)e&&await new Promise(s=>setTimeout(s,e)),await t(i[r],r)},i3=class i3 extends A0{static restoreTransferred(e,t){let n=new i3;return t&&t.addEventListener("message",({data:r})=>{r.class===i3.restorerName&&r.type==="event"&&n.emit(r.eventName,...r.args)}),n}};jr(i3,"restorerName","WorldViewWorker");var Zh=i3,r8=class extends A0{constructor(t,n,r=new lt(0,0,0)){super();this.world=t;this.viewDistance=n;this.lastPos=new lt(0,0,0).update(r)}spiralNumber=0;gotPanicLastTime=!1;panicChunksReload=()=>{};loadedChunks={};inLoading=!1;chunkReceiveTimes=[];lastChunkReceiveTime=0;lastChunkReceiveTimeAvg=0;panicTimeout;lastPos;eventListeners={};debugChunksInfo={};waitingSpiralChunksLoad={};addWaitTime=1;keepChunksDistance=0;isPlayground=!1;allowPositionUpdate=!0;prepareForTransfer(t){if(t){let n=this.emit.bind(this);this.emit=(r,...s)=>{n(r,...s),t.postMessage({class:Zh.restorerName,type:"event",eventName:r,args:s})}}return{__restorer:Zh.restorerName}}setBlockStateId(t,n){let r=this.world.setBlockStateId(t,n);if(r&&typeof r.then=="function")throw new Error("setBlockStateId returned promise (not supported)");this.emit("blockUpdate",{pos:t,stateId:n})}updateViewDistance(t){this.viewDistance=t,this.emit("renderDistance",t)}async init(t,n){console.log("WorldView init"),this.updateViewDistance(this.viewDistance),this.emit("chunkPosUpdate",{pos:t}),n?.time?.timeOfDay!==void 0&&this.emit("time",n.time.timeOfDay),n?.entity&&this.emit("playerEntity",n.entity),this.emitterGotConnected(n);let[r,s]=r3(t),a=Q2(this.viewDistance).map(([o,l])=>new lt((r+o)*16,0,(s+l)*16));this.lastPos.update(t),await this._loadChunks(a,t)}chunkProgress(){if(this.panicTimeout&&clearTimeout(this.panicTimeout),this.chunkReceiveTimes.length>=5){let t=this.chunkReceiveTimes.reduce((r,s)=>r+s,0)/this.chunkReceiveTimes.length;this.lastChunkReceiveTimeAvg=t;let n=t*2+1e3;this.panicTimeout&&clearTimeout(this.panicTimeout),this.panicTimeout=setTimeout(()=>{!this.gotPanicLastTime&&this.inLoading&&(console.warn("Chunk loading seems stuck, triggering panic reload"),this.gotPanicLastTime=!0,this.panicChunksReload())},n)}}async _loadChunks(t,n){this.spiralNumber++;let{spiralNumber:r}=this;for(let a of Object.keys(this.waitingSpiralChunksLoad))this.waitingSpiralChunksLoad[a](!1),delete this.waitingSpiralChunksLoad[a];let s=!0;this.inLoading=!0,await OHe(t,this.addWaitTime,async a=>{!s||this.loadedChunks[`${a.x},${a.z}`]||(this.world.getColumnAt(a)||(s=await new Promise(o=>{this.waitingSpiralChunksLoad[`${a.x},${a.z}`]=o})),s&&(await this.loadChunk(a,void 0,`spiral ${r} from ${n.x},${n.z}`),this.chunkProgress()))}),this.panicTimeout&&clearTimeout(this.panicTimeout),this.inLoading=!1,this.gotPanicLastTime=!1,this.chunkReceiveTimes=[],this.lastChunkReceiveTime=0}async loadChunk(t,n=!1,r="spiral"){let[s,a]=r3(this.lastPos),o=Math.abs(s-Math.floor(t.x/16)),l=Math.abs(a-Math.floor(t.z/16));if(o<=this.viewDistance&&l<=this.viewDistance){let c=await this.world.getColumnAt(t.y!==void 0?t:new lt(t.x,0,t.z));if(c){let u=c.toJson(),f={minY:c.minY??0,worldHeight:c.worldHeight??256};this.emit("loadChunk",{x:t.x,z:t.z,chunk:u,blockEntities:c.blockEntities,worldConfig:f,isLightUpdate:n}),this.loadedChunks[`${t.x},${t.z}`]=!0,this.debugChunksInfo[`${t.x},${t.z}`]??={loads:[]},this.debugChunksInfo[`${t.x},${t.z}`].loads.push({dataLength:u.length,reason:r,time:Date.now()})}else this.isPlayground&&this.emit("markAsLoaded",{x:t.x,z:t.z})}}unloadAllChunks(){for(let t of Object.keys(this.loadedChunks)){let[n,r]=t.split(",").map(Number);this.unloadChunk({x:n,z:r})}}unloadChunk(t){this.emit("unloadChunk",{x:t.x,z:t.z}),delete this.loadedChunks[`${t.x},${t.z}`],delete this.debugChunksInfo[`${t.x},${t.z}`]}emitterGotConnected(t){typeof globalThis.WorkerGlobalScope<"u"&&globalThis instanceof globalThis.WorkerGlobalScope||!t||this.emit("blockEntities",new Proxy({},{get(r,s,a){if(typeof s!="string")return;let[o,l,c]=s.split(",").map(Number);return t.world.getBlock(new lt(o,l,c))?.entity}}))}lastBiomeId=null;updateBiome(t){try{if(!this.world.getBiome)return;let n=this.world.getBiome(t);n!==this.lastBiomeId&&(this.lastBiomeId=n,this.emit("biomeReset"))}catch(n){console.error("error updating biome",n)}}lastPosCheck=null;async updatePosition(t,n=!1){if(!this.allowPositionUpdate)return;let r=t.floored();if(!n&&this.lastPosCheck&&this.lastPosCheck.equals(r))return;this.lastPosCheck=r,this.updateBiome(t);let[s,a]=r3(this.lastPos),[o,l]=r3(t);if(s!==o||a!==l||n){this.emit("chunkPosUpdate",{pos:t});let c=[],u=n?this.viewDistance:this.viewDistance+this.keepChunksDistance;for(let v of Object.keys(this.loadedChunks)){let[m,y]=v.split(",").map(Number),b=new lt(m,0,y),[_,g]=r3(b),x=Math.abs(o-_),w=Math.abs(l-g);(x>u||w>u)&&c.push(b)}for(let v of c)this.unloadChunk(v);let f=Q2(this.viewDistance).map(([v,m])=>{let y=new lt((o+v)*16,0,(l+m)*16);if(!this.loadedChunks[`${y.x},${y.z}`])return y}).filter(v=>!!v);this.lastPos.update(t),this._loadChunks(f,t)}else this.emit("chunkPosUpdate",{pos:t}),this.lastPos.update(t)}};var CR=new Date,Rve=CR.getMonth()===11&&CR.getDate()>=24&&CR.getDate()<=26,DHe=["panorama_3.webp","panorama_1.webp","panorama_4.webp","panorama_5.webp","panorama_0.webp","panorama_2.webp"],i8=class{constructor(e,t,n=!1){this.documentRenderer=e;this.options=t;this.doWorldBlocksPanorama=n;this.scene=new Qi,this.scene.background=new Ge(3294568),this.ambientLight=new b0(13421772),this.scene.add(this.ambientLight),this.directionalLight=new ca(16777215,.5),this.directionalLight.position.set(1,1,.5).normalize(),this.directionalLight.castShadow=!0,this.scene.add(this.directionalLight),this.camera=new cn(85,this.documentRenderer.canvas.width/this.documentRenderer.canvas.height,.05,1e3),this.camera.position.set(0,0,0),this.camera.rotation.set(0,0,0)}camera;scene;ambientLight;directionalLight;panoramaGroup=null;time=0;abortController=new AbortController;worldRenderer;WorldRendererClass=nu;startTimes=new Map;async start(){this.doWorldBlocksPanorama?await this.worldBlocksPanorama():this.addClassicPanorama(),this.documentRenderer.render=(e=!1)=>{e&&(this.camera.aspect=this.documentRenderer.canvas.width/this.documentRenderer.canvas.height,this.camera.updateProjectionMatrix()),this.documentRenderer.renderer.render(this.scene,this.camera)}}async debugImageInFrontOfCamera(){let e=await el(AT("background","panorama_0.webp")),t=new Ye(new Qn(1e3,1e3),new ot({map:e}));t.position.set(0,0,-500),t.rotation.set(0,0,0),this.scene.add(t)}addClassicPanorama(){let e=new on(1e3,1e3,1e3),t=[],n=200;for(let a of DHe)(async()=>{let{texture:l}=Zg(AT("background",Rve?"christmas":"",a));l.matrixAutoUpdate=!1,l.matrix.set(-1,0,1,0,1,0,0,0,1),l.wrapS=Rn,l.wrapT=Rn,l.minFilter=Yt,l.magFilter=Yt;let c=new ot({map:l,transparent:!0,side:Tn,depthWrite:!1,opacity:0});this.startTimes.set(c,Date.now()),t.push(c)})();let r=new Ye(e,t);r.onBeforeRender=()=>{this.time+=.01,r.rotation.y=Math.PI+this.time*.01,r.rotation.z=Math.sin(-this.time*.001)*.001;for(let a of t){let o=this.startTimes.get(a);if(o){let l=Date.now()-o,c=Math.min(1,l/n);a.opacity=c}}};let s=new St;if(s.add(r),!Rve)for(let a=0;a<20;a++){let o=new Go("1.16.4","squid").mesh;o.position.set(Math.random()*30-15,Math.random()*20-10,Math.random()*10-17),o.rotation.set(0,Math.PI+Math.random(),-Math.PI/4,"ZYX");let l=Math.random()*.01;o.children[0].onBeforeRender=()=>{o.rotation.y+=l,o.rotation.z=Math.cos(r.rotation.y*3)*Math.PI/4-Math.PI/2},s.add(o)}this.scene.add(s),this.panoramaGroup=s}async worldBlocksPanorama(){let e=Tve,t=new xf;if(t.currentConfig={version:e,noInventoryGui:!0},await t.updateAssetsData?.({}),this.abortController.signal.aborted)return;console.time("load panorama scene");let n=Ave(e),s=ri()(e),o=globalThis.mcData.blocksArray.filter(g=>{if(!g.name.includes("stained_glass"))return!1;let x=s.fromStateId(g.defaultState,0);if(x.shapes?.length!==1)return!1;let w=x.shapes[0];return w[0]===0&&w[1]===0&&w[2]===0&&w[3]===1&&w[4]===1&&w[5]===1}),l=-15,c=100,u=100;for(let g=-c;g<c;g++)for(let x=-u;x<u;x++){let w=o[Math.floor(Math.random()*o.length)];n.setBlockStateId(new lt(g,x,l),w.defaultState)}this.camera.updateProjectionMatrix(),this.camera.position.set(.5,u/2+.5,.5),this.camera.rotation.set(0,0,0);let f=new lt(...this.camera.position.toArray()),v=new r8(n,2,f);if(this.abortController.signal.aborted||(this.worldRenderer=new this.WorldRendererClass(this.documentRenderer.renderer,this.options,{version:e,worldView:v,inWorldRenderingConfig:Mve,playerStateReactive:hhe().reactive,rendererState:kR().reactive,nonReactiveState:kR().nonReactive,resourcesManager:t}),this.worldRenderer instanceof nu&&(this.scene=this.worldRenderer.scene),v.init(f),await this.worldRenderer.waitForChunksToRender(),this.abortController.signal.aborted))return;let{camera:m}=this,y=m.position.x,b=m.position.y,_;document.body.addEventListener("pointermove",g=>{if(g.pointerType!=="mouse")return;let x=new Ve(g.clientX,g.clientY),w=.2,S=x.x/window.innerWidth-.5,A=-(x.y/window.innerHeight-.5);_?.stop();let P={x:y+S*w,y:b+A*w};_=new br(m.position).to(P,0),_.start(),m.updateProjectionMatrix()},{signal:this.abortController.signal}),console.timeEnd("load panorama scene")}dispose(){this.scene.clear(),this.worldRenderer?.destroy(),this.abortController.abort()}};ui.enabled=!1;globalThis.THREE=rn;var kve=i=>({updateMap:i.entities.updateMap.bind(i.entities),updateCustomBlock:i.updateCustomBlock.bind(i),getBlockInfo:i.getBlockInfo.bind(i),playEntityAnimation:i.entities.playAnimation.bind(i.entities),damageEntity:i.entities.handleDamageEvent.bind(i.entities),updatePlayerSkin:i.entities.updatePlayerSkin.bind(i.entities),changeHandSwingingState:i.changeHandSwingingState.bind(i),getHighestBlocks:i.getHighestBlocks.bind(i),reloadWorld:i.reloadWorld.bind(i),updateEntityModel:i.entities.updateEntityModel.bind(i.entities),playEntityModelAnimation:i.entities.playEntityModelAnimation.bind(i.entities),addMedia:i.media.addMedia.bind(i.media),destroyMedia:i.media.destroyMedia.bind(i.media),setControlMode:i.media.setControlMode.bind(i.media),setVideoPlaying:i.media.setVideoPlaying.bind(i.media),setVideoSeeking:i.media.setVideoSeeking.bind(i.media),setVideoVolume:i.media.setVideoVolume.bind(i.media),setVideoSpeed:i.media.setVideoSpeed.bind(i.media),handleUserClick:i.media.handleUserClick.bind(i.media),addSectionAnimation(e,t){i.sectionsOffsetsAnimations[e]=t},removeSectionAnimation(e){delete i.sectionsOffsetsAnimations[e]},shakeFromDamage:i.cameraShake.shakeFromDamage.bind(i.cameraShake),onPageInteraction:i.media.onPageInteraction.bind(i.media),downloadMesherLog:i.downloadMesherLog.bind(i),explodeFirework:i.fireworksLegacy.explode.bind(i.fireworksLegacy),explodeFireworkFacingCamera:i.fireworksLegacy.explodeFacingCamera.bind(i.fireworksLegacy),addWaypoint:i.waypoints.addWaypoint.bind(i.waypoints),removeWaypoint:i.waypoints.removeWaypoint.bind(i.waypoints),startCinimaticScript:i.cinimaticScript.startScript.bind(i.cinimaticScript),stopCinimaticScript:i.cinimaticScript.stopScript.bind(i.cinimaticScript),launchFirework:i.fireworks.launchFirework.bind(i.fireworks),setSkyboxImage:i.skyboxRenderer.setSkyboxImage.bind(i.skyboxRenderer),setRain:e=>i.toggleModule("rain",e),async loadGeometryExport(e){let{applyWorldGeometryExport:t}=await Promise.resolve().then(()=>(vT(),Ppe));return t(i,e)}}),VHe=[],s8=(i,...e)=>{for(let t of Object.values(globalThis.loadedMods??{}))try{t.threeJsBackendModule?.[i]?.(...e)}catch(n){let r=`[mod three.js] Error calling ${i} on ${t.name}: ${n}`;throw new Error(r)}},Cve=()=>{let i,e=null,t=null,n=null,r=null,s=(u,f)=>{Gn?i=ev(u,VHe,globalThis):i=u,e=new Yg(i,f?.canvas),globalThis.renderer=e.renderer,globalThis.documentRenderer=e,globalThis.threeJsBackend=c,s8("default",c)},a=async()=>{if(!e)throw new Error("Document renderer not initialized");if(!n&&!t){let u={...i};t=new i8(e,u,!!process.env.SINGLE_FILE_BUILD_MODE),globalThis.panoramaRenderer=t,s8("panoramaCreated",t),await t.start(),s8("panoramaReady",t)}},o=async u=>{let v=Gn?ev(u,[xf,Zh],globalThis):u;if(!e)throw new Error("Document renderer not initialized");e.nonReactiveState=v.nonReactiveState,globalThis.resourcesManager=v.resourcesManager,t&&(t.dispose(),t=null),n=new nu(e.renderer,i,v),await n.worldReadyPromise,r=new u6(v.nonReactiveState),globalThis.frameTimingCollector=r;let m=e.render;e.render=function(y){m.call(this,y),r?.markFrameStart(),v.inWorldRenderingConfig.paused||n?.render(y),r?.markFrameEnd(),r?.markFrameDisplay()},e.inWorldRenderingConfig=v.inWorldRenderingConfig,globalThis.world=n,s8("worldReady",n)},l=()=>{t&&(t.dispose(),t=null),e&&e.dispose(),n&&(n.destroy(),n=null)},c={id:"threejs",displayName:`three.js ${fa}`,startPanorama:a,startWorld:o,disconnect:l,setRendering(u){e.setPaused(!u),n&&(n.renderingActive=u)},getDebugOverlay:()=>({get entitiesString(){return n?.entities.getDebugString()}}),updateCamera(u,f,v){r?.markCameraUpdate(!u),n?.setFirstPersonCamera(u,f,v)},get soundSystem(){return n?.soundSystem},get backendMethods(){if(n)return kve(n)}};return{main:{init:s,backend:c},workerProxy(){return YI({init(u,f){s(u,{canvas:f})},updateSizeExternal(u,f,v){e?.updateSizeExternal(u,f,v)},startPanorama:a,startWorld:o,disconnect:l,setRendering:c.setRendering,updateCamera(u,f,v){let m=u?new lt(u.x,u.y,u.z):null;r?.markCameraUpdate(!m),c.updateCamera(m,f,v)},async callBackendMethod(u,...f){if(!n)throw new Error("World renderer not initialized");let m=kve(n)[u];if(!m)throw new Error(`Backend method ${String(u)} is unavailable`);return m(...f)}})}}};globalThis.structuredClone??=i=>JSON.parse(JSON.stringify(i));self.addEventListener("message",i=>{let e=i.data,t=globalThis;if(e.type==="mcData"){t.mcData=e.mcData,t.loadedData=e.mcData,console.log("data loaded");return}Array.isArray(e)&&e.forEach(n=>{n.type==="mcData"&&(t.mcData=n.mcData,t.loadedData=n.mcData)})});var UHe=Cve();UHe.workerProxy();})();
|
|
29113
|
+
}`})}},ST=class{constructor(e){this.worldRenderer=e}points;clock=new Es;enabled=!1;currentTime;enable(){this.enabled||(this.enabled=!0,this.updateVisibility())}disable(){this.enabled&&(this.enabled=!1,this.removeStars())}toggle(){return this.enabled?this.disable():this.enable(),this.enabled}enablementCheck=()=>this.currentTime?this.currentTime>13500&&this.currentTime<23e3:!1;render=e=>{this.points&&(this.points.position.copy(this.worldRenderer.getCameraPosition()),this.points.material.uniforms.time.value=this.clock.getElapsedTime()*.2)};updateTimeOfDay(e){this.currentTime=e,this.enabled&&this.updateVisibility()}updateVisibility(){if(!this.enabled)return;let e=this.enablementCheck?.()??!1;e&&!this.points?this.createStars():!e&&this.points&&this.removeStars()}createStars(){if(this.points)return;let e=80,t=50,n=7e3,r=7,s=10,a=new at,o=b=>new Z().setFromSpherical(new Qd(b,Math.acos(1-Math.random()*2),Math.random()*2*Math.PI)),l=[],c=[],u=Array.from({length:n},()=>(.5+.5*Math.random())*r),f=new Ge,v=e+t,m=t/n;for(let b=0;b<n;b++)v-=m*Math.random(),l.push(...o(v).toArray()),f.setHSL(b/n,s,.9),c.push(f.r,f.g,f.b);a.setAttribute("position",new He(l,3)),a.setAttribute("color",new He(c,3)),a.setAttribute("size",new He(u,1));let y=new xT;y.blending=sa,y.depthTest=!1,y.transparent=!0,this.points=new Rr(a,y),this.points.renderOrder=-1,this.worldRenderer.scene.add(this.points)}dispose(){this.removeStars()}removeStars(){this.points&&(this.points.geometry.dispose(),this.points.material.dispose(),this.worldRenderer.scene.remove(this.points),this.points=void 0)}},Fpe={id:"starfield",controller:ST,enabledDefault:!0,cannotBeDisabled:!0};var zpe={starfield:Fpe,futuristicReveal:Upe,rain:Dpe};var nu=class i extends e7{constructor(t,n,r){if(!r.resourcesManager)throw new Error("resourcesManager is required in displayOptions");super(r.resourcesManager,r,n);this.renderer=t;this.initOptions=n;this.displayOptions=r;this.renderer=t,r.rendererState.renderer=i.getRendererInfo(t)??"...",this.worldBlockGeometry=new p4(this,this.scene,this.material,r),this.cursorBlock=new Q7(this),this.holdingBlock=new Ph(this),this.holdingBlockLeft=new Ph(this,!0);for(let s of Object.values(zpe))this.registerModule(s);this.skyboxRenderer=new l4(this.scene,!1,null),this.skyboxRenderer.init(),this.addDebugOverlay(),this.resetScene(),this.init(),this.soundSystem=new t4(this),this.cameraShake=new n4(this,this.onRender),this.media=new r4(this),this.fireworksLegacy=new a4(this),this.waypoints=new s4(this),this.cinimaticScript=new o4(this,(s,a,o)=>this.setCinimaticCamera(s,a,o),s=>this.setCinimaticFov(s),()=>({position:new lt(this.cameraObject.position.x,this.cameraObject.position.y,this.cameraObject.position.z),yaw:this.cameraShake.getBaseRotation().yaw,pitch:this.cameraShake.getBaseRotation().pitch,fov:this.camera.fov})),this.fireworks=new c4(this.scene),this.renderUpdateEmitter.on("chunkFinished",s=>{this.finishChunk(s)}),this.worldSwitchActions(),this.initializeModules()}outputFormat="threeJs";worldBlockGeometry;get sectionObjects(){return this.worldBlockGeometry.sectionObjects}chunkTextures=new Map;signsCache=new Map;cameraSectionPos=new lt(0,0,0);holdingBlock;holdingBlockLeft;scene=new Qi;ambientLight=new b0(13421772);directionalLight=new ca(16777215,.5);entities=new Z7(this,globalThis.mcData);cameraGroupVr;material=new di({vertexColors:!0,transparent:!0,alphaTest:.1});itemsTexture;cursorBlock;onRender=[];lastRenderTime=0;cameraShake;cameraContainer;media;get waitingChunksToDisplay(){return this.worldBlockGeometry.waitingChunksToDisplay}waypoints;cinimaticScript;camera;renderTimeAvg=0;get estimatedMemoryUsage(){return this.worldBlockGeometry.estimatedMemoryUsage}modules={};sectionsOffsetsAnimations={};fountains=[];fireworksLegacy;DEBUG_RAYCAST=!1;skyboxRenderer;fireworks;currentPosTween;currentRotTween;get tilesRendered(){return Object.values(this.sectionObjects).reduce((t,n)=>t+n.tilesCount,0)}get blocksRendered(){return Object.values(this.sectionObjects).reduce((t,n)=>t+n.blocksCount,0)}registerModule(t){if(t.id in this.modules){console.warn(`Module ${t.id} is already registered`);return}let n=new t.controller(this),r={manifest:t,controller:n,enabled:!1,toggle:()=>this.toggleModule(t.id)};this.modules[t.id]=r,t.enabledDefault&&this.toggleModule(t.id,!0)}enableModule(t){let n=this.modules[t];if(!n){console.warn(`Module ${t} not found`);return}n.enabled||(n.enabled=!0,n.controller.enable(),n.controller.render&&this.onRender.push(n.controller.render))}disableModule(t){let n=this.modules[t];if(!n){console.warn(`Module ${t} not found`);return}if(n.manifest.cannotBeDisabled){console.warn(`Module ${t} cannot be disabled`);return}if(n.enabled&&(n.enabled=!1,n.controller.disable(),n.controller.render)){let r=this.onRender.indexOf(n.controller.render);r>-1&&this.onRender.splice(r,1)}}toggleModule(t,n){let r=this.modules[t];if(!r)return console.warn(`Module ${t} not found`),!1;let s=n!==void 0?n:!r.enabled;if(s===r.enabled)return r.enabled;if(!s&&r.manifest.cannotBeDisabled)return console.warn(`Module ${t} cannot be disabled`),!0;if(r.enabled=s,s)r.controller.enable(),r.controller.render&&!this.onRender.includes(r.controller.render)&&this.onRender.push(r.controller.render);else if(r.controller.disable(),r.controller.render){let a=this.onRender.indexOf(r.controller.render);a>-1&&this.onRender.splice(a,1)}return s}disposeModules(){for(let t of Object.values(this.modules))t.controller.dispose();this.modules={}}initializeModules(){this.updateModulesFromConfig()}getModule(t){return this.modules[t]?.controller}anyModuleRequiresHeightmap(){return Object.values(this.modules).some(t=>t.enabled&&t.manifest.requiresHeightmap)}get cameraObject(){return this.cameraGroupVr??this.cameraContainer}worldSwitchActions(){this.onWorldSwitched.push(()=>{this.protocolCustomBlocks.clear(),this.sectionsOffsetsAnimations={},this.waypoints.clear(),this.cinimaticScript.stopScript(),this.fireworks.clear()})}downloadWorldGeometry(){mT(this,this.cameraObject.position,this.cameraShake.getBaseRotation(),"world-geometry.json")}updateEntity(t,n=!1){let r={rotation:{head:{x:t.headPitch??t.pitch,y:t.headYaw,z:0}}};n?this.entities.updateEntityPosition(t,!1,r):this.entities.update(t,r)}updatePlayerEntity(t){this.entities.handlePlayerEntity(t)}resetScene(){this.scene.matrixAutoUpdate=!1,this.scene.background=new Ge(this.initOptions.config.sceneBackground),this.scene.add(this.ambientLight),this.directionalLight.position.set(1,1,.5).normalize(),this.directionalLight.castShadow=!0,this.scene.add(this.directionalLight);let t=this.renderer.getSize(new Ve);this.camera=new cn(75,t.x/t.y,.1,1e3),this.cameraContainer=new St,this.cameraContainer.add(this.camera),this.scene.add(this.cameraContainer)}watchReactivePlayerState(){super.watchReactivePlayerState(),this.onReactivePlayerStateUpdated("inWater",t=>{this.skyboxRenderer.updateWaterState(t,this.playerStateReactive.waterBreathing)}),this.onReactivePlayerStateUpdated("waterBreathing",t=>{this.skyboxRenderer.updateWaterState(this.playerStateReactive.inWater,t)}),this.onReactivePlayerStateUpdated("ambientLight",t=>{t&&(this.ambientLight.intensity=t)}),this.onReactivePlayerStateUpdated("directionalLight",t=>{t&&(this.directionalLight.intensity=t)}),this.onReactivePlayerStateUpdated("lookingAtBlock",t=>{this.cursorBlock.setHighlightCursorBlock(t?new lt(t.x,t.y,t.z):null,t?.shapes)}),this.onReactivePlayerStateUpdated("diggingBlock",t=>{this.cursorBlock.updateBreakAnimation(t?{x:t.x,y:t.y,z:t.z}:void 0,t?.stage??null,t?.mergedShape)}),this.onReactivePlayerStateUpdated("perspective",t=>{let n=new lt(this.cameraObject.position.x,this.cameraObject.position.y,this.cameraObject.position.z);this.updateCamera(n,this.cameraShake.getBaseRotation().yaw,this.cameraShake.getBaseRotation().pitch)})}watchReactiveConfig(){super.watchReactiveConfig(),this.onReactiveConfigUpdated("showChunkBorders",t=>{this.updateShowChunksBorder(t)}),this.onReactiveConfigUpdated("defaultSkybox",t=>{this.skyboxRenderer.updateDefaultSkybox(t)}),this.onReactiveConfigUpdated("*",()=>{this.updateModulesFromConfig()}),this.updateModulesFromConfig()}updateModulesFromConfig(){let{moduleStates:t}=this.worldRendererConfig;for(let[n,r]of Object.entries(this.modules)){let s=t[n];if(s==="enabled"){r.enabled||this.toggleModule(n,!0);continue}if(s==="disabled"){r.enabled&&!r.manifest.cannotBeDisabled&&this.toggleModule(n,!1);continue}if(s==="auto"||s===void 0)if(r.controller.autoEnableCheck){let a=r.controller.autoEnableCheck();a&&!r.enabled?this.toggleModule(n,!0):!a&&r.enabled&&!r.manifest.cannotBeDisabled&&this.toggleModule(n,!1)}else{let a=r.manifest.enabledDefault??!1;a&&!r.enabled?this.toggleModule(n,!0):!a&&r.enabled&&!r.manifest.cannotBeDisabled&&this.toggleModule(n,!1)}}}changeHandSwingingState(t,n=!1){let r=n?this.holdingBlockLeft:this.holdingBlock;t?r.startSwing():r.stopSwing()}async updateAssetsData(){let t=this.resourcesManager.currentResources,n=this.material.map,r=this.itemsTexture,s=DE(t.blocksAtlasImage);s.needsUpdate=!0,s.flipY=!1,this.material.map=s;let a=DE(t.itemsAtlasImage);a.needsUpdate=!0,a.flipY=!1,this.itemsTexture=a,n&&n.dispose(),r&&r.dispose(),await super.updateAssetsData(),this.onAllTexturesLoaded(),Object.keys(this.loadedChunks).length>0&&(console.log("rerendering chunks because of texture update"),this.rerenderAllChunks())}onAllTexturesLoaded(){this.holdingBlock.ready=!0,this.holdingBlock.updateItem(),this.holdingBlockLeft.ready=!0,this.holdingBlockLeft.updateItem()}changeBackgroundColor(t){this.scene.background=new Ge(t[0],t[1],t[2])}timeUpdated(t){let n=this.getModule("starfield");n?.updateTimeOfDay&&n.updateTimeOfDay(t),this.skyboxRenderer.updateTime(t)}biomeUpdated(t){t?.temperature!==void 0&&this.skyboxRenderer.updateTemperature(t.temperature)}biomeReset(){this.skyboxRenderer.updateTemperature(hT)}getItemRenderData(t,n){return Ape(t,n,this.resourcesManager,this.playerStateReactive)}async demoModel(){let t=cursorBlockRel(0,1,0).position,n=await wp();bhe(n,t);let r=new ua(n,16776960);n.add(r),this.scene.add(n)}demoItem(){let t=cursorBlockRel(0,1,0).position,{mesh:n}=this.entities.getItemMesh({itemId:541},{});n.position.set(t.x+.5,t.y+.5,t.z+.5);let r=new ua(n,16776960);n.add(r),this.scene.add(n)}debugOverlayAdded=!1;addDebugOverlay(){if(this.debugOverlayAdded)return;this.debugOverlayAdded=!0;let t=Jg("debug-overlay");setInterval(()=>{if(t.setVisibility(this.displayAdvancedStats),this.displayAdvancedStats){let n=s=>new Intl.NumberFormat("en-US",{}).format(s),r="";r+=`C: ${n(this.renderer.info.render.calls)} `,r+=`TR: ${n(this.renderer.info.render.triangles)} `,r+=`TE: ${n(this.renderer.info.memory.textures)} `,r+=`F: ${n(this.tilesRendered)} `,r+=`B: ${n(this.blocksRendered)} `,r+=`MEM: ${this.worldBlockGeometry.getEstimatedMemoryUsage().readable}`,t.updateText(r),this.backendInfoReport=r}},200)}updatePosDataChunk(t){let[n,r,s]=t.split(",").map(l=>Math.floor(+l/16)),a=Math.abs(n-this.cameraSectionPos.x)+Math.abs(r-this.cameraSectionPos.y)+Math.abs(s-this.cameraSectionPos.z),o=this.sectionObjects[t].children.find(l=>l.name==="mesh");o.renderOrder=500-a}updateViewerPosition(t){this.viewerChunkPosition=t}cameraSectionPositionUpdate(){for(let t in this.sectionObjects)this.sectionObjects[t]&&this.updatePosDataChunk(t)}getDir(t,n){return t===n?0:t<n?1:-1}finishChunk(t){this.worldBlockGeometry.finishChunk(t)}handleWorkerMessage(t){t.type==="geometry"&&this.worldBlockGeometry.handleWorkerGeometryMessage(t)}getSignTexture(t,n,r,s=!1){let a=jg(t),o=this.chunkTextures.get(`${a[0]},${a[1]}`);o||(o={},this.chunkTextures.set(`${a[0]},${a[1]}`,o));let l=`${t.x},${t.y},${t.z}`;if(o[l])return o[l];let c=(0,qpe.default)(this.version),u=nhe(n,r,c);if(!u)return;let f=new Ht(u);return f.magFilter=et,f.minFilter=et,f.needsUpdate=!0,o[l]=f,f}getCameraPosition(){let t=new Z;return this.camera.getWorldPosition(t),t}getSectionCameraPosition(){let t=this.getCameraPosition();return new lt(Math.floor(t.x/16),Math.floor(t.y/16),Math.floor(t.z/16))}updateCameraSectionPos(){let t=this.getSectionCameraPosition();this.cameraSectionPos.equals(t)||(this.cameraSectionPos=t,this.cameraSectionPositionUpdate())}setFirstPersonCamera(t,n,r){let s=this.playerStateReactive.eyeHeight;this.updateCamera(t?.offset(0,s,0)??null,n,r),this.media.tryIntersectMedia(),this.updateCameraSectionPos()}getThirdPersonCamera(t,n,r){t??=this.cameraObject.position;let s=this.playerStateReactive.perspective==="third_person_back",a=4,o=new Z(0,0,-1),l=new jt().setFromAxisAngle(new Z(1,0,0),r),c=new jt().setFromAxisAngle(new Z(0,1,0),n),u=new jt().multiplyQuaternions(c,l);o.applyQuaternion(u),s&&o.multiplyScalar(-1),this.DEBUG_RAYCAST&&this.debugRaycast(t,o,a);let f=new oo;f.set(t,o),f.far=a;let v=Object.values(this.sectionObjects).filter(g=>g.name==="chunk"&&g.visible).filter(g=>{let x=g.children.find(A=>A.name==="mesh");if(!x)return!1;let w=new Z;return x.getWorldPosition(w),t.distanceTo(w)<80}),m=[];for(let g of v){let x=g.children.find(w=>w.name==="mesh");x&&m.push(x)}let y=f.intersectObjects(m,!1),b=a;return y.length>0&&(b=Math.max(.5,y[0].distance-.2)),new lt(t.x+o.x*b,t.y+o.y*b,t.z+o.z*b)}debugRaycastHelper;debugHitPoint;debugRaycast(t,n,r){this.debugRaycastHelper&&(this.scene.remove(this.debugRaycastHelper),this.debugRaycastHelper=void 0),this.debugHitPoint&&(this.scene.remove(this.debugHitPoint),this.debugHitPoint=void 0),this.debugRaycastHelper=new ac(n.clone().normalize(),t,r,16711680,r*.1,r*.05),this.scene.add(this.debugRaycastHelper);let s=new ns(.2,8,8),a=new ot({color:65280});this.debugHitPoint=new Ye(s,a),this.debugHitPoint.position.copy(t).add(n.clone().multiplyScalar(r)),this.scene.add(this.debugHitPoint)}prevFramePerspective=null;setCinimaticCamera(t,n,r){this.cameraObject.position.set(t.x,t.y,t.z),this.cameraShake.setBaseRotation(r,n),this.updateCameraSectionPos()}setCinimaticFov(t){this.camera.fov=t,this.camera.updateProjectionMatrix()}updateCamera(t,n,r){if(!this.cinimaticScript.running){if(t){this.renderer.xr.isPresenting&&(t.y-=this.camera.position.y),this.currentPosTween?.stop();let s=this.displayOptions.inWorldRenderingConfig.instantCameraUpdate?0:this.playerStateUtils.isSpectatingEntity()?150:50;this.currentPosTween=new br(this.cameraObject.position).to({x:t.x,y:t.y,z:t.z},s).start()}if(this.playerStateUtils.isSpectatingEntity()){let s=this.cameraShake.getBaseRotation(),a=0,o=Math.PI/2;s.yaw<o&&n>Math.PI+o?a=-Math.PI*2:n<o&&s.yaw>Math.PI+o&&(a=Math.PI*2),this.currentRotTween?.stop(),this.currentRotTween=new br(s).to({pitch:r,yaw:n+a},100).onUpdate(l=>this.cameraShake.setBaseRotation(l.pitch,l.yaw-a)).start()}else{this.currentRotTween?.stop(),this.cameraShake.setBaseRotation(r,n);let{perspective:s}=this.playerStateReactive;if(s==="third_person_back"||s==="third_person_front"){let a=this.cameraObject.position,o=this.getThirdPersonCamera(new Z(a.x,a.y,a.z),n,r),l=a.distanceTo(new Z(o.x,o.y,o.z)),c=s==="third_person_back"?l:-l;this.camera.position.set(0,0,c),s==="third_person_front"?this.camera.rotation.set(0,Math.PI,0):this.camera.rotation.set(0,0,0)}else this.camera.position.set(0,0,0),this.camera.rotation.set(0,0,0),this.debugRaycastHelper&&(this.scene.remove(this.debugRaycastHelper),this.debugRaycastHelper=void 0),this.debugHitPoint&&(this.scene.remove(this.debugHitPoint),this.debugHitPoint=void 0)}this.updateCameraSectionPos()}}debugChunksVisibilityOverride(){let{chunksRenderAboveOverride:t,chunksRenderBelowOverride:n,chunksRenderDistanceOverride:r,chunksRenderAboveEnabled:s,chunksRenderBelowEnabled:a,chunksRenderDistanceEnabled:o}=this.reactiveDebugParams,l=this.getSectionHeight(),c=this.cameraSectionPos.y*l;if(this.displayOptions.inWorldRenderingConfig.enableDebugOverlay&&t!==void 0||n!==void 0||r!==void 0)for(let[u,f]of Object.entries(this.sectionObjects)){let[v,m,y]=u.split(",").map(Number),b=s&&t!==void 0?m<=c+t:a&&n!==void 0?m>=c-n:o&&r!==void 0?Math.abs(m-c)<=r:!0;f.visible=b}else for(let u of Object.values(this.sectionObjects))u.visible=!0}render(t=!1){if(this.currentRenderedFrames++,this.reactiveDebugParams.stopRendering)return;this.debugChunksVisibilityOverride();let n=performance.now();this.lastRendered=performance.now();let r=this.lastRenderTime>0?Math.min(Math.max((n-this.lastRenderTime)/1e3,0),.1):1/60;this.lastRenderTime=n,this.cursorBlock.render(),this.updateSectionOffsets();let s=this.getCameraPosition();if(this.skyboxRenderer.update(s,this.viewDistance),t||this.displayOptions.inWorldRenderingConfig.fov!==this.camera.fov){let u=this.renderer.getSize(new Ve);this.camera.aspect=u.width/u.height,this.camera.fov=this.displayOptions.inWorldRenderingConfig.fov,this.camera.updateProjectionMatrix()}this.reactiveDebugParams.disableEntities||this.entities.render();let o=this.cameraGroupVr instanceof ft?this.cameraGroupVr.children.find(u=>u instanceof cn):this.camera;this.renderer.render(this.scene,o),this.displayOptions.inWorldRenderingConfig.showHand&&this.playerStateReactive.gameMode!=="spectator"&&this.playerStateReactive.perspective==="first_person"&&!this.renderer.xr.isPresenting&&(this.holdingBlock.render(this.camera,this.renderer,this.ambientLight,this.directionalLight),this.holdingBlockLeft.render(this.camera,this.renderer,this.ambientLight,this.directionalLight));for(let u of this.fountains)this.sectionObjects[u.sectionId]&&!this.sectionObjects[u.sectionId].foutain&&(u.createParticles(this.sectionObjects[u.sectionId]),this.sectionObjects[u.sectionId].foutain=!0),u.render();this.waypoints.render(),this.fireworks.update();for(let u of this.onRender)u(r);let c=performance.now()-n;this.renderTimeAvgCount++,this.renderTimeAvg=(this.renderTimeAvg*(this.renderTimeAvgCount-1)+c)/this.renderTimeAvgCount,this.renderTimeMax=Math.max(this.renderTimeMax,c)}renderHead(t,n,r,s){let a;if(s.SkullOwner?a=s.SkullOwner.Properties?.textures?.[0]?.Value:a=s.profile?.properties?.find(o=>o.name==="textures")?.value,!!a)try{let l=JSON.parse(Buffer.from(a,"base64").toString()).textures?.SKIN?.url,{skinTexturesProxy:c}=this.worldRendererConfig;c&&(l=l?.replace("http://textures.minecraft.net/",c).replace("https://textures.minecraft.net/",c));let u=Bh(this,l,Oh.head),f=new ft;return r&&u.position.set(0,.3125,.3125),u.position.y-=23/16,f.add(u),f.position.set(t.x+.5,t.y+.045,t.z+.5),f.rotation.set(0,-Pt.degToRad(n*(r?90:45/2)),0),f.scale.set(.8,.8,.8),f}catch(o){console.error("Error decoding player texture:",o)}}renderSign(t,n,r,s,a){let o=this.getSignTexture(t,a,s);if(!o)return;let l=new Ye(new Qn(1,1),new ot({map:o,transparent:!0}));l.renderOrder=999;let c=7/16,u=s?1.3:1;l.scale.set(1*u,c*u,1*u);let f=(s?2:1.5)/16,v=.25/16;r&&!s?l.position.set(0,0,-.5+f+v+1e-4):l.position.set(0,0,f/2+1e-4);let m=new ft;m.rotation.set(0,-Pt.degToRad(n*(r?90:45/2)),0),m.add(l);let y=(s?10:8)/16,b=(s?0:r?4.333:9.333)/16,_=y/2+b;return m.position.set(t.x+.5,t.y+_,t.z+.5),m}lightUpdate(t,n){for(let r=this.worldSizeParams.minY;r<this.worldSizeParams.worldHeight;r+=16)this.setSectionDirty(new lt(t,r,n))}rerenderAllChunks(){for(let t of Object.keys(this.sectionObjects)){let[n,r,s]=t.split(",").map(Number);this.setSectionDirty(new lt(n,r,s))}}updateShowChunksBorder(t){for(let n of Object.values(this.sectionObjects))for(let r of n.children)r.name==="helper"&&(r.visible=t)}resetWorld(){super.resetWorld(),this.worldBlockGeometry.resetWorld(),this.debugRaycastHelper&&(this.scene.remove(this.debugRaycastHelper),this.debugRaycastHelper=void 0),this.debugHitPoint&&(this.scene.remove(this.debugHitPoint),this.debugHitPoint=void 0)}getLoadedChunksRelative(t,n=!1){let[r,s,a]=SE(t);return Object.fromEntries(Object.entries(this.sectionObjects).map(([o,l])=>{let[c,u,f]=o.split(",").map(Number),[v,m,y]=SE({x:c,y:u,z:f});return[n?`${v-r},${m-s},${y-a}`:`${v-r},${y-a}`,l]}))}cleanChunkTextures(t,n){let r=this.chunkTextures.get(`${Math.floor(t/16)},${Math.floor(n/16)}`)??{};for(let s of Object.keys(r))r[s].dispose(),delete r[s]}readdChunks(){for(let t of Object.keys(this.sectionObjects))this.scene.remove(this.sectionObjects[t]);setTimeout(()=>{for(let t of Object.keys(this.sectionObjects))this.scene.add(this.sectionObjects[t])},500)}disableUpdates(t=this.scene.children){for(let n of t)n.matrixWorldNeedsUpdate=!1,this.disableUpdates(n.children??[])}removeColumn(t,n){super.removeColumn(t,n),this.cleanChunkTextures(t,n),this.worldBlockGeometry.removeColumn(t,n)}setSectionDirty(...t){let[n]=t;this.cleanChunkTextures(n.x,n.z),super.setSectionDirty(...t)}static getRendererInfo(t){try{let n=t.getContext();return`${n.getParameter(n.getExtension("WEBGL_debug_renderer_info").UNMASKED_RENDERER_WEBGL)}`}catch(n){console.warn("Failed to get renderer info",n)}}worldStop(){this.media.onWorldStop()}destroy(){this.disposeModules(),this.fireworksLegacy.destroy(),super.destroy(),this.skyboxRenderer.dispose(),this.fireworks.dispose()}shouldObjectVisible(t){let r=this.getSectionHeight(),s=Math.floor(t.position.x/16)*16,a=Math.floor(t.position.z/16)*16,o=Math.floor(t.position.y/r)*r,l=`${s},${a}`,c=`${s},${o},${a}`;return!!this.finishedChunks[l]||!!this.sectionObjects[c]}handleUserClick(t){this.media.handleUserClick(t)}updateSectionOffsets(){let t=performance.now();for(let[n,r]of Object.entries(this.sectionsOffsetsAnimations)){let s=(t-r.time)/1e3;r.time=t,r.currentOffsetX+=r.speedX*s,r.currentOffsetY+=r.speedY*s,r.currentOffsetZ+=r.speedZ*s,r.limitX!==void 0&&(r.speedX>0?r.currentOffsetX=Math.min(r.currentOffsetX,r.limitX):r.currentOffsetX=Math.max(r.currentOffsetX,r.limitX)),r.limitY!==void 0&&(r.speedY>0?r.currentOffsetY=Math.min(r.currentOffsetY,r.limitY):r.currentOffsetY=Math.max(r.currentOffsetY,r.limitY)),r.limitZ!==void 0&&(r.speedZ>0?r.currentOffsetZ=Math.min(r.currentOffsetZ,r.limitZ):r.currentOffsetZ=Math.max(r.currentOffsetZ,r.limitZ));let a=this.sectionObjects[n];a&&(a.position.set(r.currentOffsetX,r.currentOffsetY,r.currentOffsetZ),a.updateMatrix())}}reloadWorld(){this.entities.reloadEntities()}};h();p();d();h();p();d();h();p();d();k2();var ET={},Hpe=!1;function oqe(){if(Hpe)return ET;Hpe=!0;var i=Y0;function e(s){if(typeof s!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(s))}function t(s,a){for(var o="",l=0,c=-1,u=0,f,v=0;v<=s.length;++v){if(v<s.length)f=s.charCodeAt(v);else{if(f===47)break;f=47}if(f===47){if(!(c===v-1||u===1))if(c!==v-1&&u===2){if(o.length<2||l!==2||o.charCodeAt(o.length-1)!==46||o.charCodeAt(o.length-2)!==46){if(o.length>2){var m=o.lastIndexOf("/");if(m!==o.length-1){m===-1?(o="",l=0):(o=o.slice(0,m),l=o.length-1-o.lastIndexOf("/")),c=v,u=0;continue}}else if(o.length===2||o.length===1){o="",l=0,c=v,u=0;continue}}a&&(o.length>0?o+="/..":o="..",l=2)}else o.length>0?o+="/"+s.slice(c+1,v):o=s.slice(c+1,v),l=v-c-1;c=v,u=0}else f===46&&u!==-1?++u:u=-1}return o}function n(s,a){var o=a.dir||a.root,l=a.base||(a.name||"")+(a.ext||"");return o?o===a.root?o+l:o+s+l:l}var r={resolve:function(){for(var a="",o=!1,l,c=arguments.length-1;c>=-1&&!o;c--){var u;c>=0?u=arguments[c]:(l===void 0&&(l=i.cwd()),u=l),e(u),u.length!==0&&(a=u+"/"+a,o=u.charCodeAt(0)===47)}return a=t(a,!o),o?a.length>0?"/"+a:"/":a.length>0?a:"."},normalize:function(a){if(e(a),a.length===0)return".";var o=a.charCodeAt(0)===47,l=a.charCodeAt(a.length-1)===47;return a=t(a,!o),a.length===0&&!o&&(a="."),a.length>0&&l&&(a+="/"),o?"/"+a:a},isAbsolute:function(a){return e(a),a.length>0&&a.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var a,o=0;o<arguments.length;++o){var l=arguments[o];e(l),l.length>0&&(a===void 0?a=l:a+="/"+l)}return a===void 0?".":r.normalize(a)},relative:function(a,o){if(e(a),e(o),a===o||(a=r.resolve(a),o=r.resolve(o),a===o))return"";for(var l=1;l<a.length&&a.charCodeAt(l)===47;++l);for(var c=a.length,u=c-l,f=1;f<o.length&&o.charCodeAt(f)===47;++f);for(var v=o.length,m=v-f,y=u<m?u:m,b=-1,_=0;_<=y;++_){if(_===y){if(m>y){if(o.charCodeAt(f+_)===47)return o.slice(f+_+1);if(_===0)return o.slice(f+_)}else u>y&&(a.charCodeAt(l+_)===47?b=_:_===0&&(b=0));break}var g=a.charCodeAt(l+_),x=o.charCodeAt(f+_);if(g!==x)break;g===47&&(b=_)}var w="";for(_=l+b+1;_<=c;++_)(_===c||a.charCodeAt(_)===47)&&(w.length===0?w+="..":w+="/..");return w.length>0?w+o.slice(f+b):(f+=b,o.charCodeAt(f)===47&&++f,o.slice(f))},_makeLong:function(a){return a},dirname:function(a){if(e(a),a.length===0)return".";for(var o=a.charCodeAt(0),l=o===47,c=-1,u=!0,f=a.length-1;f>=1;--f)if(o=a.charCodeAt(f),o===47){if(!u){c=f;break}}else u=!1;return c===-1?l?"/":".":l&&c===1?"//":a.slice(0,c)},basename:function(a,o){if(o!==void 0&&typeof o!="string")throw new TypeError('"ext" argument must be a string');e(a);var l=0,c=-1,u=!0,f;if(o!==void 0&&o.length>0&&o.length<=a.length){if(o.length===a.length&&o===a)return"";var v=o.length-1,m=-1;for(f=a.length-1;f>=0;--f){var y=a.charCodeAt(f);if(y===47){if(!u){l=f+1;break}}else m===-1&&(u=!1,m=f+1),v>=0&&(y===o.charCodeAt(v)?--v===-1&&(c=f):(v=-1,c=m))}return l===c?c=m:c===-1&&(c=a.length),a.slice(l,c)}else{for(f=a.length-1;f>=0;--f)if(a.charCodeAt(f)===47){if(!u){l=f+1;break}}else c===-1&&(u=!1,c=f+1);return c===-1?"":a.slice(l,c)}},extname:function(a){e(a);for(var o=-1,l=0,c=-1,u=!0,f=0,v=a.length-1;v>=0;--v){var m=a.charCodeAt(v);if(m===47){if(!u){l=v+1;break}continue}c===-1&&(u=!1,c=v+1),m===46?o===-1?o=v:f!==1&&(f=1):o!==-1&&(f=-1)}return o===-1||c===-1||f===0||f===1&&o===c-1&&o===l+1?"":a.slice(o,c)},format:function(a){if(a===null||typeof a!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof a);return n("/",a)},parse:function(a){e(a);var o={root:"",dir:"",base:"",ext:"",name:""};if(a.length===0)return o;var l=a.charCodeAt(0),c=l===47,u;c?(o.root="/",u=1):u=0;for(var f=-1,v=0,m=-1,y=!0,b=a.length-1,_=0;b>=u;--b){if(l=a.charCodeAt(b),l===47){if(!y){v=b+1;break}continue}m===-1&&(y=!1,m=b+1),l===46?f===-1?f=b:_!==1&&(_=1):f!==-1&&(_=-1)}return f===-1||m===-1||_===0||_===1&&f===m-1&&f===v+1?m!==-1&&(v===0&&c?o.base=o.name=a.slice(1,m):o.base=o.name=a.slice(v,m)):(v===0&&c?(o.name=a.slice(1,f),o.base=a.slice(1,m)):(o.name=a.slice(v,f),o.base=a.slice(v,m)),o.ext=a.slice(f,m)),v>0?o.dir=a.slice(0,v-1):c&&(o.dir="/"),o},sep:"/",delimiter:":",win32:null,posix:null};return r.posix=r,ET=r,ET}var qr=oqe();k2();var Ohn=qr._makeLong,Dhn=qr.basename,Vhn=qr.delimiter,Uhn=qr.dirname,Fhn=qr.extname,zhn=qr.format,qhn=qr.isAbsolute,AT=qr.join,Hhn=qr.normalize,Ghn=qr.parse,Whn=qr.posix,jhn=qr.relative,$hn=qr.resolve,Xhn=qr.sep,Yhn=qr.win32;zt();h();p();d();var Sve=Wr(Jpe(),1),Eve=Wr(xve(),1);var Ave=i=>{let e=(0,Sve.default)(i),t=(0,Eve.default)(i),n=new e(i).sync,r=NHe(n);for(let s of r)if(s.startsWith("set")&&s!=="setColumn"){let a=n[s].bind(n);n[s]=(...o)=>{let l=o[0];l.x!==void 0&&!n.getColumnAt(l)&&n.setColumn(Math.floor(l.x/16),Math.floor(l.z/16),new t(void 0)),a(...o)}}return n};function NHe(i){let e=new Set,t=i;do for(let n of Object.getOwnPropertyNames(t))typeof i[n]=="function"&&n!=="constructor"&&e.add(n);while(t=Object.getPrototypeOf(t));return[...e]}h();p();d();var Mve={paused:!1,showChunkBorders:!1,enableDebugOverlay:!1,debugModelVariant:void 0,futuristicReveal:!1,wasmMesher:!1,mesherWorkers:1,addChunksBatchWaitTime:200,_experimentalSmoothChunkLoading:!0,_renderByChunks:!1,dayCycle:!0,smoothLighting:!0,enableLighting:!0,starfield:!0,defaultSkybox:!0,renderEntities:!0,extraBlockRenderers:!0,foreground:!0,fov:75,volume:1,showHand:!1,viewBobbing:!1,renderEars:!0,highlightBlockColor:"blue",fetchPlayerSkins:!0,skinTexturesProxy:void 0,vrSupport:!0,vrPageGameRendering:!0,clipWorldBelowY:void 0,isPlayground:!1,instantCameraUpdate:!1,isRaining:!1,moduleStates:{}};var kR=()=>({reactive:co({world:{chunksLoaded:new Set,heightmaps:new Map,allChunksLoaded:!1,mesherWork:!1,intersectMedia:null},renderer:"...",preventEscapeMenu:!1}),nonReactive:{fps:0,worstRenderTime:0,avgRenderTime:0,world:{chunksLoaded:new Set,chunksTotalNumber:0},renderer:{timeline:{live:[],frozen:[],lastSecond:[]}}}});h();p();d();var Tve="1.21.4";h();p();d();h();p();d();h();p();d();As();var r3=i=>[Math.floor(i.x/16),Math.floor(i.z/16)];var OHe=async(i,e,t,n=1)=>{for(let r=0;r<i.length;r+=n)e&&await new Promise(s=>setTimeout(s,e)),await t(i[r],r)},i3=class i3 extends A0{static restoreTransferred(e,t){let n=new i3;return t&&t.addEventListener("message",({data:r})=>{r.class===i3.restorerName&&r.type==="event"&&n.emit(r.eventName,...r.args)}),n}};jr(i3,"restorerName","WorldViewWorker");var Zh=i3,r8=class extends A0{constructor(t,n,r=new lt(0,0,0)){super();this.world=t;this.viewDistance=n;this.lastPos=new lt(0,0,0).update(r)}spiralNumber=0;gotPanicLastTime=!1;panicChunksReload=()=>{};loadedChunks={};inLoading=!1;chunkReceiveTimes=[];lastChunkReceiveTime=0;lastChunkReceiveTimeAvg=0;panicTimeout;lastPos;eventListeners={};debugChunksInfo={};waitingSpiralChunksLoad={};addWaitTime=1;keepChunksDistance=0;isPlayground=!1;allowPositionUpdate=!0;prepareForTransfer(t){if(t){let n=this.emit.bind(this);this.emit=(r,...s)=>{n(r,...s),t.postMessage({class:Zh.restorerName,type:"event",eventName:r,args:s})}}return{__restorer:Zh.restorerName}}setBlockStateId(t,n){let r=this.world.setBlockStateId(t,n);if(r&&typeof r.then=="function")throw new Error("setBlockStateId returned promise (not supported)");this.emit("blockUpdate",{pos:t,stateId:n})}updateViewDistance(t){this.viewDistance=t,this.emit("renderDistance",t)}async init(t,n){console.log("WorldView init"),this.updateViewDistance(this.viewDistance),this.emit("chunkPosUpdate",{pos:t}),n?.time?.timeOfDay!==void 0&&this.emit("time",n.time.timeOfDay),n?.entity&&this.emit("playerEntity",n.entity),this.emitterGotConnected(n);let[r,s]=r3(t),a=Q2(this.viewDistance).map(([o,l])=>new lt((r+o)*16,0,(s+l)*16));this.lastPos.update(t),await this._loadChunks(a,t)}chunkProgress(){if(this.panicTimeout&&clearTimeout(this.panicTimeout),this.chunkReceiveTimes.length>=5){let t=this.chunkReceiveTimes.reduce((r,s)=>r+s,0)/this.chunkReceiveTimes.length;this.lastChunkReceiveTimeAvg=t;let n=t*2+1e3;this.panicTimeout&&clearTimeout(this.panicTimeout),this.panicTimeout=setTimeout(()=>{!this.gotPanicLastTime&&this.inLoading&&(console.warn("Chunk loading seems stuck, triggering panic reload"),this.gotPanicLastTime=!0,this.panicChunksReload())},n)}}async _loadChunks(t,n){this.spiralNumber++;let{spiralNumber:r}=this;for(let a of Object.keys(this.waitingSpiralChunksLoad))this.waitingSpiralChunksLoad[a](!1),delete this.waitingSpiralChunksLoad[a];let s=!0;this.inLoading=!0,await OHe(t,this.addWaitTime,async a=>{!s||this.loadedChunks[`${a.x},${a.z}`]||(this.world.getColumnAt(a)||(s=await new Promise(o=>{this.waitingSpiralChunksLoad[`${a.x},${a.z}`]=o})),s&&(await this.loadChunk(a,void 0,`spiral ${r} from ${n.x},${n.z}`),this.chunkProgress()))}),this.panicTimeout&&clearTimeout(this.panicTimeout),this.inLoading=!1,this.gotPanicLastTime=!1,this.chunkReceiveTimes=[],this.lastChunkReceiveTime=0}async loadChunk(t,n=!1,r="spiral"){let[s,a]=r3(this.lastPos),o=Math.abs(s-Math.floor(t.x/16)),l=Math.abs(a-Math.floor(t.z/16));if(o<=this.viewDistance&&l<=this.viewDistance){let c=await this.world.getColumnAt(t.y!==void 0?t:new lt(t.x,0,t.z));if(c){let u=c.toJson(),f={minY:c.minY??0,worldHeight:c.worldHeight??256};this.emit("loadChunk",{x:t.x,z:t.z,chunk:u,blockEntities:c.blockEntities,worldConfig:f,isLightUpdate:n}),this.loadedChunks[`${t.x},${t.z}`]=!0,this.debugChunksInfo[`${t.x},${t.z}`]??={loads:[]},this.debugChunksInfo[`${t.x},${t.z}`].loads.push({dataLength:u.length,reason:r,time:Date.now()})}else this.isPlayground&&this.emit("markAsLoaded",{x:t.x,z:t.z})}}unloadAllChunks(){for(let t of Object.keys(this.loadedChunks)){let[n,r]=t.split(",").map(Number);this.unloadChunk({x:n,z:r})}}unloadChunk(t){this.emit("unloadChunk",{x:t.x,z:t.z}),delete this.loadedChunks[`${t.x},${t.z}`],delete this.debugChunksInfo[`${t.x},${t.z}`]}emitterGotConnected(t){typeof globalThis.WorkerGlobalScope<"u"&&globalThis instanceof globalThis.WorkerGlobalScope||!t||this.emit("blockEntities",new Proxy({},{get(r,s,a){if(typeof s!="string")return;let[o,l,c]=s.split(",").map(Number);return t.world.getBlock(new lt(o,l,c))?.entity}}))}lastBiomeId=null;updateBiome(t){try{if(!this.world.getBiome)return;let n=this.world.getBiome(t);n!==this.lastBiomeId&&(this.lastBiomeId=n,this.emit("biomeReset"))}catch(n){console.error("error updating biome",n)}}lastPosCheck=null;async updatePosition(t,n=!1){if(!this.allowPositionUpdate)return;let r=t.floored();if(!n&&this.lastPosCheck&&this.lastPosCheck.equals(r))return;this.lastPosCheck=r,this.updateBiome(t);let[s,a]=r3(this.lastPos),[o,l]=r3(t);if(s!==o||a!==l||n){this.emit("chunkPosUpdate",{pos:t});let c=[],u=n?this.viewDistance:this.viewDistance+this.keepChunksDistance;for(let v of Object.keys(this.loadedChunks)){let[m,y]=v.split(",").map(Number),b=new lt(m,0,y),[_,g]=r3(b),x=Math.abs(o-_),w=Math.abs(l-g);(x>u||w>u)&&c.push(b)}for(let v of c)this.unloadChunk(v);let f=Q2(this.viewDistance).map(([v,m])=>{let y=new lt((o+v)*16,0,(l+m)*16);if(!this.loadedChunks[`${y.x},${y.z}`])return y}).filter(v=>!!v);this.lastPos.update(t),this._loadChunks(f,t)}else this.emit("chunkPosUpdate",{pos:t}),this.lastPos.update(t)}};var CR=new Date,Rve=CR.getMonth()===11&&CR.getDate()>=24&&CR.getDate()<=26,DHe=["panorama_3.webp","panorama_1.webp","panorama_4.webp","panorama_5.webp","panorama_0.webp","panorama_2.webp"],i8=class{constructor(e,t,n=!1){this.documentRenderer=e;this.options=t;this.doWorldBlocksPanorama=n;this.scene=new Qi,this.scene.background=new Ge(3294568),this.ambientLight=new b0(13421772),this.scene.add(this.ambientLight),this.directionalLight=new ca(16777215,.5),this.directionalLight.position.set(1,1,.5).normalize(),this.directionalLight.castShadow=!0,this.scene.add(this.directionalLight),this.camera=new cn(85,this.documentRenderer.canvas.width/this.documentRenderer.canvas.height,.05,1e3),this.camera.position.set(0,0,0),this.camera.rotation.set(0,0,0)}camera;scene;ambientLight;directionalLight;panoramaGroup=null;time=0;abortController=new AbortController;worldRenderer;WorldRendererClass=nu;startTimes=new Map;async start(){this.doWorldBlocksPanorama?await this.worldBlocksPanorama():this.addClassicPanorama(),this.documentRenderer.render=(e=!1)=>{e&&(this.camera.aspect=this.documentRenderer.canvas.width/this.documentRenderer.canvas.height,this.camera.updateProjectionMatrix()),this.documentRenderer.renderer.render(this.scene,this.camera)}}async debugImageInFrontOfCamera(){let e=await el(AT("background","panorama_0.webp")),t=new Ye(new Qn(1e3,1e3),new ot({map:e}));t.position.set(0,0,-500),t.rotation.set(0,0,0),this.scene.add(t)}addClassicPanorama(){let e=new on(1e3,1e3,1e3),t=[],n=200;for(let a of DHe)(async()=>{let{texture:l}=Zg(AT("background",Rve?"christmas":"",a));l.matrixAutoUpdate=!1,l.matrix.set(-1,0,1,0,1,0,0,0,1),l.wrapS=Rn,l.wrapT=Rn,l.minFilter=Yt,l.magFilter=Yt;let c=new ot({map:l,transparent:!0,side:Tn,depthWrite:!1,opacity:0});this.startTimes.set(c,Date.now()),t.push(c)})();let r=new Ye(e,t);r.onBeforeRender=()=>{this.time+=.01,r.rotation.y=Math.PI+this.time*.01,r.rotation.z=Math.sin(-this.time*.001)*.001;for(let a of t){let o=this.startTimes.get(a);if(o){let l=Date.now()-o,c=Math.min(1,l/n);a.opacity=c}}};let s=new St;if(s.add(r),!Rve)for(let a=0;a<20;a++){let o=new Go("1.16.4","squid").mesh;o.position.set(Math.random()*30-15,Math.random()*20-10,Math.random()*10-17),o.rotation.set(0,Math.PI+Math.random(),-Math.PI/4,"ZYX");let l=Math.random()*.01;o.children[0].onBeforeRender=()=>{o.rotation.y+=l,o.rotation.z=Math.cos(r.rotation.y*3)*Math.PI/4-Math.PI/2},s.add(o)}this.scene.add(s),this.panoramaGroup=s}async worldBlocksPanorama(){let e=Tve,t=new xf;if(t.currentConfig={version:e,noInventoryGui:!0},await t.updateAssetsData?.({}),this.abortController.signal.aborted)return;console.time("load panorama scene");let n=Ave(e),s=ri()(e),o=globalThis.mcData.blocksArray.filter(g=>{if(!g.name.includes("stained_glass"))return!1;let x=s.fromStateId(g.defaultState,0);if(x.shapes?.length!==1)return!1;let w=x.shapes[0];return w[0]===0&&w[1]===0&&w[2]===0&&w[3]===1&&w[4]===1&&w[5]===1}),l=-15,c=100,u=100;for(let g=-c;g<c;g++)for(let x=-u;x<u;x++){let w=o[Math.floor(Math.random()*o.length)];n.setBlockStateId(new lt(g,x,l),w.defaultState)}this.camera.updateProjectionMatrix(),this.camera.position.set(.5,u/2+.5,.5),this.camera.rotation.set(0,0,0);let f=new lt(...this.camera.position.toArray()),v=new r8(n,2,f);if(this.abortController.signal.aborted||(this.worldRenderer=new this.WorldRendererClass(this.documentRenderer.renderer,this.options,{version:e,worldView:v,inWorldRenderingConfig:Mve,playerStateReactive:hhe().reactive,rendererState:kR().reactive,nonReactiveState:kR().nonReactive,resourcesManager:t}),this.worldRenderer instanceof nu&&(this.scene=this.worldRenderer.scene),v.init(f),await this.worldRenderer.waitForChunksToRender(),this.abortController.signal.aborted))return;let{camera:m}=this,y=m.position.x,b=m.position.y,_;document.body.addEventListener("pointermove",g=>{if(g.pointerType!=="mouse")return;let x=new Ve(g.clientX,g.clientY),w=.2,S=x.x/window.innerWidth-.5,A=-(x.y/window.innerHeight-.5);_?.stop();let P={x:y+S*w,y:b+A*w};_=new br(m.position).to(P,0),_.start(),m.updateProjectionMatrix()},{signal:this.abortController.signal}),console.timeEnd("load panorama scene")}dispose(){this.scene.clear(),this.worldRenderer?.destroy(),this.abortController.abort()}};ui.enabled=!1;globalThis.THREE=rn;var kve=i=>({updateMap:i.entities.updateMap.bind(i.entities),updateCustomBlock:i.updateCustomBlock.bind(i),getBlockInfo:i.getBlockInfo.bind(i),playEntityAnimation:i.entities.playAnimation.bind(i.entities),damageEntity:i.entities.handleDamageEvent.bind(i.entities),updatePlayerSkin:i.entities.updatePlayerSkin.bind(i.entities),changeHandSwingingState:i.changeHandSwingingState.bind(i),getHighestBlocks:i.getHighestBlocks.bind(i),reloadWorld:i.reloadWorld.bind(i),updateEntityModel:i.entities.updateEntityModel.bind(i.entities),playEntityModelAnimation:i.entities.playEntityModelAnimation.bind(i.entities),addMedia:i.media.addMedia.bind(i.media),destroyMedia:i.media.destroyMedia.bind(i.media),setControlMode:i.media.setControlMode.bind(i.media),setVideoPlaying:i.media.setVideoPlaying.bind(i.media),setVideoSeeking:i.media.setVideoSeeking.bind(i.media),setVideoVolume:i.media.setVideoVolume.bind(i.media),setVideoSpeed:i.media.setVideoSpeed.bind(i.media),handleUserClick:i.media.handleUserClick.bind(i.media),addSectionAnimation(e,t){i.sectionsOffsetsAnimations[e]=t},removeSectionAnimation(e){delete i.sectionsOffsetsAnimations[e]},shakeFromDamage:i.cameraShake.shakeFromDamage.bind(i.cameraShake),onPageInteraction:i.media.onPageInteraction.bind(i.media),downloadMesherLog:i.downloadMesherLog.bind(i),explodeFirework:i.fireworksLegacy.explode.bind(i.fireworksLegacy),explodeFireworkFacingCamera:i.fireworksLegacy.explodeFacingCamera.bind(i.fireworksLegacy),addWaypoint:i.waypoints.addWaypoint.bind(i.waypoints),removeWaypoint:i.waypoints.removeWaypoint.bind(i.waypoints),startCinimaticScript:i.cinimaticScript.startScript.bind(i.cinimaticScript),stopCinimaticScript:i.cinimaticScript.stopScript.bind(i.cinimaticScript),launchFirework:i.fireworks.launchFirework.bind(i.fireworks),setSkyboxImage:i.skyboxRenderer.setSkyboxImage.bind(i.skyboxRenderer),setRain:e=>i.toggleModule("rain",e),async loadGeometryExport(e){let{applyWorldGeometryExport:t}=await Promise.resolve().then(()=>(vT(),Ppe));return t(i,e)}}),VHe=[],s8=(i,...e)=>{for(let t of Object.values(globalThis.loadedMods??{}))try{t.threeJsBackendModule?.[i]?.(...e)}catch(n){let r=`[mod three.js] Error calling ${i} on ${t.name}: ${n}`;throw new Error(r)}},Cve=()=>{let i,e=null,t=null,n=null,r=null,s=(u,f)=>{Gn?i=ev(u,VHe,globalThis):i=u,e=new Yg(i,f?.canvas),globalThis.renderer=e.renderer,globalThis.documentRenderer=e,globalThis.threeJsBackend=c,s8("default",c)},a=async()=>{if(!e)throw new Error("Document renderer not initialized");if(!n&&!t){let u={...i};t=new i8(e,u,!!process.env.SINGLE_FILE_BUILD_MODE),globalThis.panoramaRenderer=t,s8("panoramaCreated",t),await t.start(),s8("panoramaReady",t)}},o=async u=>{let v=Gn?ev(u,[xf,Zh],globalThis):u;if(!e)throw new Error("Document renderer not initialized");e.nonReactiveState=v.nonReactiveState,globalThis.resourcesManager=v.resourcesManager,t&&(t.dispose(),t=null),n=new nu(e.renderer,i,v),await n.worldReadyPromise,r=new u6(v.nonReactiveState),globalThis.frameTimingCollector=r;let m=e.render;e.render=function(y){m.call(this,y),r?.markFrameStart(),v.inWorldRenderingConfig.paused||n?.render(y),r?.markFrameEnd(),r?.markFrameDisplay()},e.inWorldRenderingConfig=v.inWorldRenderingConfig,globalThis.world=n,s8("worldReady",n)},l=()=>{t&&(t.dispose(),t=null),e&&e.dispose(),n&&(n.destroy(),n=null)},c={id:"threejs",displayName:`three.js ${fa}`,startPanorama:a,startWorld:o,disconnect:l,setRendering(u){e.setPaused(!u),n&&(n.renderingActive=u)},getDebugOverlay:()=>({get entitiesString(){return n?.entities.getDebugString()}}),updateCamera(u,f,v){r?.markCameraUpdate(!u),n?.setFirstPersonCamera(u,f,v)},get soundSystem(){return n?.soundSystem},get backendMethods(){if(n)return kve(n)}};return{main:{init:s,backend:c},workerProxy(){return YI({init(u,f){s(u,{canvas:f})},updateSizeExternal(u,f,v){e?.updateSizeExternal(u,f,v)},startPanorama:a,startWorld:o,disconnect:l,setRendering:c.setRendering,updateCamera(u,f,v){let m=u?new lt(u.x,u.y,u.z):null;r?.markCameraUpdate(!m),c.updateCamera(m,f,v)},async callBackendMethod(u,...f){if(!n)throw new Error("World renderer not initialized");let m=kve(n)[u];if(!m)throw new Error(`Backend method ${String(u)} is unavailable`);return m(...f)}})}}};globalThis.structuredClone??=i=>JSON.parse(JSON.stringify(i));self.addEventListener("message",i=>{let e=i.data,t=globalThis;if(e.type==="mcData"){t.mcData=e.mcData,t.loadedData=e.mcData,console.log("data loaded");return}Array.isArray(e)&&e.forEach(n=>{n.type==="mcData"&&(t.mcData=n.mcData,t.loadedData=n.mcData)})});var UHe=Cve();UHe.workerProxy();})();
|
|
29114
29114
|
/*! Bundled license information:
|
|
29115
29115
|
|
|
29116
29116
|
@jspm/core/nodelibs/browser/chunk-DtuTasat.js:
|
package/package.json
CHANGED
package/src/three/cameraShake.ts
CHANGED
|
@@ -10,7 +10,7 @@ export class CameraShake {
|
|
|
10
10
|
private basePitch = 0
|
|
11
11
|
private baseYaw = 0
|
|
12
12
|
|
|
13
|
-
constructor(public worldRenderer: WorldRendererThree, public onRenderCallbacks: Array<() => void>) {
|
|
13
|
+
constructor(public worldRenderer: WorldRendererThree, public onRenderCallbacks: Array<(deltaTime: number) => void>) {
|
|
14
14
|
onRenderCallbacks.push(() => {
|
|
15
15
|
this.update()
|
|
16
16
|
})
|
|
@@ -12,9 +12,9 @@ interface RainParticleData {
|
|
|
12
12
|
const PARTICLE_COUNT = 2000
|
|
13
13
|
const RANGE = 32
|
|
14
14
|
const HEIGHT = 32
|
|
15
|
-
const FALL_SPEED_MIN =
|
|
16
|
-
const FALL_SPEED_MAX =
|
|
17
|
-
const HORIZONTAL_DRIFT =
|
|
15
|
+
const FALL_SPEED_MIN = 12
|
|
16
|
+
const FALL_SPEED_MAX = 24
|
|
17
|
+
const HORIZONTAL_DRIFT = 1.2
|
|
18
18
|
const RESPAWN_BELOW = -5
|
|
19
19
|
|
|
20
20
|
export class RainModule implements RendererModuleController {
|
|
@@ -52,7 +52,7 @@ export class RainModule implements RendererModuleController {
|
|
|
52
52
|
return this.worldRenderer.worldRendererConfig.isRaining === true
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
render?: () => void = () => {
|
|
55
|
+
render?: (deltaTime: number) => void = (deltaTime) => {
|
|
56
56
|
if (!this.enabled || !this.instancedMesh) return
|
|
57
57
|
|
|
58
58
|
const cameraPos = this.worldRenderer.getCameraPosition()
|
|
@@ -72,7 +72,7 @@ export class RainModule implements RendererModuleController {
|
|
|
72
72
|
this.instancedMesh.getMatrixAt(i, dummy)
|
|
73
73
|
dummy.decompose(position, quaternion, scale)
|
|
74
74
|
|
|
75
|
-
position.
|
|
75
|
+
position.addScaledVector(particle.velocity, deltaTime)
|
|
76
76
|
|
|
77
77
|
const relativeY = position.y
|
|
78
78
|
const horizontalDist = Math.sqrt(position.x * position.x + position.z * position.z)
|
|
@@ -108,9 +108,9 @@ export class SciFiWorldRevealModule implements RendererModuleController {
|
|
|
108
108
|
return this.enabled
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
render?: () => void = () => {
|
|
111
|
+
render?: (deltaTime: number) => void = (deltaTime) => {
|
|
112
112
|
if (!this.enabled) return
|
|
113
|
-
this.update(
|
|
113
|
+
this.update(deltaTime * 1000)
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
dispose(): void {
|
|
@@ -72,7 +72,7 @@ export class StarfieldModule implements RendererModuleController {
|
|
|
72
72
|
return this.currentTime > nightTime && this.currentTime < morningStart
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
render?: () => void = () => {
|
|
75
|
+
render?: (deltaTime: number) => void = (_deltaTime) => {
|
|
76
76
|
if (!this.points) return
|
|
77
77
|
this.points.position.copy(this.worldRenderer.getCameraPosition())
|
|
78
78
|
; (this.points.material as StarfieldMaterial).uniforms.time.value =
|
|
@@ -11,7 +11,7 @@ export interface RendererModuleController {
|
|
|
11
11
|
|
|
12
12
|
enablementCheck?: () => boolean
|
|
13
13
|
autoEnableCheck?: () => boolean // Called when config updates, returns true to enable, false to disable
|
|
14
|
-
render?: () => void
|
|
14
|
+
render?: (deltaTime: number) => void
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -57,7 +57,8 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
57
57
|
material = new THREE.MeshLambertMaterial({ vertexColors: true, transparent: true, alphaTest: 0.1 })
|
|
58
58
|
itemsTexture!: THREE.Texture
|
|
59
59
|
cursorBlock: CursorBlock
|
|
60
|
-
onRender: Array<() => void> = []
|
|
60
|
+
onRender: Array<(deltaTime: number) => void> = []
|
|
61
|
+
private lastRenderTime = 0
|
|
61
62
|
cameraShake: CameraShake
|
|
62
63
|
cameraContainer!: THREE.Object3D
|
|
63
64
|
media: ThreeJsMedia
|
|
@@ -928,6 +929,10 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
928
929
|
this.debugChunksVisibilityOverride()
|
|
929
930
|
const start = performance.now()
|
|
930
931
|
this.lastRendered = performance.now()
|
|
932
|
+
const deltaTime = this.lastRenderTime > 0
|
|
933
|
+
? Math.min(Math.max((start - this.lastRenderTime) / 1000, 0), 0.1)
|
|
934
|
+
: 1 / 60
|
|
935
|
+
this.lastRenderTime = start
|
|
931
936
|
this.cursorBlock.render()
|
|
932
937
|
this.updateSectionOffsets()
|
|
933
938
|
|
|
@@ -974,7 +979,7 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
974
979
|
this.fireworks.update()
|
|
975
980
|
|
|
976
981
|
for (const onRender of this.onRender) {
|
|
977
|
-
onRender()
|
|
982
|
+
onRender(deltaTime)
|
|
978
983
|
}
|
|
979
984
|
const end = performance.now()
|
|
980
985
|
const totalTime = end - start
|