minecraft-renderer 0.1.26 → 0.1.27

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.
@@ -21787,7 +21787,7 @@ void main() {
21787
21787
 
21788
21788
  #include <tonemapping_fragment>
21789
21789
  #include <${dk>=154?"colorspace_fragment":"encodings_fragment"}>
21790
- }`})}},hn=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 bn;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)}},td={id:"starfield",controller:hn,enabledDefault:!0,cannotBeDisabled:!0};var od={starfield:td,futuristicReveal:ed,rain:Xu};var Yo=class l extends Kl{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 ma(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 Ra(this,this.scene,this.material,r),this.cursorBlock=new ba(this),this.holdingBlock=new gr(this),this.holdingBlockLeft=new gr(this,!0);for(let a of Object.values(od))this.registerModule(a);this.skyboxRenderer=new Ia(this.scene,!1,null),this.skyboxRenderer.init(),this.addDebugOverlay(),this.resetScene(),this.init(),this.soundSystem=new ka(this),this.cameraShake=new fa(this,this.onRender),this.media=new ga(this),this.fireworksLegacy=new ya(this),this.waypoints=new xa(this),this.cinimaticScript=new wa(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 Aa(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(){sn(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=ps(t.blocksAtlasImage);a.needsUpdate=!0,a.flipY=!1,this.material.map=a;let s=ps(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(rn)}getItemRenderData(t,o){return Gu(t,o,this.resourcesManager,this.playerStateReactive)}async demoModel(){let t=cursorBlockRel(0,1,0).position,o=await nl();n_(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=ur("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=Ul(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=pk(this.version),_=qc(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 _=wr(this,i,Ar.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]=Qa(t);return Object.fromEntries(Object.entries(this.sectionObjects).map(([n,i])=>{let[c,_,u]=n.split(",").map(Number),[b,h,k]=Qa({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 vn(l){throw new Error("Node.js process "+l+" is not supported by JSPM core outside of Node.js")}var Ft=[],Sr=!1,$o,Ta=-1;function mk(){!Sr||!$o||(Sr=!1,$o.length?Ft=$o.concat(Ft):Ta=-1,Ft.length&&rd())}function rd(){if(!Sr){var l=setTimeout(mk,0);Sr=!0;for(var e=Ft.length;e;){for($o=Ft,Ft=[];++Ta<e;)$o&&$o[Ta].run();Ta=-1,e=Ft.length}$o=null,Sr=!1,clearTimeout(l)}}function bk(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 ld(l,e)),Ft.length===1&&!Sr&&setTimeout(rd,0)}function ld(l,e){this.fun=l,this.array=e}ld.prototype.run=function(){this.fun.apply(null,this.array)};var hk="browser",kk="x64",fk="browser",gk={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},vk=["/usr/bin/node"],xk=[],yk="v16.8.0",wk={},Ik=function(l,e){},Ak=function(l){vn("binding")},zk=function(l){return 0},Ek=function(){return"/"},Mk=function(l){},Rk={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};function Ke(){}var Ok=Ke,Sk=[];function Tk(l){vn("_linkedBinding")}var Ck={},Pk=!1,Bk={};function jk(l){vn("dlopen")}function Hk(){return[]}function Dk(){return[]}var Nk=Ke,Gk=Ke,xn=function(){return{}},Lk=xn,Wk=xn,Uk=Ke,qk=Ke,Fk=Ke,Vk={};function Yk(l,e){if(!l)throw new Error(e||"assertion error")}var $k={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},Zk=Ke,Kk=Ke;function Jk(){return!1}var Xk=Ke,Qk=Ke,ef=Ke,tf=Ke,of=Ke,rf=void 0,lf=void 0,af=void 0,sf=Ke,nf=2,cf=1,_f="/bin/usr/node",uf=9229,df="node",pf=[],mf=Ke,so={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};so.now===void 0&&(kn=Date.now(),so.timing&&so.timing.navigationStart&&(kn=so.timing.navigationStart),so.now=()=>Date.now()-kn);var kn;function bf(){return so.now()/1e3}var fn=1e9;function gn(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+=fn)),[o,r]}gn.bigint=function(l){var e=gn(l);return typeof BigInt>"u"?e[0]*fn+e[1]:BigInt(e[0]*fn)+BigInt(e[1])};var hf=10,kf={},ff=0;function no(){return yn}var gf=no,vf=no,xf=no,yf=no,wf=no,If=Ke,Af=no,zf=no;function Ef(l){return[]}var yn={version:yk,versions:wk,arch:kk,platform:fk,release:Rk,_rawDebug:Ok,moduleLoadList:Sk,binding:Ak,_linkedBinding:Tk,_events:kf,_eventsCount:ff,_maxListeners:hf,on:no,addListener:gf,once:vf,off:xf,removeListener:yf,removeAllListeners:wf,emit:If,prependListener:Af,prependOnceListener:zf,listeners:Ef,domain:Ck,_exiting:Pk,config:Bk,dlopen:jk,uptime:bf,_getActiveRequests:Hk,_getActiveHandles:Dk,reallyExit:Nk,_kill:Gk,cpuUsage:xn,resourceUsage:Lk,memoryUsage:Wk,kill:Uk,exit:qk,openStdin:Fk,allowedNodeEnvironmentFlags:Vk,assert:Yk,features:$k,_fatalExceptions:Zk,setUncaughtExceptionCaptureCallback:Kk,hasUncaughtExceptionCaptureCallback:Jk,emitWarning:Ik,nextTick:bk,_tickCallback:Xk,_debugProcess:Qk,_debugEnd:ef,_startProfilerIdleNotifier:tf,_stopProfilerIdleNotifier:of,stdout:rf,stdin:af,stderr:lf,abort:sf,umask:zk,chdir:Mk,cwd:Ek,env:gk,title:hk,argv:vk,execArgv:xk,pid:nf,ppid:cf,execPath:_f,debugPort:uf,hrtime:gn,argv0:df,_preload_modules:pf,setSourceMapsEnabled:mf};var wn={},ad=!1;function Mf(){if(ad)return wn;ad=!0;var l=yn;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,wn=r,wn}var Je=Mf();var HO=Je._makeLong,DO=Je.basename,NO=Je.delimiter,GO=Je.dirname,LO=Je.extname,WO=Je.format,UO=Je.isAbsolute,In=Je.join,qO=Je.normalize,FO=Je.parse,VO=Je.posix,YO=Je.relative,$O=Je.resolve,ZO=Je.sep,KO=Je.win32;import*as he from"three";I();A();E();z();import Rf from"prismarine-world";import Of from"prismarine-chunk";var sd=l=>{let e=Rf(l),t=Of(l),o=new e(l).sync,r=Sf(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 Sf(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 id}from"vec3";I();A();E();z();var nd="1.21.4";var An=new Date,cd=An.getMonth()===11&&An.getDate()>=24&&An.getDate()<=26,Tf=["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",Yo);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(In("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 Tf)(async()=>{let{texture:i}=$l(In("background",cd?"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),!cd)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=nd,t=new Dt;if(t.currentConfig={version:e,noInventoryGui:!0},await t.updateAssetsData?.({}),this.abortController.signal.aborted)return;let o=sd(e),a=gd("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 id(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 id(...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:Dr,playerStateReactive:ec().reactive,rendererState:po().reactive,nonReactiveState:po().nonReactive,resourcesManager:t}),this.worldRenderer instanceof Yo&&(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 C={x:k+M*R,y:f+O*R};y=new Le(h.position).to(C,0),y.start(),h.updateProjectionMatrix()},{signal:this.abortController.signal})}dispose(){this.scene.clear(),this.worldRenderer?.destroy(),this.abortController.abort()}};fl.ColorManagement.enabled=!1;globalThis.THREE=fl;var _d=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(()=>(nn(),Vu));return t(l,e)}}),Pf=[],Pa=(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)}},ud=()=>{let l,e=null,t=null,o=null,r=null,a=(_,u)=>{Oe?l=Gl(_,Pf,globalThis):l=_,e=new Kr(l,u?.canvas),globalThis.renderer=e.renderer,globalThis.documentRenderer=e,globalThis.threeJsBackend=c,Pa("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,Pa("panoramaCreated",t),await t.start(),Pa("panoramaReady",t)}},n=async _=>{let b=Oe?Gl(_,[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 Yo(e.renderer,l,b),await o.worldReadyPromise,r=new Ll(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,Pa("worldReady",o)},i=()=>{t&&(t.dispose(),t=null),e&&e.dispose(),o&&(o.destroy(),o=null)},c={id:"threejs",displayName:`three.js ${fl.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 _d(o)}};return{main:{init:a,backend:c},workerProxy(){return Nc({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=_d(o)[_];if(!h)throw new Error(`Backend method ${String(_)} is unavailable`);return h(...u)}})}}};var Ba=l=>{let{main:e}=ud();return e.init(l),e.backend};Ba.id="threejs";Ba.displayName="three.js Blocking";Ba.description="Simple, old and stable main thread graphics backend providing balanced performance on top of WebGL2.";I();A();E();z();import*as dd from"three";function Bf(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 ja=async l=>{let e=Bf(()=>{}),t=Gc(e),o=ls();o.onSizeChanged((n,i)=>{t.updateSizeExternal(n,i,window.devicePixelRatio||1)});let r=Nl(l,e);try{t.init(r,o.canvas)}catch(n){throw Vr(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 ${dd.REVISION}`,async startPanorama(){},async startWorld(n){let i={...Zr,items:"itemsArray",entities:"entitiesArray"};bs([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=Nl(n,e);try{await t.startWorld(structuredClone(c))}catch(u){throw Vr(c),u}t.updateSizeExternal(o.size.width,o.size.height,window.devicePixelRatio||1);let _=ur("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}};ja.id="threejs-off-thread";ja.displayName="three.js Multi-thread";ja.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{Tc as AppViewer,Kr as DocumentRenderer,cr as LoadedResourcesTransferrable,Dt as ResourcesManager,ko as WorldView,ho as WorldViewWorker,ls as addCanvasForWorker,Qo as chunkPos,ja as createGraphicsBackendOffThread,Ba as createGraphicsBackendSingleThread,d5 as createWorldRendererConfig,Xi as defaultGraphicsBackendConfig,Dr as defaultWorldRendererConfig,oc as delayedIterator,po as getDefaultRendererState,Cc as getInitialPlayerState,mm as getInitialPlayerStateRenderer,pm as getPlayerStateUtils,Oe as isWebWorker,zd as sectionPos};
21790
+ }`})}},hn=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 bn;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)}},td={id:"starfield",controller:hn,enabledDefault:!0,cannotBeDisabled:!0};var od={starfield:td,futuristicReveal:ed,rain:Xu};var Yo=class l extends Kl{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 ma(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 Ra(this,this.scene,this.material,r),this.cursorBlock=new ba(this),this.holdingBlock=new gr(this),this.holdingBlockLeft=new gr(this,!0);for(let a of Object.values(od))this.registerModule(a);this.skyboxRenderer=new Ia(this.scene,!1,null),this.skyboxRenderer.init(),this.addDebugOverlay(),this.resetScene(),this.init(),this.soundSystem=new ka(this),this.cameraShake=new fa(this,this.onRender),this.media=new ga(this),this.fireworksLegacy=new ya(this),this.waypoints=new xa(this),this.cinimaticScript=new wa(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 Aa(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(){sn(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=ps(t.blocksAtlasImage);a.needsUpdate=!0,a.flipY=!1,this.material.map=a;let s=ps(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(rn)}getItemRenderData(t,o){return Gu(t,o,this.resourcesManager,this.playerStateReactive)}async demoModel(){let t=cursorBlockRel(0,1,0).position,o=await nl();n_(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=ur("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=Ul(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=pk(this.version),_=qc(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 _=wr(this,i,Ar.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]=Qa(t);return Object.fromEntries(Object.entries(this.sectionObjects).map(([n,i])=>{let[c,_,u]=n.split(",").map(Number),[b,h,k]=Qa({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 vn(l){throw new Error("Node.js process "+l+" is not supported by JSPM core outside of Node.js")}var Ft=[],Sr=!1,$o,Ta=-1;function mk(){!Sr||!$o||(Sr=!1,$o.length?Ft=$o.concat(Ft):Ta=-1,Ft.length&&rd())}function rd(){if(!Sr){var l=setTimeout(mk,0);Sr=!0;for(var e=Ft.length;e;){for($o=Ft,Ft=[];++Ta<e;)$o&&$o[Ta].run();Ta=-1,e=Ft.length}$o=null,Sr=!1,clearTimeout(l)}}function bk(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 ld(l,e)),Ft.length===1&&!Sr&&setTimeout(rd,0)}function ld(l,e){this.fun=l,this.array=e}ld.prototype.run=function(){this.fun.apply(null,this.array)};var hk="browser",kk="x64",fk="browser",gk={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},vk=["/usr/bin/node"],xk=[],yk="v16.8.0",wk={},Ik=function(l,e){},Ak=function(l){vn("binding")},zk=function(l){return 0},Ek=function(){return"/"},Mk=function(l){},Rk={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};function Ke(){}var Ok=Ke,Sk=[];function Tk(l){vn("_linkedBinding")}var Ck={},Pk=!1,Bk={};function jk(l){vn("dlopen")}function Hk(){return[]}function Dk(){return[]}var Nk=Ke,Gk=Ke,xn=function(){return{}},Lk=xn,Wk=xn,Uk=Ke,qk=Ke,Fk=Ke,Vk={};function Yk(l,e){if(!l)throw new Error(e||"assertion error")}var $k={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},Zk=Ke,Kk=Ke;function Jk(){return!1}var Xk=Ke,Qk=Ke,ef=Ke,tf=Ke,of=Ke,rf=void 0,lf=void 0,af=void 0,sf=Ke,nf=2,cf=1,_f="/bin/usr/node",uf=9229,df="node",pf=[],mf=Ke,so={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};so.now===void 0&&(kn=Date.now(),so.timing&&so.timing.navigationStart&&(kn=so.timing.navigationStart),so.now=()=>Date.now()-kn);var kn;function bf(){return so.now()/1e3}var fn=1e9;function gn(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+=fn)),[o,r]}gn.bigint=function(l){var e=gn(l);return typeof BigInt>"u"?e[0]*fn+e[1]:BigInt(e[0]*fn)+BigInt(e[1])};var hf=10,kf={},ff=0;function no(){return yn}var gf=no,vf=no,xf=no,yf=no,wf=no,If=Ke,Af=no,zf=no;function Ef(l){return[]}var yn={version:yk,versions:wk,arch:kk,platform:fk,release:Rk,_rawDebug:Ok,moduleLoadList:Sk,binding:Ak,_linkedBinding:Tk,_events:kf,_eventsCount:ff,_maxListeners:hf,on:no,addListener:gf,once:vf,off:xf,removeListener:yf,removeAllListeners:wf,emit:If,prependListener:Af,prependOnceListener:zf,listeners:Ef,domain:Ck,_exiting:Pk,config:Bk,dlopen:jk,uptime:bf,_getActiveRequests:Hk,_getActiveHandles:Dk,reallyExit:Nk,_kill:Gk,cpuUsage:xn,resourceUsage:Lk,memoryUsage:Wk,kill:Uk,exit:qk,openStdin:Fk,allowedNodeEnvironmentFlags:Vk,assert:Yk,features:$k,_fatalExceptions:Zk,setUncaughtExceptionCaptureCallback:Kk,hasUncaughtExceptionCaptureCallback:Jk,emitWarning:Ik,nextTick:bk,_tickCallback:Xk,_debugProcess:Qk,_debugEnd:ef,_startProfilerIdleNotifier:tf,_stopProfilerIdleNotifier:of,stdout:rf,stdin:af,stderr:lf,abort:sf,umask:zk,chdir:Mk,cwd:Ek,env:gk,title:hk,argv:vk,execArgv:xk,pid:nf,ppid:cf,execPath:_f,debugPort:uf,hrtime:gn,argv0:df,_preload_modules:pf,setSourceMapsEnabled:mf};var wn={},ad=!1;function Mf(){if(ad)return wn;ad=!0;var l=yn;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,wn=r,wn}var Je=Mf();var HO=Je._makeLong,DO=Je.basename,NO=Je.delimiter,GO=Je.dirname,LO=Je.extname,WO=Je.format,UO=Je.isAbsolute,In=Je.join,qO=Je.normalize,FO=Je.parse,VO=Je.posix,YO=Je.relative,$O=Je.resolve,ZO=Je.sep,KO=Je.win32;import*as he from"three";I();A();E();z();import Rf from"prismarine-world";import Of from"prismarine-chunk";var sd=l=>{let e=Rf(l),t=Of(l),o=new e(l).sync,r=Sf(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 Sf(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 id}from"vec3";I();A();E();z();var nd="1.21.4";var An=new Date,cd=An.getMonth()===11&&An.getDate()>=24&&An.getDate()<=26,Tf=["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",Yo);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(In("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 Tf)(async()=>{let{texture:i}=$l(In("background",cd?"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),!cd)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=nd,t=new Dt;if(t.currentConfig={version:e,noInventoryGui:!0},await t.updateAssetsData?.({}),this.abortController.signal.aborted)return;let o=sd(e),a=gd("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 id(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 id(...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:Dr,playerStateReactive:ec().reactive,rendererState:po().reactive,nonReactiveState:po().nonReactive,resourcesManager:t}),this.worldRenderer instanceof Yo&&(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 C={x:k+M*R,y:f+O*R};y=new Le(h.position).to(C,0),y.start(),h.updateProjectionMatrix()},{signal:this.abortController.signal})}dispose(){this.scene.clear(),this.worldRenderer?.destroy(),this.abortController.abort()}};fl.ColorManagement.enabled=!1;globalThis.THREE=fl;var _d=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(()=>(nn(),Vu));return t(l,e)}}),Pf=[],Pa=(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)}},ud=()=>{let l,e=null,t=null,o=null,r=null,a=(_,u)=>{Oe?l=Gl(_,Pf,globalThis):l=_,e=new Kr(l,u?.canvas),globalThis.renderer=e.renderer,globalThis.documentRenderer=e,globalThis.threeJsBackend=c,Pa("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,Pa("panoramaCreated",t),await t.start(),Pa("panoramaReady",t)}},n=async _=>{let b=Oe?Gl(_,[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 Yo(e.renderer,l,b),await o.worldReadyPromise,r=new Ll(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,Pa("worldReady",o)},i=()=>{t&&(t.dispose(),t=null),e&&e.dispose(),o&&(o.destroy(),o=null)},c={id:"threejs",displayName:`three.js ${fl.REVISION}`,startPanorama:s,startWorld:n,disconnect:i,setRendering(_){e.setPaused(!_),o&&(o.renderingActive=_)},getDebugOverlay:()=>({get entitiesString(){return o?.entities.getDebugString()},get left(){return{"Geo Memory":o?.worldBlockGeometry.getEstimatedMemoryUsage().readable??"-"}}}),updateCamera(_,u,b){r?.markCameraUpdate(!_),o?.setFirstPersonCamera(_,u,b)},get soundSystem(){return o?.soundSystem},get backendMethods(){if(o)return _d(o)}};return{main:{init:a,backend:c},workerProxy(){return Nc({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=_d(o)[_];if(!h)throw new Error(`Backend method ${String(_)} is unavailable`);return h(...u)}})}}};var Ba=l=>{let{main:e}=ud();return e.init(l),e.backend};Ba.id="threejs";Ba.displayName="three.js Blocking";Ba.description="Simple, old and stable main thread graphics backend providing balanced performance on top of WebGL2.";I();A();E();z();import*as dd from"three";function Bf(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 ja=async l=>{let e=Bf(()=>{}),t=Gc(e),o=ls();o.onSizeChanged((n,i)=>{t.updateSizeExternal(n,i,window.devicePixelRatio||1)});let r=Nl(l,e);try{t.init(r,o.canvas)}catch(n){throw Vr(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 ${dd.REVISION}`,async startPanorama(){},async startWorld(n){let i={...Zr,items:"itemsArray",entities:"entitiesArray"};bs([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=Nl(n,e);try{await t.startWorld(structuredClone(c))}catch(u){throw Vr(c),u}t.updateSizeExternal(o.size.width,o.size.height,window.devicePixelRatio||1);let _=ur("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}};ja.id="threejs-off-thread";ja.displayName="three.js Multi-thread";ja.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{Tc as AppViewer,Kr as DocumentRenderer,cr as LoadedResourcesTransferrable,Dt as ResourcesManager,ko as WorldView,ho as WorldViewWorker,ls as addCanvasForWorker,Qo as chunkPos,ja as createGraphicsBackendOffThread,Ba as createGraphicsBackendSingleThread,d5 as createWorldRendererConfig,Xi as defaultGraphicsBackendConfig,Dr as defaultWorldRendererConfig,oc as delayedIterator,po as getDefaultRendererState,Cc as getInitialPlayerState,mm as getInitialPlayerStateRenderer,pm as getPlayerStateUtils,Oe as isWebWorker,zd as sectionPos};
21791
21791
  /*! Bundled license information:
21792
21792
 
21793
21793
  @jspm/core/nodelibs/browser/chunk-DtuTasat.js:
@@ -29110,7 +29110,7 @@ void main() {
29110
29110
 
29111
29111
  #include <tonemapping_fragment>
29112
29112
  #include <${oHe>=154?"colorspace_fragment":"encodings_fragment"}>
29113
- }`})}},ST=class{constructor(e){this.worldRenderer=e}points;clock=new Ss;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 e5(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 qe(l,3)),a.setAttribute("color",new qe(c,3)),a.setAttribute("size",new qe(u,1));let y=new ET;y.blending=sa,y.depthTest=!1,y.transparent=!0,this.points=new kr(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)}},zpe={id:"starfield",controller:ST,enabledDefault:!0,cannotBeDisabled:!0};var Hpe={starfield:zpe,futuristicReveal:Fpe,rain:Vpe};var ru=class i extends t7{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 m4(this,this.scene,this.material,r),this.cursorBlock=new e4(this),this.holdingBlock=new Ih(this),this.holdingBlockLeft=new Ih(this,!0);for(let s of Object.values(Hpe))this.registerModule(s);this.skyboxRenderer=new c4(this.scene,!1,null),this.skyboxRenderer.init(),this.addDebugOverlay(),this.resetScene(),this.init(),this.soundSystem=new n4(this),this.cameraShake=new r4(this,this.onRender),this.media=new i4(this),this.fireworksLegacy=new o4(this),this.waypoints=new a4(this),this.cinimaticScript=new l4(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 u4(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 Q7(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(){vT(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 Et,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=VS(t.blocksAtlasImage);s.needsUpdate=!0,s.flipY=!1,this.material.map=s;let a=VS(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(dT)}getItemRenderData(t,n){return Mpe(t,n,this.resourcesManager,this.playerStateReactive)}async demoModel(){let t=cursorBlockRel(0,1,0).position,n=await xp();whe(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=Kg("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=$g(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=rhe(n,r,c);if(!u)return;let f=new qt(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 wr(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 wr(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=Nh(this,l,Dh.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]=SS(t);return Object.fromEntries(Object.entries(this.sectionObjects).map(([o,l])=>{let[c,u,f]=o.split(",").map(Number),[v,m,y]=SS({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();C2();var AT={},Gpe=!1;function lHe(){if(Gpe)return AT;Gpe=!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,AT=r,AT}var qr=lHe();C2();var Vhn=qr._makeLong,Uhn=qr.basename,Fhn=qr.delimiter,zhn=qr.dirname,Hhn=qr.extname,qhn=qr.format,Ghn=qr.isAbsolute,MT=qr.join,Whn=qr.normalize,jhn=qr.parse,$hn=qr.posix,Xhn=qr.relative,Yhn=qr.resolve,Jhn=qr.sep,Khn=qr.win32;zt();h();p();d();var Sve=jr(Kpe(),1),Ave=jr(Eve(),1);var Mve=i=>{let e=(0,Sve.default)(i),t=(0,Ave.default)(i),n=new e(i).sync,r=Oqe(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 Oqe(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 Tve={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 CR=()=>({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 Rve="1.21.4";h();p();d();h();p();d();h();p();d();As();var i3=i=>[Math.floor(i.x/16),Math.floor(i.z/16)];var Dqe=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)},s3=class s3 extends A0{static restoreTransferred(e,t){let n=new s3;return t&&t.addEventListener("message",({data:r})=>{r.class===s3.restorerName&&r.type==="event"&&n.emit(r.eventName,...r.args)}),n}};ur(s3,"restorerName","WorldViewWorker");var Qh=s3,i8=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:Qh.restorerName,type:"event",eventName:r,args:s})}}return{__restorer:Qh.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]=i3(t),a=ep(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 Dqe(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]=i3(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]=i3(this.lastPos),[o,l]=i3(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]=i3(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=ep(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 PR=new Date,kve=PR.getMonth()===11&&PR.getDate()>=24&&PR.getDate()<=26,Vqe=["panorama_3.webp","panorama_1.webp","panorama_4.webp","panorama_5.webp","panorama_0.webp","panorama_2.webp"],s8=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=ru;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(MT("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 Vqe)(async()=>{let{texture:l}=Qg(MT("background",kve?"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 Et;if(s.add(r),!kve)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=Rve,t=new Ef;if(t.currentConfig={version:e,noInventoryGui:!0},await t.updateAssetsData?.({}),this.abortController.signal.aborted)return;console.time("load panorama scene");let n=Mve(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 i8(n,2,f);if(this.abortController.signal.aborted||(this.worldRenderer=new this.WorldRendererClass(this.documentRenderer.renderer,this.options,{version:e,worldView:v,inWorldRenderingConfig:Tve,playerStateReactive:dhe().reactive,rendererState:CR().reactive,nonReactiveState:CR().nonReactive,resourcesManager:t}),this.worldRenderer instanceof ru&&(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,E=x.x/window.innerWidth-.5,A=-(x.y/window.innerHeight-.5);_?.stop();let P={x:y+E*w,y:b+A*w};_=new wr(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 Cve=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(()=>(gT(),Ipe));return t(i,e)}}),Uqe=[],a8=(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)}},Pve=()=>{let i,e=null,t=null,n=null,r=null,s=(u,f)=>{Gn?i=tv(u,Uqe,globalThis):i=u,e=new Jg(i,f?.canvas),globalThis.renderer=e.renderer,globalThis.documentRenderer=e,globalThis.threeJsBackend=c,a8("default",c)},a=async()=>{if(!e)throw new Error("Document renderer not initialized");if(!n&&!t){let u={...i};t=new s8(e,u,!!process.env.SINGLE_FILE_BUILD_MODE),globalThis.panoramaRenderer=t,a8("panoramaCreated",t),await t.start(),a8("panoramaReady",t)}},o=async u=>{let v=Gn?tv(u,[Ef,Qh],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 ru(e.renderer,i,v),await n.worldReadyPromise,r=new f6(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,a8("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 Cve(n)}};return{main:{init:s,backend:c},workerProxy(){return JI({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=Cve(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 Fqe=Pve();Fqe.workerProxy();})();
29113
+ }`})}},ST=class{constructor(e){this.worldRenderer=e}points;clock=new Ss;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 e5(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 qe(l,3)),a.setAttribute("color",new qe(c,3)),a.setAttribute("size",new qe(u,1));let y=new ET;y.blending=sa,y.depthTest=!1,y.transparent=!0,this.points=new kr(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)}},zpe={id:"starfield",controller:ST,enabledDefault:!0,cannotBeDisabled:!0};var Hpe={starfield:zpe,futuristicReveal:Fpe,rain:Vpe};var ru=class i extends t7{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 m4(this,this.scene,this.material,r),this.cursorBlock=new e4(this),this.holdingBlock=new Ih(this),this.holdingBlockLeft=new Ih(this,!0);for(let s of Object.values(Hpe))this.registerModule(s);this.skyboxRenderer=new c4(this.scene,!1,null),this.skyboxRenderer.init(),this.addDebugOverlay(),this.resetScene(),this.init(),this.soundSystem=new n4(this),this.cameraShake=new r4(this,this.onRender),this.media=new i4(this),this.fireworksLegacy=new o4(this),this.waypoints=new a4(this),this.cinimaticScript=new l4(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 u4(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 Q7(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(){vT(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 Et,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=VS(t.blocksAtlasImage);s.needsUpdate=!0,s.flipY=!1,this.material.map=s;let a=VS(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(dT)}getItemRenderData(t,n){return Mpe(t,n,this.resourcesManager,this.playerStateReactive)}async demoModel(){let t=cursorBlockRel(0,1,0).position,n=await xp();whe(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=Kg("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=$g(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=rhe(n,r,c);if(!u)return;let f=new qt(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 wr(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 wr(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=Nh(this,l,Dh.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]=SS(t);return Object.fromEntries(Object.entries(this.sectionObjects).map(([o,l])=>{let[c,u,f]=o.split(",").map(Number),[v,m,y]=SS({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();C2();var AT={},Gpe=!1;function lHe(){if(Gpe)return AT;Gpe=!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,AT=r,AT}var qr=lHe();C2();var Vhn=qr._makeLong,Uhn=qr.basename,Fhn=qr.delimiter,zhn=qr.dirname,Hhn=qr.extname,qhn=qr.format,Ghn=qr.isAbsolute,MT=qr.join,Whn=qr.normalize,jhn=qr.parse,$hn=qr.posix,Xhn=qr.relative,Yhn=qr.resolve,Jhn=qr.sep,Khn=qr.win32;zt();h();p();d();var Sve=jr(Kpe(),1),Ave=jr(Eve(),1);var Mve=i=>{let e=(0,Sve.default)(i),t=(0,Ave.default)(i),n=new e(i).sync,r=Oqe(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 Oqe(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 Tve={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 CR=()=>({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 Rve="1.21.4";h();p();d();h();p();d();h();p();d();As();var i3=i=>[Math.floor(i.x/16),Math.floor(i.z/16)];var Dqe=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)},s3=class s3 extends A0{static restoreTransferred(e,t){let n=new s3;return t&&t.addEventListener("message",({data:r})=>{r.class===s3.restorerName&&r.type==="event"&&n.emit(r.eventName,...r.args)}),n}};ur(s3,"restorerName","WorldViewWorker");var Qh=s3,i8=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:Qh.restorerName,type:"event",eventName:r,args:s})}}return{__restorer:Qh.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]=i3(t),a=ep(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 Dqe(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]=i3(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]=i3(this.lastPos),[o,l]=i3(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]=i3(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=ep(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 PR=new Date,kve=PR.getMonth()===11&&PR.getDate()>=24&&PR.getDate()<=26,Vqe=["panorama_3.webp","panorama_1.webp","panorama_4.webp","panorama_5.webp","panorama_0.webp","panorama_2.webp"],s8=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=ru;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(MT("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 Vqe)(async()=>{let{texture:l}=Qg(MT("background",kve?"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 Et;if(s.add(r),!kve)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=Rve,t=new Ef;if(t.currentConfig={version:e,noInventoryGui:!0},await t.updateAssetsData?.({}),this.abortController.signal.aborted)return;console.time("load panorama scene");let n=Mve(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 i8(n,2,f);if(this.abortController.signal.aborted||(this.worldRenderer=new this.WorldRendererClass(this.documentRenderer.renderer,this.options,{version:e,worldView:v,inWorldRenderingConfig:Tve,playerStateReactive:dhe().reactive,rendererState:CR().reactive,nonReactiveState:CR().nonReactive,resourcesManager:t}),this.worldRenderer instanceof ru&&(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,E=x.x/window.innerWidth-.5,A=-(x.y/window.innerHeight-.5);_?.stop();let P={x:y+E*w,y:b+A*w};_=new wr(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 Cve=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(()=>(gT(),Ipe));return t(i,e)}}),Uqe=[],a8=(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)}},Pve=()=>{let i,e=null,t=null,n=null,r=null,s=(u,f)=>{Gn?i=tv(u,Uqe,globalThis):i=u,e=new Jg(i,f?.canvas),globalThis.renderer=e.renderer,globalThis.documentRenderer=e,globalThis.threeJsBackend=c,a8("default",c)},a=async()=>{if(!e)throw new Error("Document renderer not initialized");if(!n&&!t){let u={...i};t=new s8(e,u,!!process.env.SINGLE_FILE_BUILD_MODE),globalThis.panoramaRenderer=t,a8("panoramaCreated",t),await t.start(),a8("panoramaReady",t)}},o=async u=>{let v=Gn?tv(u,[Ef,Qh],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 ru(e.renderer,i,v),await n.worldReadyPromise,r=new f6(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,a8("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()},get left(){return{"Geo Memory":n?.worldBlockGeometry.getEstimatedMemoryUsage().readable??"-"}}}),updateCamera(u,f,v){r?.markCameraUpdate(!u),n?.setFirstPersonCamera(u,f,v)},get soundSystem(){return n?.soundSystem},get backendMethods(){if(n)return Cve(n)}};return{main:{init:s,backend:c},workerProxy(){return JI({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=Cve(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 Fqe=Pve();Fqe.workerProxy();})();
29114
29114
  /*! Bundled license information:
29115
29115
 
29116
29116
  @jspm/core/nodelibs/browser/chunk-DtuTasat.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "minecraft-renderer",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "description": "The most Modular Minecraft world renderer with Three.js WebGL backend",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -119,7 +119,7 @@ export interface GraphicsBackend {
119
119
  updateCamera(pos: Vec3 | null, yaw: number, pitch: number): void
120
120
  soundSystem?: any
121
121
  backendMethods?: any
122
- getDebugOverlay?(): { entitiesString?: string, right?: string }
122
+ getDebugOverlay?(): { entitiesString?: string, left?: Record<string, string>, right?: Record<string, string> }
123
123
  }
124
124
 
125
125
  /** Graphics backend loader function type */
@@ -215,6 +215,11 @@ export const createGraphicsBackendBase = () => {
215
215
  get entitiesString() {
216
216
  return worldRenderer?.entities.getDebugString()
217
217
  },
218
+ get left() {
219
+ return {
220
+ 'Geo Memory': worldRenderer?.worldBlockGeometry.getEstimatedMemoryUsage().readable ?? '-'
221
+ }
222
+ },
218
223
  }),
219
224
  updateCamera(pos: Vec3 | null, yaw: number, pitch: number) {
220
225
  // Mark camera update event for frame timing visualization