minecraft-renderer 0.1.69 → 0.1.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/minecraft-renderer.js +2 -2
- package/dist/minecraft-renderer.js.meta.json +1 -1
- package/dist/threeWorker.js +1 -1
- package/package.json +1 -1
- package/src/graphicsBackend/rendererDefaultOptions.ts +1 -1
- package/src/three/graphicsBackendOffThread.ts +2 -1
- package/src/three/graphicsBackendSingleThread.ts +1 -1
package/dist/threeWorker.js
CHANGED
|
@@ -28829,7 +28829,7 @@ void main() {
|
|
|
28829
28829
|
|
|
28830
28830
|
#include <tonemapping_fragment>
|
|
28831
28831
|
#include <${CGe>=154?"colorspace_fragment":"encodings_fragment"}>
|
|
28832
|
-
}`})}},VT=class{constructor(e){this.worldRenderer=e}points;clock=new Rs;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.set(0,0,0),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,o=new it,a=b=>new K().setFromSpherical(new E5(b,Math.acos(1-Math.random()*2),Math.random()*2*Math.PI)),l=[],c=[],d=Array.from({length:n},()=>(.5+.5*Math.random())*r),u=new Fe,p=e+t,v=t/n;for(let b=0;b<n;b++)p-=v*Math.random(),l.push(...a(p).toArray()),u.setHSL(b/n,s,.9),c.push(u.r,u.g,u.b);o.setAttribute("position",new qe(l,3)),o.setAttribute("color",new qe(c,3)),o.setAttribute("size",new qe(d,1));let _=new DT;_.blending=Pi,_.depthTest=!0,_.depthWrite=!1,_.transparent=!0,this.points=new tr(o,_),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)}},T3e={id:"starfield",controller:VT,enabledDefault:!0,cannotBeDisabled:!0};var I3e={starfield:T3e,futuristicReveal:k3e,rain:A3e,cameraBobbing:x3e,blockBreakParticles:b3e};f();m();h();f();m();h();var UT=()=>({longRenderTime:!1,constantLongRenderTime:!1,tooManyEntities:!1,tooManyTextures:!1,unknownReason:!1});f();m();h();f();m();h();var a2=class{constructor(e){this.factors=e}renderTimeHistory=[];onFrame(e){this.pushRenderTime(e.totalMs),this.recompute(e)}pushRenderTime(e){this.renderTimeHistory.push(e),this.renderTimeHistory.length>24&&this.renderTimeHistory.shift()}recompute(e){let t=e.fps>0&&e.fps<=45,n=Math.max(0,e.totalMs-e.entitiesMs),r=e.totalMs>=30,s=this.renderTimeHistory.length,o=this.renderTimeHistory.filter(p=>p>=30).length,a=s>=8&&o/s>=.65,l=e.loadedTextureCount>=100,c=t&&e.entitiesMs>=8&&n<=20,u=t&&!(r||a||c||l);this.factors.longRenderTime=r,this.factors.constantLongRenderTime=a,this.factors.tooManyEntities=c,this.factors.tooManyTextures=l,this.factors.unknownReason=u}reset(){this.renderTimeHistory.length=0,this.factors.longRenderTime=!1,this.factors.constantLongRenderTime=!1,this.factors.tooManyEntities=!1,this.factors.tooManyTextures=!1,this.factors.unknownReason=!1}};f();m();h();var DGe=[{key:"longRenderTime",code:"LR"},{key:"constantLongRenderTime",code:"CLR"},{key:"tooManyEntities",code:"ENT"},{key:"tooManyTextures",code:"TEX"},{key:"unknownReason",code:"UNK"}];function zT(i){let e=DGe.filter(({key:t})=>i[t]).map(({code:t})=>t);return e.length>0?e.join("+"):""}var _d=class _d extends U7{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.performanceMonitor=new a2(this.reactiveState.world.instabilityFactors),this.renderer=t;let s=_d.getRendererInfo(t)??"...";r.rendererState.renderer=s,this.chunkMeshManager=new o2(this,this.scene,this.material,this.worldSizeParams.worldHeight,this.viewDistance),this.onRenderDistanceChanged=o=>{this.chunkMeshManager.updateViewDistance(o)},this.cursorBlock=new z_(this),this.holdingBlock=t2(this),this.holdingBlockLeft=t2(this,!0);for(let o of Object.values(I3e))this.registerModule(o);this.skyboxRenderer=new J_(this.realScene,!1,null),this.skyboxRenderer.init(),this.addDebugOverlay(),this.resetScene(),this.init(),this.soundSystem=new q_(this),this.cameraShake=new G_(this,this.onRender),this.media=new W_(this),this.fireworksLegacy=new X_(this),this.waypoints=new $_(this),this.cinimaticScript=new Y_(this,(o,a,l)=>this.setCinimaticCamera(o,a,l),o=>this.setCinimaticFov(o),()=>({position:new ut(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z),yaw:this.cameraShake.getBaseRotation().yaw,pitch:this.cameraShake.getBaseRotation().pitch,fov:this.camera.fov})),this.fireworks=new K_(this.realScene,this.sceneOrigin),this.renderUpdateEmitter.on("chunkFinished",o=>{this.finishChunk(o)}),this.worldSwitchActions(),this.initializeModules()}outputFormat="threeJs";isShaderCubeBlocksEnabled(){return this.worldRendererConfig.shaderCubeBlocks===!0&&!!this.renderer?.capabilities?.isWebGL2}chunkMeshManager;get sectionObjects(){return this.chunkMeshManager.sectionObjects}chunkTextures=new Map;signsCache=new Map;cameraSectionPos=new ut(0,0,0);holdingBlock;holdingBlockLeft;scene=new _r;get realScene(){return this.scene}ambientLight=new go(13421772);directionalLight=new ss(16777215,.5);entities=new F_(this,globalThis.mcData);performanceMonitor;cameraGroupVr;material=new st({vertexColors:!0,transparent:!0,alphaTest:.1});itemsTexture;cursorBlock;onRender=[];lastRenderTime=0;animatedFov=0;lastFovAnimTime=0;cameraShake;cameraContainer;media;get waitingChunksToDisplay(){return this.chunkMeshManager.waitingChunksToDisplay}waypoints;cinimaticScript;camera;renderTimeAvg=0;pendingSectionUpdates=new Map;pendingSectionBufferStartTimes=new Map;get estimatedMemoryUsage(){return this.chunkMeshManager.getEstimatedMemoryUsage().total}modules={};sectionsOffsetsAnimations={};fountains=[];fireworksLegacy;DEBUG_RAYCAST=!1;skyboxRenderer;fireworks;sceneOrigin=new Z_(this.scene);cameraWorldPos={x:0,y:0,z:0};_cameraPositionAccessWarned=!1;_tmpCameraPos=new K;currentPosTween;currentRotTween;_tpDirection=new K;_tpPitchQuat=new Vt;_tpYawQuat=new Vt;_tpFinalQuat=new Vt;_tpScenePos=new K;_tpAxisX=new K(1,0,0);_tpAxisY=new K(0,1,0);_tpRaycaster=new _a;_tpChunkWorldPos=new K;get tilesRendered(){return this.chunkMeshManager.getTotalTiles()}get blocksRendered(){return this.chunkMeshManager.getTotalBlocks()}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 o=this.onRender.indexOf(r.controller.render);o>-1&&this.onRender.splice(o,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}_wrapCameraPositionWithWarning(){let t=this.camera.position,n=this,r=20,s=(l,c,d)=>Math.abs(l)>r||Math.abs(c)>r||Math.abs(d)>r,o=()=>{!n._cameraPositionAccessWarned&&typeof process<"u"},a=new Proxy(t,{set(l,c,d){return(c==="x"||c==="y"||c==="z")&&typeof d=="number"&&Math.abs(d)>r&&o(),l[c]=d,!0},get(l,c,d){let u=l[c];return c==="set"?function(p,v,_){return s(p,v,_)&&o(),l.set(p,v,_)}:c==="setX"||c==="setY"||c==="setZ"?function(p){return Math.abs(p)>r&&o(),l[c](p)}:c==="copy"?function(p){return s(p.x,p.y,p.z)&&o(),l.copy(p)}:typeof u=="function"?u.bind(l):u}});Object.defineProperty(this.camera,"position",{value:a,configurable:!0,enumerable:!0})}worldSwitchActions(){this.onWorldSwitched.push(()=>{this.protocolCustomBlocks.clear(),this.sectionsOffsetsAnimations={},this.waypoints.clear(),this.cinimaticScript.stopScript(),this.fireworks.clear()})}downloadWorldGeometry(){MT(this,new K(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z),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.sceneOrigin.update(0,0,0),this.cameraWorldPos.x=0,this.cameraWorldPos.y=0,this.cameraWorldPos.z=0,this.scene.matrixAutoUpdate=!1,this.scene.background=new Fe(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 Yt(75,t.x/t.y,.1,1e3),this._wrapCameraPositionWithWarning(),this.cameraContainer=new At,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 ut(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 ut(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z);this.updateCamera(n,this.cameraShake.getBaseRotation().yaw,this.cameraShake.getBaseRotation().pitch)})}watchReactiveConfig(){super.watchReactiveConfig(),this.onReactiveConfigUpdated("showChunkBorders",n=>{this.updateShowChunksBorder(n)}),this.onReactiveConfigUpdated("defaultSkybox",n=>{this.skyboxRenderer.updateDefaultSkybox(n)}),this.onReactiveConfigUpdated("shaderCubeDebugMode",()=>{this.chunkMeshManager.syncCubeShaderUniforms()}),this.onReactiveConfigUpdated("futuristicReveal",()=>{this.updateModulesFromConfig()});let t=this.displayOptions.inWorldRenderingConfig.handRenderer;this.onReactiveConfigUpdated("handRenderer",n=>{if(n===t)return;t=n;let r=this.holdingBlock.ready,s=this.holdingBlockLeft.ready;this.holdingBlock.dispose(),this.holdingBlockLeft.dispose(),this.holdingBlock=t2(this),this.holdingBlockLeft=t2(this,!0),r&&(this.holdingBlock.ready=!0,this.holdingBlock.updateItem()),s&&(this.holdingBlockLeft.ready=!0,this.holdingBlockLeft.updateItem())}),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 o=r.controller.autoEnableCheck();o&&!r.enabled?this.toggleModule(n,!0):!o&&r.enabled&&!r.manifest.cannotBeDisabled&&this.toggleModule(n,!1)}else{let o=r.manifest.enabledDefault??!1;o&&!r.enabled?this.toggleModule(n,!0):!o&&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=f0(t.blocksAtlasImage);s.needsUpdate=!0,s.flipY=!1,this.material.map=s,this.chunkMeshManager.syncCubeShaderUniforms();let o=f0(t.itemsAtlasImage);o.needsUpdate=!0,o.flipY=!1,this.itemsTexture=o,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.realScene.background=new Fe(t[0],t[1],t[2])}changeCardinalLight(t){this.worldRendererConfig.cardinalLight=t}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(yT)}getItemRenderData(t,n){return G2e(t,n,this.resourcesManager,this.playerStateReactive)}async demoModel(){let t=cursorBlockRel(0,1,0).position,n=await Tp();Ghe(n,t);let r=new yo(n,16776960);n.add(r),this.realScene.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 yo(n,16776960);n.add(r),this.realScene.add(n)}debugOverlayAdded=!1;addDebugOverlay(){if(this.debugOverlayAdded)return;this.debugOverlayAdded=!0;let t=N7("debug-overlay",80,0,void 0,{className:O7});setInterval(()=>{if(t.setVisibility(this.displayAdvancedStats),this.displayAdvancedStats){let n=l=>new Intl.NumberFormat("en-US",{}).format(l),r=l=>new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1}).format(l),s="";s+=`TE: ${n(this.renderer.info.memory.textures)} `,s+=`F: ${r(this.tilesRendered)} `,s+=`B: ${r(this.blocksRendered)} `,s+=`MEM: ${this.chunkMeshManager.getEstimatedMemoryUsage().total} `;let o=this.chunkMeshManager.getStats();s+=`POOL: ${o.activeCount}/${o.poolSize} `;let a=zT(this.reactiveState.world.instabilityFactors);a&&(s+=`PF: ${a} `),t.updateText(s),this.backendInfoReport=s}},200)}updatePosDataChunk(t){let n=this.sectionObjects[t];if(!n)return;let[r,s,o]=t.split(",").map(d=>Math.floor(+d/16)),l=500-(Math.abs(r-this.cameraSectionPos.x)+Math.abs(s-this.cameraSectionPos.y)+Math.abs(o-this.cameraSectionPos.z)),c=n.mesh??n.shaderMesh??n.children.find(d=>d.name==="mesh"||d.name==="shaderMesh");c&&(c.renderOrder=l)}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.chunkMeshManager.finishChunkDisplay(t)}applyPendingSectionUpdates(){if(this.pendingSectionUpdates.size===0)return;let t=performance.now(),n=this.getSectionHeight(),r=[];for(let s of this.pendingSectionUpdates.keys()){let o=this.pendingSectionBufferStartTimes.get(s)??t;if(t-o<_d.MAX_SECTION_UPDATE_BUFFER_MS){let[l,c,d]=s.split(",").map(Number),u=[`${l-16},${c},${d}`,`${l+16},${c},${d}`,`${l},${c-n},${d}`,`${l},${c+n},${d}`,`${l},${c},${d-16}`,`${l},${c},${d+16}`],p=!1;for(let v of u)if(this.sectionsWaiting.has(v)&&!this.pendingSectionUpdates.has(v)&&this.sectionObjects[v]){p=!0;break}if(p)continue}r.push(s)}if(r.length!==0)for(let s of r){let o=this.pendingSectionUpdates.get(s);this.pendingSectionUpdates.delete(s),this.pendingSectionBufferStartTimes.delete(s);let a=o.key.split(","),l=`${a[0]},${a[2]}`;if(!this.loadedChunks[l]||!this.active){this.chunkMeshManager.releaseSection(o.key);continue}if(!this.chunkMeshManager.sectionHasRenderableContent(o.geometry)){this.chunkMeshManager.releaseSection(o.key);continue}this.chunkMeshManager.updateSection(o.key,o.geometry),this.updatePosDataChunk(o.key)}}clearPendingSectionUpdatesForChunk(t,n){for(let r of[...this.pendingSectionUpdates.keys()])r.startsWith(`${t},`)&&r.endsWith(`,${n}`)&&(this.pendingSectionUpdates.delete(r),this.pendingSectionBufferStartTimes.delete(r))}handleWorkerMessage(t){if(t.type==="geometry"){let n=t.key.split(","),r=`${n[0]},${n[2]}`;if(!this.loadedChunks[r]||!this.active){this.pendingSectionUpdates.delete(t.key),this.pendingSectionBufferStartTimes.delete(t.key);return}if(this.sectionObjects[t.key]){this.pendingSectionUpdates.set(t.key,t),this.pendingSectionBufferStartTimes.has(t.key)||this.pendingSectionBufferStartTimes.set(t.key,performance.now());return}if(!this.chunkMeshManager.sectionHasRenderableContent(t.geometry)){this.chunkMeshManager.releaseSection(t.key);return}this.chunkMeshManager.updateSection(t.key,t.geometry),this.updatePosDataChunk(t.key)}}getSignTexture(t,n,r,s=!1){let o=m1(t),a=this.chunkTextures.get(`${o[0]},${o[1]}`);a||(a={},this.chunkTextures.set(`${o[0]},${o[1]}`,a));let l=`${t.x},${t.y},${t.z}`;if(a[l])return a[l];let c=(0,P3e.default)(this.version),d=B7(n,r,c);if(!d)return;let u=new Gt(d);return u.magFilter=Qe,u.minFilter=Qe,u.needsUpdate=!0,a[l]=u,u}getCameraPosition(t){return(t??this._tmpCameraPos).set(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z)}getSectionCameraPosition(){let t=this.getCameraPosition();return new ut(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.updateCameraSectionPos()}getThirdPersonCamera(t,n,r){t??=new K(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z);let s=this.playerStateReactive.perspective==="third_person_back",o=4,a=this._tpDirection.set(0,0,-1),l=this._tpPitchQuat.setFromAxisAngle(this._tpAxisX,r),c=this._tpYawQuat.setFromAxisAngle(this._tpAxisY,n),d=this._tpFinalQuat.multiplyQuaternions(c,l);a.applyQuaternion(d),s&&a.multiplyScalar(-1),this.DEBUG_RAYCAST&&this.debugRaycast(t,a,o);let u=this._tpScenePos.set(this.sceneOrigin.toSceneX(t.x),this.sceneOrigin.toSceneY(t.y),this.sceneOrigin.toSceneZ(t.z)),p=this._tpRaycaster;p.set(u,a),p.far=o;let v=80,_=v*v,b=t.x,y=t.y,g=t.z,w=[];for(let C of Object.values(this.sectionObjects)){if(C.name!=="chunk"||!C.visible||C.worldX===void 0)continue;let L=C.worldX-b,M=C.worldY-y,k=C.worldZ-g;if(L*L+M*M+k*k>_)continue;let F=C.children.find(Z=>Z.name==="mesh"||Z.name==="shaderMesh");F&&w.push(F)}let x=p.intersectObjects(w,!1),E=o;x.length>0&&(E=Math.max(.5,x[0].distance-.2));let A=this.chunkMeshManager.raycastShaderSectionAABBs(t,a,E,v);return A!==void 0&&(E=Math.max(.5,A-.2)),new ut(t.x+a.x*E,t.y+a.y*E,t.z+a.z*E)}debugRaycastHelper;debugHitPoint;debugRaycast(t,n,r){this.debugRaycastHelper&&(this.realScene.remove(this.debugRaycastHelper),this.debugRaycastHelper=void 0),this.debugHitPoint&&(this.realScene.remove(this.debugHitPoint),this.debugHitPoint=void 0);let s=new K(this.sceneOrigin.toSceneX(t.x),this.sceneOrigin.toSceneY(t.y),this.sceneOrigin.toSceneZ(t.z));this.debugRaycastHelper=new bc(n.clone().normalize(),s,r,16711680,r*.1,r*.05),this.realScene.add(this.debugRaycastHelper);let o=new rs(.2,8,8),a=new st({color:65280});this.debugHitPoint=new je(o,a),this.debugHitPoint.position.copy(s).add(n.clone().multiplyScalar(r)),this.realScene.add(this.debugHitPoint)}prevFramePerspective=null;setCinimaticCamera(t,n,r){this.cameraWorldPos.x=t.x,this.cameraWorldPos.y=t.y,this.cameraWorldPos.z=t.z,this.sceneOrigin.update(t.x,t.y,t.z),this.cameraObject.position.set(0,0,0),this.cameraShake.setBaseRotation(r,n),this.updateCameraSectionPos()}setCinimaticFov(t){this.animatedFov=t,this.camera.fov=t,this.camera.updateProjectionMatrix()}updateSmoothFov(){if(this.cinimaticScript.running)return;let t=this.displayOptions.inWorldRenderingConfig.fov,n=this.playerStateReactive.fovMultiplier,r=t*(Number.isFinite(n)?n:1),s=performance.now();if(this.animatedFov===0&&(this.animatedFov=r),Math.abs(this.animatedFov-r)>=.01){let o=s-this.lastFovAnimTime,a=Math.min(o/_d.FOV_TRANSITION_MS,1),l=c=>1-(1-c)**3;this.animatedFov+=(r-this.animatedFov)*l(a),Math.abs(this.animatedFov-r)<.01&&(this.animatedFov=r)}else this.animatedFov=r;this.lastFovAnimTime=s,this.camera.fov!==this.animatedFov&&(this.camera.fov=this.animatedFov,this.camera.updateProjectionMatrix())}updateCamera(t,n,r){if(!this.cinimaticScript.running){if(t){this.renderer.xr.isPresenting&&(t.y-=this.camera.position.y),this.currentPosTween?.stop();let s=this.displayOptions.inWorldRenderingConfig.instantCameraUpdate?0:this.playerStateUtils.isSpectatingEntity()?150:50;this.currentPosTween=new br(this.cameraWorldPos).to({x:t.x,y:t.y,z:t.z},s).onUpdate(()=>{this.sceneOrigin.update(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z),this.cameraObject.position.set(0,0,0)}).start()}if(this.playerStateUtils.isSpectatingEntity()){let s=this.cameraShake.getBaseRotation(),o=0,a=Math.PI/2;s.yaw<a&&n>Math.PI+a?o=-Math.PI*2:n<a&&s.yaw>Math.PI+a&&(o=Math.PI*2),this.currentRotTween?.stop(),this.currentRotTween=new br(s).to({pitch:r,yaw:n+o},100).onUpdate(l=>this.cameraShake.setBaseRotation(l.pitch,l.yaw-o)).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 o=new K(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z),a=this.getThirdPersonCamera(o,n,r),l=o.distanceTo(new K(a.x,a.y,a.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.z=0,this.camera.rotation.set(0,0,0),this.debugRaycastHelper&&(this.realScene.remove(this.debugRaycastHelper),this.debugRaycastHelper=void 0),this.debugHitPoint&&(this.realScene.remove(this.debugHitPoint),this.debugHitPoint=void 0)}this.updateCameraSectionPos()}}debugChunksVisibilityOverride(){let{chunksRenderAboveOverride:t,chunksRenderBelowOverride:n,chunksRenderDistanceOverride:r,chunksRenderAboveEnabled:s,chunksRenderBelowEnabled:o,chunksRenderDistanceEnabled:a}=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[d,u]of Object.entries(this.sectionObjects)){if(u._waitingForChunkDisplay)continue;let[p,v,_]=d.split(",").map(Number),b=s&&t!==void 0?v<=c+t:o&&n!==void 0?v>=c-n:a&&r!==void 0?Math.abs(v-c)<=r:!0;u.visible=b}else this.chunkMeshManager.updateSectionsVisibility()}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),this.updateSmoothFov(),t){let u=this.renderer.getSize(new Ve);this.camera.aspect=u.width/u.height,this.camera.updateProjectionMatrix()}let o=0;if(!this.reactiveDebugParams.disableEntities){let u=performance.now();this.entities.render(),o=performance.now()-u}let a=this.cameraGroupVr instanceof at?this.cameraGroupVr.children.find(u=>u instanceof Yt):this.camera;this.applyPendingSectionUpdates();let l=this.chunkMeshManager.globalBlockBuffer;l&&(l.setCameraOrigin(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z),l.compactStep(),l.uploadDirtyRange()),this.renderer.render(this.scene,a),this.displayOptions.inWorldRenderingConfig.showHand&&this.playerStateReactive.gameMode!=="spectator"&&this.playerStateReactive.perspective==="first_person"&&!this.renderer.xr.isPresenting&&(this.holdingBlock.render(this.camera,this.renderer,this.ambientLight,this.directionalLight),this.holdingBlockLeft.render(this.camera,this.renderer,this.ambientLight,this.directionalLight));for(let 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 d=performance.now()-n;this.worldRendererConfig.autoLowerRenderDistance&&this.chunkMeshManager.recordRenderTime(d),this.renderTimeAvgCount++,this.renderTimeAvg=(this.renderTimeAvg*(this.renderTimeAvgCount-1)+d)/this.renderTimeAvgCount,this.renderTimeMax=Math.max(this.renderTimeMax,d),this.performanceMonitor.onFrame({totalMs:d,entitiesMs:o,loadedTextureCount:this.renderer.info.memory.textures,fps:this.lastFps})}renderHead(t,n,r,s){let o;if(s.SkullOwner?o=s.SkullOwner.Properties?.textures?.[0]?.Value:o=s.profile?.properties?.find(a=>a.name==="textures")?.value,!!o)try{let l=JSON.parse(Buffer.from(o,"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 d=R0(this,l,C0.head),u=new at;return r&&d.position.set(0,.3125,.3125),d.position.y-=23/16,u.add(d),this.sceneOrigin.track(u),u.position.set(t.x+.5,t.y+.045,t.z+.5),u.rotation.set(0,-_t.degToRad(n*(r?90:45/2)),0),u.scale.set(.8,.8,.8),u}catch(a){console.error("Error decoding player texture:",a)}}renderSign(t,n,r,s,o){let a=this.getSignTexture(t,o,s);if(!a)return;let l=new je(new _n(1,1),new st({map:a,transparent:!0}));l.renderOrder=999;let c=7/16,d=s?1.3:1;l.scale.set(1*d,c*d,1*d);let u=(s?2:1.5)/16,p=.25/16;r&&!s?l.position.set(0,0,-.5+u+p+1e-4):l.position.set(0,0,u/2+1e-4);let v=new at;v.rotation.set(0,-_t.degToRad(n*(r?90:45/2)),0),v.add(l);let _=(s?10:8)/16,b=(s?0:r?4.333:9.333)/16,y=_/2+b;return this.sceneOrigin.track(v),v.position.set(t.x+.5,t.y+y,t.z+.5),v}lightUpdate(t,n){for(let r=this.worldSizeParams.minY;r<this.worldSizeParams.worldHeight;r+=16)this.setSectionDirty(new ut(t,r,n))}rerenderAllChunks(){for(let t of Object.keys(this.sectionObjects)){let[n,r,s]=t.split(",").map(Number);this.setSectionDirty(new ut(n,r,s))}}updateShowChunksBorder(t){this.chunkMeshManager.updateAllBoxHelpers(t)}resetWorld(){super.resetWorld(),this.pendingSectionUpdates.clear(),this.pendingSectionBufferStartTimes.clear(),this.chunkMeshManager.dispose(),this.chunkMeshManager=new o2(this,this.scene,this.material,this.worldSizeParams.worldHeight,this.viewDistance),this.debugRaycastHelper&&(this.realScene.remove(this.debugRaycastHelper),this.debugRaycastHelper=void 0),this.debugHitPoint&&(this.realScene.remove(this.debugHitPoint),this.debugHitPoint=void 0)}getLoadedChunksRelative(t,n=!1){let[r,s,o]=PA(t);return Object.fromEntries(Object.entries(this.sectionObjects).map(([a,l])=>{let[c,d,u]=a.split(",").map(Number),[p,v,_]=PA({x:c,y:d,z:u});return[n?`${p-r},${v-s},${_-o}`:`${p-r},${_-o}`,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];this.chunkMeshManager.cleanSignChunkTextures(t,n)}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.clearPendingSectionUpdatesForChunk(t,n);let r=this.getSectionHeight(),s=this.worldMinYRender;for(let o=s;o<this.worldSizeParams.worldHeight;o+=r){let a=`${t},${o},${n}`;this.chunkMeshManager.sectionObjects[a]&&this.chunkMeshManager.releaseSection(a)}this.chunkMeshManager.onChunkRemovedFromGate(`${t},${n}`)}updateViewerPosition(t){super.updateViewerPosition(t),this.chunkMeshManager.pendingNearReveal.size>0&&this.chunkMeshManager.tryRevealPending()}onViewerChunkPositionChanged(){this.chunkMeshManager.tryRevealPending()}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.performanceMonitor?.reset(),this.pendingSectionUpdates.clear(),this.pendingSectionBufferStartTimes.clear(),this.chunkMeshManager.dispose(),this.disposeModules(),this.fireworksLegacy.destroy(),super.destroy(),this.skyboxRenderer.dispose(),this.fireworks.dispose()}shouldObjectVisible(t){let r=this.getSectionHeight(),s,o,a,l=this.sceneOrigin.getWorldPosition(t);l?(s=l.x,o=l.y,a=l.z):(s=this.sceneOrigin.toWorldX(t.position.x),o=this.sceneOrigin.toWorldY(t.position.y),a=this.sceneOrigin.toWorldZ(t.position.z));let c=Math.floor(s/16)*16,d=Math.floor(a/16)*16,u=Math.floor(o/r)*r,p=`${c},${d}`,v=`${c},${u},${d}`;return!!this.finishedChunks[p]||!!this.sectionObjects[v]}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 o=this.sectionObjects[n];o&&(o.position.set(r.currentOffsetX,r.currentOffsetY,r.currentOffsetZ),o.updateMatrix())}}reloadWorld(){this.entities.reloadEntities()}};Cn(_d,"FOV_TRANSITION_MS",200),Cn(_d,"MAX_SECTION_UPDATE_BUFFER_MS",500);var yd=_d;f();m();h();f();m();h();var l2="1.21.4";f();m();h();function bd(i,e){i.aspect=e.width/e.height,i.updateProjectionMatrix()}f();m();h();f();m();h();var nl={mode:"v2",minecraftTextures:!0,v2Scene:"light",v2Camera:"dive",v2BlockGroup:"stainedGlass",v2CameraSpeedPercent:80,v2BlockSpeedPercent:40},HT=i=>i/100,h4={camera:HT(nl.v2CameraSpeedPercent),block:HT(nl.v2BlockSpeedPercent)};function qT(i,e=!1){return i?.mode?i.mode:e?"worldBlocks":nl.mode}f();m();h();yt();f();m();h();var GT={};function WT(...i){let e=i.filter(n=>n.length>0).join("/"),t=typeof globalThis.location<"u"&&globalThis.location.href?globalThis.location.href:typeof GT<"u"&>.url?GT.url:`/${e}`;try{return new URL(e,t).href}catch{return`/${e}`}}var jT=new Date,L3e=jT.getMonth()===11&&jT.getDate()>=24&&jT.getDate()<=26,VGe=["panorama_3.webp","panorama_1.webp","panorama_4.webp","panorama_5.webp","panorama_0.webp","panorama_2.webp"],UGe=200,c2=class{constructor(e){this.documentRenderer=e;this.scene=new _r,this.scene.background=new Fe(3294568);let t=new go(13421772);this.scene.add(t);let n=new ss(16777215,.5);n.position.set(1,1,.5).normalize(),n.castShadow=!0,this.scene.add(n),this.camera=new Yt(85,e.canvas.width/e.canvas.height,.05,1e3),this.camera.position.set(0,0,0),this.camera.rotation.set(0,0,0)}scene;camera;startTimes=new Map;time=0;panoramaGroup=null;async init(){this.buildCubemap()}update(e,t){t&&bd(this.camera,this.documentRenderer.canvas)}dispose(){this.scene.clear(),this.panoramaGroup=null,this.startTimes.clear()}buildCubemap(){let e=new nn(1e3,1e3,1e3),t=[];for(let s of VGe)(async()=>{let a=WT("background",L3e?"christmas":"",s),l=await $c(a),c=f0(l);c.matrixAutoUpdate=!1,c.matrix.set(-1,0,1,0,1,0,0,0,1),c.wrapS=gn,c.wrapT=gn,c.minFilter=jt,c.magFilter=jt;let d=new st({map:c,transparent:!0,side:cn,depthWrite:!1,opacity:0});this.startTimes.set(d,Date.now()),t.push(d)})().catch(a=>{console.warn("[ClassicMenuBackground] Failed to load panorama face:",s,a)});let n=new je(e,t);n.onBeforeRender=()=>{this.time+=.01,n.rotation.y=Math.PI+this.time*.01,n.rotation.z=Math.sin(-this.time*.001)*.001;for(let s of t){let o=this.startTimes.get(s);if(o){let a=Date.now()-o;s.opacity=Math.min(1,a/UGe)}}};let r=new At;if(r.add(n),!L3e)for(let s=0;s<20;s++){let o=new tl("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 a=Math.random()*.01;o.children[0].onBeforeRender=()=>{o.rotation.y+=a,o.rotation.z=Math.cos(n.rotation.y*3)*Math.PI/4-Math.PI/2},r.add(o)}this.scene.add(r),this.panoramaGroup=r}async debugImageInFrontOfCamera(){let e=await $c(WT("background","panorama_0.webp")),t=f0(e),n=new je(new _n(1e3,1e3),new st({map:t}));n.position.set(0,0,-500),this.scene.add(n)}};f();m();h();yt();f();m();h();var ih=["galaxy","nether","end","cyber","light"],sh=["cruise","barrel","dive","orbit","snake"],m4={galaxy:"Galaxy",nether:"Nether",end:"The End",cyber:"Cyber",light:"Light Space"},p4={cruise:"Cruise",barrel:"Barrel",dive:"Dive",orbit:"Orbit",snake:"Snake"},oh=["mixed","stainedGlass","wool","construction","glow","world"],v4={mixed:"Mixed",stainedGlass:"Stained glass",wool:"Wool",construction:"Construction",glow:"Glow",world:"World (grass & ores)"};var B3e=.1,D3e={mixed:["white_wool","cyan_wool","blue_wool","purple_wool","white_stained_glass","cyan_stained_glass","blue_stained_glass","purple_stained_glass","glowstone","sea_lantern","amethyst_block","copper_block","gold_block","diamond_block"],stainedGlass:["white_stained_glass","orange_stained_glass","magenta_stained_glass","light_blue_stained_glass","yellow_stained_glass","lime_stained_glass","pink_stained_glass","gray_stained_glass","light_gray_stained_glass","cyan_stained_glass","purple_stained_glass","blue_stained_glass","brown_stained_glass","green_stained_glass","red_stained_glass","black_stained_glass"],wool:["white_wool","orange_wool","magenta_wool","light_blue_wool","yellow_wool","lime_wool","pink_wool","gray_wool","light_gray_wool","cyan_wool","purple_wool","blue_wool","brown_wool","green_wool","red_wool","black_wool"],construction:["copper_block","exposed_copper","weathered_copper","oxidized_copper","cut_copper","exposed_cut_copper","weathered_cut_copper","oxidized_cut_copper","iron_block","gold_block","diamond_block","emerald_block","netherite_block","lapis_block","redstone_block","coal_block","quartz_block","amethyst_block","bricks","stone_bricks","deepslate_bricks","polished_blackstone"],glow:["glowstone","sea_lantern","shroomlight","ochre_froglight","verdant_froglight","pearlescent_froglight","redstone_lamp","beacon"],world:["grass_block","podzol","mycelium","dirt","coarse_dirt","rooted_dirt","mud","clay","stone","cobblestone","mossy_cobblestone","deepslate","cobbled_deepslate","tuff","calcite","sand","red_sand","gravel","snow_block","coal_ore","deepslate_coal_ore","iron_ore","deepslate_iron_ore","copper_ore","deepslate_copper_ore","gold_ore","deepslate_gold_ore","diamond_ore","deepslate_diamond_ore","emerald_ore","deepslate_emerald_ore","lapis_ore","deepslate_lapis_ore","redstone_ore","deepslate_redstone_ore","nether_gold_ore","ancient_debris","oak_log","birch_log","spruce_log","jungle_log","acacia_log","dark_oak_log","mangrove_log","cherry_log","netherrack","soul_sand","basalt","end_stone"]},O3e={galaxy:{bg:132114,fog:132114,fogD:.011,blocks:[61695,54527,47359,59647,2280703,43263],emit:[13158,8789,6724],nebula:[4403,1114146,4386],galFn:i=>new Fe(i*.05,i*.2,i),ambient:264216,dir:3368703,pt1:43775,pt2:16729343,name:"GALAXY"},nether:{bg:917760,fog:917760,fogD:.016,blocks:[16720384,16737792,16750848,13373696,16729122,16755200],emit:[2230272,1114112,3346688],nebula:[1704960,851968,1705984],galFn:i=>new Fe(i,i*.15,0),ambient:1573376,dir:16724736,pt1:16729088,pt2:16755200,name:"NETHER"},end:{bg:0,fog:0,fogD:.009,blocks:[7807658,11158732,5570679,14527231,3342421,12299007],emit:[655381,1572901,327696],nebula:[524312,851989,262158],galFn:i=>new Fe(i*.4,0,i),ambient:393232,dir:10040319,pt1:11158783,pt2:4456618,name:"THE END"},cyber:{bg:792610,fog:792610,fogD:.008,blocks:[65535,4521932,11206468,6741503,8978278,65450],emit:[666163,668450,665656],nebula:[1192e3,1587240,1323588],galFn:i=>new Fe(i*.15,i*.85,i*.95),ambient:1716288,dir:6750156,pt1:4521966,pt2:10092356,name:"CYBER",starColor:13431039,starOpacity:.75,galaxyOpacity:.62,nebulaOpacity:.36,edgeLineColor:4521949,blockOpacity:[.38,.54]},light:{bg:8951984,fog:7899296,fogD:.006,gradientBg:{top:14214392,mid:10531016,bottom:6846608,radial:!0},blocks:[15266559,13691135,12114175,10537208,8960240,7383272,10012927,12640511,15792383,7909608,14216447,14739711],emit:[6854864,8958176,11061488,12638456],nebula:[9480392,11059424,12637420,14215416,7901360],galFn:i=>{let e=new Fe;return i<.4?e.lerpColors(new Fe(16054527),new Fe(14215423),i/.4):i<.75?e.lerpColors(new Fe(14215423),new Fe(11061488),(i-.4)/.35):e.lerpColors(new Fe(11061488),new Fe(9482464),(i-.75)/.25),e},ambient:7899296,dir:13688040,pt1:11061503,pt2:13162751,name:"LIGHT",starColor:15266047,starOpacity:.5,galaxyOpacity:.7,nebulaOpacity:.32,edgeLineColor:10010856,blockOpacity:[.42,.56]}},FGe={cruise:{pos:(i,e,t)=>({x:Math.sin(i*.28)*18+Math.cos(i*.11)*7+e*10,y:Math.sin(i*.19)*6+Math.cos(i*.31)*3+t*6,z:0}),look:(i,e,t)=>({x:Math.sin((i+.18)*.28)*18+e*8,y:Math.sin((i+.18)*.19)*6+t*4,z:-25}),roll:(i,e=0)=>e*.05+Math.sin(i*.22)*.015,spd:.18},barrel:{pos:(i,e,t)=>{let r=i*2.4;return{x:Math.cos(r)*10+e*4,y:Math.sin(r)*10+t*4,z:Math.sin(i*.4)*8}},look:i=>({x:Math.sin(i*.5)*5,y:Math.cos(i*.5)*5,z:-30}),roll:i=>i*2.4+Math.PI*.5,spd:.24},dive:{pos:(i,e,t)=>({x:Math.sin(i*.6)*30+e*8,y:Math.cos(i*.4)*18+t*6,z:Math.sin(i*.3)*12}),look:(i,e,t)=>({x:Math.sin(i*.6+.2)*30+e*6,y:Math.cos(i*.4+.2)*18-8+t*4,z:-35}),roll:(i,e=0)=>e*.08+Math.sin(i*.6)*.12,spd:.3},orbit:{pos:(i,e,t)=>({x:Math.cos(i*.5)*20+e*5,y:Math.sin(i*.25)*10+t*5,z:Math.sin(i*.5)*20}),look:()=>({x:0,y:0,z:-60}),roll:i=>Math.sin(i*.5)*.08,spd:.15},snake:{pos:(i,e,t)=>({x:Math.sin(i*1.1)*22+Math.sin(i*.37)*8+e*10,y:Math.sin(i*.7)*10+e*4+t*8,z:0}),look:(i,e,t)=>{let n=i+.12;return{x:Math.sin(n*1.1)*22+Math.sin(n*.37)*8+e*8,y:Math.sin(n*.7)*10+t*6,z:-22}},roll:(i,e=0)=>e*.1+Math.sin(i*1.1)*.06,spd:.22}},zGe={cruise:1,barrel:1.6,dive:2.2,orbit:.7,snake:1.4},HGe=250,g4=1e4,_4=3e3,ah=i=>i[Math.floor(Math.random()*i.length)],$T=i=>"#"+i.toString(16).padStart(6,"0"),N3e=i=>{if(typeof document>"u")return null;let e=document.createElement("canvas");e.width=4,e.height=512;let t=e.getContext("2d");if(!t)return null;let n=e.width,r=e.height,s=i.radial?t.createRadialGradient(n/2,r*.32,0,n/2,r*.32,r*.85):t.createLinearGradient(0,0,0,r);s.addColorStop(0,$T(i.top)),i.mid!=null&&s.addColorStop(.45,$T(i.mid)),s.addColorStop(1,$T(i.bottom)),t.fillStyle=s,t.fillRect(0,0,n,r);let o=new mn(e);return o.needsUpdate=!0,o},lh=class{constructor(e,t={},n){this.documentRenderer=e;this.abortSignal=n;let r=nl;this.curScene=t.initialScene??r.v2Scene,this.curCam=t.initialCamera??r.v2Camera,this.blockGroup=t.initialBlockGroup??r.v2BlockGroup,this.cameraSpeed=t.initialCameraSpeed??h4.camera,this.blockSpeed=t.initialBlockSpeed??h4.block,this.useMinecraftTextures=t.useMinecraftTextures??r.minecraftTextures,this.resourcesManager=t.resourcesManager;let s=O3e[this.curScene];this.scene=new _r,this.scene.fog=new oa(s.fog,s.fogD),this.applyScenePalette(s),this.camera=new Yt(80,this.documentRenderer.canvas.width/this.documentRenderer.canvas.height,.1,700),this.ambient=new go(s.ambient,2.5),this.scene.add(this.ambient),this.dir=new ss(s.dir,4),this.dir.position.set(1,1,0),this.scene.add(this.dir),this.pt1=new va(s.pt1,5,100),this.scene.add(this.pt1),this.pt2=new va(s.pt2,4,80),this.pt2.position.set(30,20,-30),this.scene.add(this.pt2);for(let p=0;p<HGe;p++)this.spawnBlock(s,!0);if(!this.useMinecraftTextures){let p=s.edgeLineColor??62975;for(let v=0;v<40;v++){let _=new fn({color:p,transparent:!0,opacity:.25});ah(this.blocks).mesh.add(new Ln(this.eGeo,_))}}this.scene.add(this.bGroup);let o=new it,a=new Float32Array(5e3*3);for(let p=0;p<5e3*3;p++)a[p]=(Math.random()-.5)*500;o.setAttribute("position",new ht(a,3)),this.stars=new tr(o,new Lr({color:s.starColor??16777215,size:.3,transparent:!0,opacity:s.starOpacity??.7,sizeAttenuation:!0})),this.scene.add(this.stars),this.galGeo=new it;let l=new Float32Array(g4*3),c=new Float32Array(g4*3);for(let p=0;p<g4;p++){let v=p%3,_=Math.random(),b=v/3*Math.PI*2+_*Math.PI*5,y=_*90+Math.random()*10,g=(1-_)*18;l[p*3]=Math.cos(b)*y+(Math.random()-.5)*g,l[p*3+1]=(Math.random()-.5)*7,l[p*3+2]=Math.sin(b)*y+(Math.random()-.5)*g-180;let w=.2+_*.8,x=s.galFn(w);c[p*3]=x.r,c[p*3+1]=x.g,c[p*3+2]=x.b}this.galGeo.setAttribute("position",new ht(l,3)),this.galGeo.setAttribute("color",new ht(c,3)),this.galaxy=new tr(this.galGeo,new Lr({size:.9,vertexColors:!0,transparent:!0,opacity:s.galaxyOpacity??.55,sizeAttenuation:!0})),this.scene.add(this.galaxy),this.nebGeo=new it;let d=new Float32Array(_4*3),u=new Float32Array(_4*3);for(let p=0;p<_4;p++){let v=25+Math.random()*110,_=Math.random()*Math.PI*2,b=(Math.random()-.5)*Math.PI*.5;d[p*3]=v*Math.cos(_)*Math.cos(b),d[p*3+1]=v*Math.sin(b)*.6,d[p*3+2]=v*Math.sin(_)*Math.cos(b)-80;let y=new Fe(ah(s.nebula));u[p*3]=y.r,u[p*3+1]=y.g,u[p*3+2]=y.b}this.nebGeo.setAttribute("position",new ht(d,3)),this.nebGeo.setAttribute("color",new ht(u,3)),this.nebula=new tr(this.nebGeo,new Lr({size:3,vertexColors:!0,transparent:!0,opacity:s.nebulaOpacity??.3,sizeAttenuation:!0})),this.scene.add(this.nebula),this.addBackgroundTextPlane(),this.setupMouseTracking()}scene;camera;ambient;dir;pt1;pt2;blocks=[];bGroup=new at;galaxy;nebula;stars;galGeo;nebGeo;bGeo=new nn(1,1,1);eGeo=new Cl(this.bGeo);curScene;curCam;blockGroup;cameraSpeed;blockSpeed;camT=0;mx=0;my=0;tmx=0;tmy=0;transitioning=!1;useMinecraftTextures=!1;resourcesManager;atlasTexture=null;blockMaterialPool=new Map;gradientSky=null;gradientSkyTexture=null;disposed=!1;animTime=0;texturesApplied=!1;textureLoadInProgress=!1;onAssetsTexturesUpdated;async init(){this.useMinecraftTextures&&this.scheduleMinecraftTextureLoad()}scheduleMinecraftTextureLoad(){!this.useMinecraftTextures||this.disposed||this.texturesApplied||this.textureLoadInProgress||this.tryApplyMinecraftTextures()}attachAssetsListener(){let e=this.resourcesManager;!e||this.onAssetsTexturesUpdated||(this.onAssetsTexturesUpdated=()=>this.scheduleMinecraftTextureLoad(),e.on("assetsTexturesUpdated",this.onAssetsTexturesUpdated))}detachAssetsListener(){let e=this.resourcesManager;!e||!this.onAssetsTexturesUpdated||(e.off("assetsTexturesUpdated",this.onAssetsTexturesUpdated),this.onAssetsTexturesUpdated=void 0)}hasBlockAtlas(e){let t=e.currentResources;return!!(t?.blocksAtlasImage&&t.blocksAtlasJson)}async ensureAtlasReady(e){if(await this.ensureMcDataLoaded(),this.hasBlockAtlas(e))return!0;if(typeof document>"u"&&e!==this.resourcesManager)return!1;e.currentConfig={...e.currentConfig,version:l2,noInventoryGui:!0};try{await e.updateAssetsData?.({})}catch{return!1}return this.hasBlockAtlas(e)}async tryApplyMinecraftTextures(){if(!(this.disposed||!this.useMinecraftTextures||this.texturesApplied)){this.textureLoadInProgress=!0;try{let e=this.resourcesManager??new Ql;if(!await this.ensureAtlasReady(e)){this.resourcesManager&&this.attachAssetsListener();return}if(this.disposed)return;this.applyMinecraftTexturesFromAtlas(e),this.texturesApplied=!0,this.detachAssetsListener()}catch(e){console.warn("[V2MenuBackground] Failed to load Minecraft textures, using solid colors:",e),this.useMinecraftTextures=!1,this.detachAssetsListener()}finally{this.textureLoadInProgress=!1}}}applyScenePalette(e){if(this.documentRenderer.renderer.setClearColor(e.bg),e.gradientBg)if(this.scene.background=null,this.gradientSky){if(this.gradientSky.visible=!0,this.gradientSkyTexture&&e.gradientBg){let s=N3e(e.gradientBg);s&&(this.gradientSkyTexture.dispose(),this.gradientSkyTexture=s,this.gradientSky.material.map=s,this.gradientSky.material.needsUpdate=!0)}}else{let s=N3e(e.gradientBg);s?(this.gradientSkyTexture=s,this.gradientSky=new je(new _n(900,700),new st({map:s,depthWrite:!1,side:cn})),this.gradientSky.position.set(0,0,-280),this.gradientSky.renderOrder=-1e3,this.scene.add(this.gradientSky)):this.scene.background=new Fe(e.bg)}else this.scene.background=new Fe(e.bg),this.gradientSky&&(this.gradientSky.visible=!1);this.scene.fog instanceof oa&&(this.scene.fog.color.set(e.fog),this.scene.fog.density=e.fogD);let t=this.stars?.material;t&&(t.color.set(e.starColor??16777215),t.opacity=e.starOpacity??.7);let n=this.galaxy?.material;n&&(n.opacity=e.galaxyOpacity??.55);let r=this.nebula?.material;r&&(r.opacity=e.nebulaOpacity??.3)}setupMouseTracking(){let e=n=>{let r=typeof window<"u"?window.innerWidth:this.documentRenderer.canvas.width,s=typeof window<"u"?window.innerHeight:this.documentRenderer.canvas.height;this.tmx=(n.clientX/r-.5)*2,this.tmy=-(n.clientY/s-.5)*2};(typeof document<"u"?document:void 0)?.addEventListener("mousemove",e,{signal:this.abortSignal})}addBackgroundTextPlane(){let n=typeof document<"u"?document.createElement("canvas"):null;if(!n)return;n.width=2048,n.height=768;let r=n.getContext("2d");if(!r)return;r.clearRect(0,0,2048,768),r.save(),r.font="bold 560px Orbitron, sans-serif",r.textAlign="center",r.textBaseline="middle",r.shadowColor="rgba(0,200,255,0.35)",r.shadowBlur=80,r.fillStyle="rgba(255,255,255,0.055)",r.fillText("V2",2048*.28,768*.5),r.restore(),r.save(),r.font="bold 148px Orbitron, sans-serif",r.textAlign="center",r.textBaseline="middle",r.shadowColor="rgba(0,200,255,0.2)",r.shadowBlur=40,r.fillStyle="rgba(255,255,255,0.038)",r.fillText("by ZARDOY",2048*.72,768*.52),r.restore();let s=new mn(n),o=new je(new _n(280,105),new st({map:s,transparent:!0,opacity:1,depthWrite:!1,side:cn,blending:Pi}));o.position.set(8,4,-320),this.scene.add(o)}spawnBlock(e,t,n){let r=this.createBlockMaterial(e,n),s=new je(this.bGeo,r),o=.3+Math.random()*3;s.scale.setScalar(o),s.position.set((Math.random()-.5)*140,(Math.random()-.5)*70,t?-(Math.random()*140):-155-Math.random()*30),s.rotation.set(Math.random()*Math.PI*2,Math.random()*Math.PI*2,Math.random()*Math.PI*2);let a={mesh:s,spd:.04+Math.random()*.12,dx:(Math.random()-.5)*.012,dy:(Math.random()-.5)*.008,rx:(Math.random()-.5)*.012,ry:(Math.random()-.5)*.012,rz:(Math.random()-.5)*.01,minecraftBlockName:n};this.blocks.push(a),this.bGroup.add(s)}createBlockMaterial(e,t){if(this.useMinecraftTextures&&t){let s=this.blockMaterialPool.get(t);if(s)return s.clone()}let[n,r]=e.blockOpacity??[.32,.46];return new st({color:ah(e.blocks),transparent:!0,opacity:n+Math.random()*(r-n),depthWrite:!1,blending:Pi})}removeBlockEdgeLines(){for(let e of this.blocks){let t=e.mesh.children.filter(n=>n instanceof Ln);for(let n of t){e.mesh.remove(n),n.geometry?.dispose();let r=n.material;Array.isArray(r)?r.forEach(s=>s.dispose()):r.dispose()}}}async ensureMcDataLoaded(){let e=globalThis._LOAD_MC_DATA;e&&await e()}resolveBlockAtlasUv(e,t,n){let r=s=>{let o=t[s];return o?{u:o.u,v:o.v,su:o.su??n.suSv,sv:o.sv??n.suSv}:null};if(t[e])return r(e);for(let s of["_top","_side","_front","_0"]){let o=r(`${e}${s}`);if(o)return o}for(let s of Object.keys(t))if(s.startsWith(e))return r(s);return null}applyMinecraftTexturesFromAtlas(e){let t=e.currentResources;if(!t?.blocksAtlasImage||!t.blocksAtlasJson)throw new Error("Block atlas not available");let n=t.blocksAtlasJson,r=n.textures;this.atlasTexture=f0(t.blocksAtlasImage),this.atlasTexture.flipY=!1,this.atlasTexture.needsUpdate=!0;for(let s of D3e[this.blockGroup]){let o=this.resolveBlockAtlasUv(s,r,n);if(!o)continue;let a=this.atlasTexture.clone();a.flipY=!1,a.offset.set(o.u,o.v),a.repeat.set(o.su,o.sv),a.needsUpdate=!0;let l=s.includes("glass"),c=new st({map:a,side:cn,transparent:l,opacity:l?.85:1,alphaTest:l?.08:0,depthWrite:!0,toneMapped:!1});this.blockMaterialPool.set(s,c)}if(this.blockMaterialPool.size===0)throw new Error("No block textures resolved from atlas (check block names vs atlas keys)");this.removeBlockEdgeLines();for(let s of this.blocks){let o=ah([...this.blockMaterialPool.keys()]);s.minecraftBlockName=o,s.mesh.material=this.blockMaterialPool.get(o).clone()}}setScene(e){if(!ih.includes(e)||e===this.curScene||this.transitioning)return;this.transitioning=!0,this.curScene=e;let t=O3e[e];setTimeout(()=>{if(this.disposed)return;this.applyScenePalette(t),this.ambient.color.set(t.ambient),this.dir.color.set(t.dir),this.pt1.color.set(t.pt1),this.pt2.color.set(t.pt2);for(let s of this.blocks)this.useMinecraftTextures&&s.minecraftBlockName||s.mesh.material instanceof st&&s.mesh.material.color.set(ah(t.blocks));let n=this.nebGeo.attributes.color;for(let s=0;s<_4;s++){let o=new Fe(ah(t.nebula));n.setXYZ(s,o.r,o.g,o.b)}n.needsUpdate=!0;let r=this.galGeo.attributes.color;for(let s=0;s<g4;s++){let o=.2+Math.random()*.8,a=t.galFn(o);r.setXYZ(s,a.r,a.g,a.b)}r.needsUpdate=!0,this.transitioning=!1},150)}setCamera(e){sh.includes(e)&&(this.curCam=e)}setCameraSpeed(e){this.cameraSpeed=Math.max(0,e)}setBlockSpeed(e){this.blockSpeed=Math.max(0,e)}async setBlockGroup(e){if(oh.includes(e)&&e!==this.blockGroup&&(this.blockGroup=e,!(!this.useMinecraftTextures||this.disposed))){for(let t of this.blockMaterialPool.values())t.map?.dispose(),t.dispose();this.blockMaterialPool.clear(),this.texturesApplied=!1,this.scheduleMinecraftTextureLoad()}}getSceneId(){return this.curScene}getCameraId(){return this.curCam}getBlockGroupId(){return this.blockGroup}update(e,t){t&&bd(this.camera,this.documentRenderer.canvas);let n=FGe[this.curCam],r=this.cameraSpeed,s=this.blockSpeed;this.camT+=e*n.spd*r,this.mx+=(this.tmx-this.mx)*.05,this.my+=(this.tmy-this.my)*.05;let o=this.mx*B3e,a=this.my*B3e,l=n.pos(this.camT,o,a),c=n.look(this.camT,o,a);this.camera.position.set(l.x,l.y,l.z),this.camera.lookAt(c.x,c.y,c.z),this.camera.rotation.z=n.roll(this.camT,o);let d=zGe[this.curCam]*s;this.animTime+=e*1e3*s;for(let u of this.blocks){if(u.mesh.position.z+=u.spd*d*60*e,u.mesh.position.x+=u.dx*60*e*s,u.mesh.position.y+=u.dy*60*e*s,u.mesh.rotation.x+=u.rx*d,u.mesh.rotation.y+=u.ry*d,u.mesh.rotation.z+=u.rz,!this.useMinecraftTextures&&u.mesh.material instanceof st){let p=u.mesh.userData.baseOpacity??.38;u.mesh.userData.baseOpacity==null&&(u.mesh.userData.baseOpacity=p);let v=.88+Math.abs(Math.sin(this.animTime*8e-4+u.mesh.position.x*.3))*.12;u.mesh.material.opacity=p*v}u.mesh.position.z>this.camera.position.z+15&&u.mesh.position.set((Math.random()-.5)*140,(Math.random()-.5)*70,this.camera.position.z-155-Math.random()*30)}this.pt1.position.set(Math.sin(this.camT*.8)*25+this.camera.position.x,Math.cos(this.camT*.6)*12+this.camera.position.y,this.camera.position.z-18),this.pt2.position.set(Math.cos(this.camT*.5)*20+this.camera.position.x,Math.sin(this.camT*.9)*15+this.camera.position.y,this.camera.position.z-30),this.galaxy.rotation.y+=e*.006*s,this.nebula.rotation.y-=e*.003*s,this.stars.rotation.y+=e*4e-4*s}dispose(){this.disposed=!0,this.detachAssetsListener(),this.scene.clear(),this.bGeo.dispose(),this.eGeo.dispose(),this.galGeo.dispose(),this.nebGeo.dispose(),this.gradientSkyTexture?.dispose(),this.atlasTexture?.dispose();for(let e of this.blockMaterialPool.values())e.map?.dispose(),e.dispose();this.blockMaterialPool.clear()}};f();m();h();yt();f();m();h();var gge=Jr(G3e(),1),_ge=Jr(vge(),1);var yge=i=>{let e=(0,gge.default)(i),t=(0,_ge.default)(i),n=new e(i).sync,r=vje(n);for(let s of r)if(s.startsWith("set")&&s!=="setColumn"){let o=n[s].bind(n);n[s]=(...a)=>{let l=a[0];l.x!==void 0&&!n.getColumnAt(l)&&n.setColumn(Math.floor(l.x/16),Math.floor(l.z/16),new t(void 0)),o(...a)}}return n};function vje(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]}f();m();h();var bge={paused:!1,showChunkBorders:!1,enableDebugOverlay:!1,debugWasmPerf:!1,debugModelVariant:void 0,futuristicReveal:!1,wasmMesher:!0,shaderCubeBlocks:!1,shaderCubeDebugMode:0,mesherWorkers:1,addChunksBatchWaitTime:200,_experimentalSmoothChunkLoading:!0,_renderByChunks:!1,autoLowerRenderDistance:!1,disableMesherConversionCache:!1,dedicatedChangeWorker:!1,shadingTheme:"high-contrast",cardinalLight:"default",dayCycle:!0,smoothLighting:!0,enableLighting:!0,starfield:!0,defaultSkybox:!0,renderEntities:!0,extraBlockRenderers:!0,foreground:!0,fov:75,volume:1,showHand:!1,viewBobbing:!1,handRenderer:"vanilla",renderEars:!0,highlightBlockColor:"blue",fetchPlayerSkins:!0,skinTexturesProxy:void 0,vrSupport:!0,vrPageGameRendering:!0,clipWorldBelowY:void 0,isPlayground:!1,instantCameraUpdate:!1,isRaining:!1,moduleStates:{}};var KI=()=>({reactive:ba({world:{chunksLoaded:{},heightmaps:{},allChunksLoaded:!1,mesherWork:!1,instabilityFactors:UT(),intersectMedia:null},renderer:"...",preventEscapeMenu:!1}),nonReactive:{fps:0,worstRenderTime:0,avgRenderTime:0,world:{chunksLoadedCount:0,chunksTotalNumber:0,chunksFullInfo:"-"},renderer:{timeline:{live:[],frozen:[],lastSecond:[]}}}});f();m();h();f();m();h();f();m();h();Cs();var D2=i=>[Math.floor(i.x/16),Math.floor(i.z/16)];var gje=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)},bh=new WeakMap,V2=class V2 extends Nl{static restoreTransferred(e,t){let n=new V2;if(!t)return n;let r=bh.get(t);if(r)r.activeWorldView=n;else{let s=({data:o})=>{let l=bh.get(t)?.activeWorldView;!l||o?.class!==V2.restorerName||o.type==="event"&&l.emit(o.eventName,...o.args)};t.addEventListener("message",s),r={activeWorldView:n,handler:s},bh.set(t,r)}return n}static clearWorkerBridgeForTest(e){let t=bh.get(e);t&&(e.removeEventListener("message",t.handler),bh.delete(e))}static getWorkerBridgeListenerCountForTest(e){return bh.has(e)?1:0}};Cn(V2,"restorerName","WorldViewWorker");var xh=V2,s8=class extends Nl{constructor(t,n,r=new ut(0,0,0)){super();this.world=t;this.viewDistance=n;this.lastPos=new ut(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:xh.restorerName,type:"event",eventName:r,args:Z6(s)})}}return{__restorer:xh.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]=D2(t),o=Mp(this.viewDistance).map(([a,l])=>new ut((r+a)*16,0,(s+l)*16));this.lastPos.update(t),await this._loadChunks(o,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 o of Object.keys(this.waitingSpiralChunksLoad))this.waitingSpiralChunksLoad[o](!1),delete this.waitingSpiralChunksLoad[o];let s=!0;this.inLoading=!0,await gje(t,this.addWaitTime,async o=>{!s||this.loadedChunks[`${o.x},${o.z}`]||(this.world.getColumnAt(o)||(s=await new Promise(a=>{this.waitingSpiralChunksLoad[`${o.x},${o.z}`]=a})),s&&(await this.loadChunk(o,void 0,`spiral ${r} from ${n.x},${n.z}`),this.chunkProgress()))}),r===this.spiralNumber&&(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,o]=D2(this.lastPos),a=Math.abs(s-Math.floor(t.x/16)),l=Math.abs(o-Math.floor(t.z/16));if(a<=this.viewDistance&&l<=this.viewDistance){let c=await this.world.getColumnAt(t.y!==void 0?t:new ut(t.x,0,t.z));if(c){let d=c.toJson(),u={minY:c.minY??0,worldHeight:c.worldHeight??256};this.emit("loadChunk",{x:t.x,z:t.z,chunk:d,blockEntities:c.blockEntities,worldConfig:u,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:d.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,o){if(typeof s!="string")return;let[a,l,c]=s.split(",").map(Number);return t.world.getBlock(new ut(a,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,o]=D2(this.lastPos),[a,l]=D2(t);if(s!==a||o!==l||n){this.emit("chunkPosUpdate",{pos:t});let c=[],d=n?this.viewDistance:this.viewDistance+this.keepChunksDistance;for(let p of Object.keys(this.loadedChunks)){let[v,_]=p.split(",").map(Number),b=new ut(v,0,_),[y,g]=D2(b),w=Math.abs(a-y),x=Math.abs(l-g);(w>d||x>d)&&c.push(b)}for(let p of c)this.unloadChunk(p);let u=Mp(this.viewDistance).map(([p,v])=>{let _=new ut((a+p)*16,0,(l+v)*16);if(!this.loadedChunks[`${_.x},${_.z}`])return _}).filter(p=>!!p);this.lastPos.update(t),this._loadChunks(u,t)}else this.emit("chunkPosUpdate",{pos:t}),this.lastPos.update(t)}};var U2=class{constructor(e,t,n){this.documentRenderer=e;this.options=t;this.abortSignal=n;this._scene=new _r,this._scene.background=new Fe(3294568),this._camera=new Yt(85,e.canvas.width/e.canvas.height,.05,1e3),this.camera.position.set(0,0,0),this.camera.rotation.set(0,0,0)}_scene;_camera;get scene(){return this._scene}get camera(){return this._camera}worldRenderer;WorldRendererClass=yd;async init(){let e=l2,t=new Ql;if(t.currentConfig={version:e,noInventoryGui:!0},await t.updateAssetsData?.({}),this.abortSignal.aborted)return;console.time("load menu background scene");let n=yge(e),s=oi()(e),a=globalThis.mcData.blocksArray.filter(v=>{if(!v.name.includes("stained_glass"))return!1;let _=s.fromStateId(v.defaultState,0);if(_.shapes?.length!==1)return!1;let b=_.shapes[0];return b[0]===0&&b[1]===0&&b[2]===0&&b[3]===1&&b[4]===1&&b[5]===1}),l=-15,c=100,d=100;for(let v=-c;v<c;v++)for(let _=-d;_<d;_++){let b=a[Math.floor(Math.random()*a.length)];n.setBlockStateId(new ut(v,_,l),b.defaultState)}this._camera.updateProjectionMatrix(),this._camera.position.set(.5,d/2+.5,.5),this._camera.rotation.set(0,0,0);let u=new ut(...this._camera.position.toArray()),p=new s8(n,2,u);this.abortSignal.aborted||(this.worldRenderer=new this.WorldRendererClass(this.documentRenderer.renderer,this.options,{version:e,worldView:p,inWorldRenderingConfig:bge,playerStateReactive:Ohe().reactive,rendererState:KI().reactive,nonReactiveState:KI().nonReactive,resourcesManager:t}),this.worldRenderer instanceof yd&&(this._scene=this.worldRenderer.realScene,this._camera=this.worldRenderer.camera),p.init(u),await this.worldRenderer.waitForChunksToRender(),!this.abortSignal.aborted&&(this.setupMouseParallax(),console.timeEnd("load menu background scene")))}update(e,t){t&&bd(this.camera,this.documentRenderer.canvas)}dispose(){this.worldRenderer?.destroy(),this.worldRenderer=void 0,this._scene.clear()}setupMouseParallax(){let e=this._camera,t=e.position.x,n=e.position.y,r;document.body.addEventListener("pointermove",s=>{if(s.pointerType!=="mouse")return;let o=.2,a=s.clientX/window.innerWidth-.5,l=-(s.clientY/window.innerHeight-.5);r?.stop(),r=new br(e.position).to({x:t+a*o,y:n+l*o},0),r.start(),e.updateProjectionMatrix()},{signal:this.abortSignal})}};f();m();h();yt();var F2=class{constructor(e,t,n={},r=!1){this.documentRenderer=e;this.options=t;this.mode=qT(n,r)}active;abortController=new AbortController;mode;lastFrameTime=0;get v2(){return this.active instanceof lh?this.active:void 0}get scene(){return this.active?.scene}get camera(){return this.active?.camera}async start(e={}){this.active=this.createImplementation(e),await this.active.init(),this.active.scene.background instanceof Fe&&this.documentRenderer.renderer.setClearColor(this.active.scene.background),this.lastFrameTime=performance.now(),this.documentRenderer.render=(t=!1)=>{let n=performance.now(),r=Math.min((n-this.lastFrameTime)/1e3,.05);this.lastFrameTime=n;let s=this.active;s&&(s.update(r,t),this.documentRenderer.renderer.render(s.scene,s.camera))}}createImplementation(e){switch(this.mode){case"v2":return new lh(this.documentRenderer,{useMinecraftTextures:e.useMinecraftTextures,initialScene:e.v2Scene,initialCamera:e.v2Camera,initialBlockGroup:e.v2BlockGroup,initialCameraSpeed:e.v2CameraSpeed,initialBlockSpeed:e.v2BlockSpeed,resourcesManager:e.resourcesManager},this.abortController.signal);case"worldBlocks":return new U2(this.documentRenderer,this.options,this.abortController.signal);default:return new c2(this.documentRenderer)}}dispose(){this.active?.dispose(),this.active=void 0,this.abortController.abort()}};f();m();h();var Dd=nl,_je={rendererWorldPerformance:"normal",rendererMeshersCountOverride:null,starfieldRendering:!0,defaultSkybox:!0,menuBackgroundMode:Dd.mode,menuBackgroundMinecraftTextures:Dd.minecraftTextures,menuBackgroundV2Scene:Dd.v2Scene,menuBackgroundV2Camera:Dd.v2Camera,menuBackgroundV2BlockGroup:Dd.v2BlockGroup,menuBackgroundV2CameraSpeed:Dd.v2CameraSpeedPercent,menuBackgroundV2BlockSpeed:Dd.v2BlockSpeedPercent,rendererFuturisticReveal:!1,rendererPerfDebugOverlay:!1,disableBlockEntityTextures:!1,rendererMesher:"wasm",rendererShaderCubeBlocks:!1,rendererShaderCubeDebugMode:"off",showChunkBorders:!1,renderEntities:!0,renderDebug:"basic",frameLimit:!1,backgroundRendering:"20fps",vanillaLook:!1,smoothLighting:!0,newVersionsLighting:!1,vrSupport:!0,vrPageGameRendering:!1,clipWorldBelowY:void 0,highlightBlockColor:"auto",loadPlayerSkins:!0,renderEars:!0,showHand:!0,viewBobbing:!0,dayCycleAndLighting:!0,keepChunksDistance:1,gpuPreference:"default",fov:75};var yje={menuBackgroundMode:{possibleValues:[["classic","Classic"],["v2","V2"]],requiresRestart:!0},menuBackgroundMinecraftTextures:{text:"Minecraft block textures",tooltip:"Use block atlas on V2 menu cubes (loads assets on menu)"},menuBackgroundV2Scene:{possibleValues:ih.map(i=>[i,m4[i]])},menuBackgroundV2Camera:{possibleValues:sh.map(i=>[i,p4[i]])},menuBackgroundV2BlockGroup:{possibleValues:oh.map(i=>[i,v4[i]]),text:"Block pool",tooltip:"Block set for textured menu cubes (requires Minecraft textures)"},menuBackgroundV2CameraSpeed:{text:"Camera speed",tooltip:"Orbit / fly-through camera path speed. 0 freezes the path; mouse parallax still works.",min:0,max:200,unit:"%"},menuBackgroundV2BlockSpeed:{text:"Block speed",tooltip:"Floating blocks and sky rotation. Independent of camera path speed.",min:0,max:200,unit:"%"},rendererWorldPerformance:{text:"World performance",tooltip:"Background workers for chunk geometry. Reload to apply.",requiresRestart:!0,possibleValues:[["low-energy","Low Energy"],["normal","Normal"],["maximum","Maximum"]]},starfieldRendering:{text:"Starfield"},defaultSkybox:{text:"Default skybox"},rendererFuturisticReveal:{text:"Futuristic world reveal"},rendererPerfDebugOverlay:{text:"Performance debug overlay"},disableBlockEntityTextures:{text:"Disable block entity textures",tooltip:"Skips signs, banners, heads, maps, etc."},rendererMesher:{possibleValues:[["wasm","WASM"],["legacy-js","Legacy JS"]],text:"Mesher pipeline",tooltip:"WASM is faster. Use JS if WASM is not working. Requires reload.",requiresRestart:!0},rendererShaderCubeBlocks:{text:"Instanced shader cubes",tooltip:"Render full blocks through the global GPU instanced path. Requires WASM mesher and WebGL2.",requiresChunksReload:!0},rendererShaderCubeDebugMode:{text:"Shader cube debug",tooltip:"Instanced cube path visualization (requires shader cubes enabled).",possibleValues:[["off","Off"],["holes","Hole test (red)"],["texIndex","Tile index colors"],["faces","Face id colors"],["atlasAlpha","Atlas alpha"]]},showChunkBorders:{text:"Chunk borders"},renderEntities:{text:"Render entities"},renderDebug:{possibleValues:["advanced","basic","none"]},frameLimit:{text:"Frame limit",tooltip:"false = VSync / unlimited when focused"},backgroundRendering:{text:"Background FPS limit",possibleValues:[["full","NO"],["5fps","5 FPS"],["20fps","20 FPS"]]},vanillaLook:{text:"Vanilla shading",tooltip:"On: Minecraft-style face shading. Off: higher-contrast client shading."},smoothLighting:{},newVersionsLighting:{text:"Lighting in newer versions"},vrSupport:{text:"VR support",tooltip:"Shows VR entry; does not force VR on."},vrPageGameRendering:{text:"VR page game rendering"},clipWorldBelowY:{text:"Clip world below Y"},highlightBlockColor:{possibleValues:[["auto","Auto"],["blue","Blue"],["classic","Classic"]]},loadPlayerSkins:{},renderEars:{tooltip:"Deadmau5 ears when the skin texture includes them"},showHand:{},viewBobbing:{},dayCycleAndLighting:{text:"Day cycle"},keepChunksDistance:{text:"Keep chunks distance",tooltip:"Extra distance before unloading chunks",max:5,unit:""},fov:{min:30,max:110,unit:"\xB0",text:"FOV"},gpuPreference:{text:"GPU preference",tooltip:"WebGL power preference. Requires reload / backend restart to apply.",requiresRestart:!0,possibleValues:[["default","Auto"],["high-performance","Dedicated"],["low-power","Low power"]]}};hi.enabled=!1;globalThis.THREE=Lt;var xge=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),spawnBlockBreakParticles(e,t,n,r,s,o){i.getModule("blockBreakParticles")?.spawnBlockBreakParticles(e,t,n,r,s,o)},spawnBlockCrackParticle(e,t,n,r,s,o,a){i.getModule("blockBreakParticles")?.spawnCrackParticle(e,t,n,r,s,o,a)},async loadGeometryExport(e){let{applyWorldGeometryExport:t}=await Promise.resolve().then(()=>(kT(),a3e));return t(i,e)},feedChunkPacket(e){let{kind:t,...n}=e,r={type:t,...n};for(let s of i.workers)s.postMessage(r)},getChunksDebugState(){let e={};for(let t of Object.keys(i.sectionObjects)){let[n,,r]=t.split(",").map(Number);e[`${n},${r}`]=!0}return{loadedSectionsChunks:e,loadedChunks:{...i.loadedChunks},finishedChunks:{...i.finishedChunks}}}}),bje=[],o8=(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)}},wge=()=>{let i,e=null,t=null,n=null,r=null,s=(d,u)=>{dn?i=R5(d,bje,globalThis):i=d,e=new K6(i,u?.canvas),globalThis.renderer=e.renderer,globalThis.documentRenderer=e,globalThis.threeJsBackend=c,o8("default",c)},o=async d=>{if(!e)throw new Error("Document renderer not initialized");n&&(n.destroy(),n=null,r=null,globalThis.world=void 0,globalThis.frameTimingCollector=void 0),t&&(t.dispose(),t=null);let u={...i.config.menuBackground,...d};t=new F2(e,{...i},u,!!process.env.SINGLE_FILE_BUILD_MODE),o8("menuBackgroundCreated",t),await t.start(u),o8("menuBackgroundReady",t)},a=async d=>{if(!e)throw new Error("Document renderer not initialized");t&&(t.dispose(),t=null),n&&(n.destroy(),n=null,r=null,globalThis.world=void 0,globalThis.frameTimingCollector=void 0);let p=dn?R5(d,[Ql,xh],globalThis):d;e.nonReactiveState=p.nonReactiveState,globalThis.resourcesManager=p.resourcesManager,n=new yd(e.renderer,i,p),await n.worldReadyPromise,r=p.inWorldRenderingConfig.enableDebugOverlay?new eg(p.nonReactiveState):null,globalThis.frameTimingCollector=r;let v=e.render;e.render=function(_){v.call(this,_),r?.markFrameStart(),p.inWorldRenderingConfig.paused||n?.render(_),r?.markFrameEnd(),r?.markFrameDisplay()},e.inWorldRenderingConfig=p.inWorldRenderingConfig,globalThis.world=n,o8("worldReady",n)},l=()=>{t&&(t.dispose(),t=null),e&&e.dispose(),n&&(n.destroy(),n=null)},c={id:"threejs",displayName:`three.js ${bo}`,startMenuBackground:o,startWorld:a,disconnect:l,setRendering(d){e.setPaused(!d),n&&(n.renderingActive=d)},getMenuBackground:()=>t??void 0,getDebugOverlay:()=>({get entitiesString(){return n?.entities.getDebugString()},get left(){return{"Geo Memory":n?.chunkMeshManager.getEstimatedMemoryUsage().total??"-"}}}),updateCamera(d,u,p){r?.markCameraUpdate(!d),n?.setFirstPersonCamera(d,u,p)},get soundSystem(){return n?.soundSystem},get backendMethods(){if(n)return xge(n)}};return{main:{init:s,backend:c},workerProxy(){return yB({init(d,u){s(d,{canvas:u})},updateSizeExternal(d,u,p){e?.updateSizeExternal(d,u,p)},startMenuBackground:o,startWorld:a,disconnect:l,setRendering:c.setRendering,updateCamera(d,u,p){let v=d?new ut(d.x,d.y,d.z):null;r?.markCameraUpdate(!v),c.updateCamera(v,u,p)},async callBackendMethod(d,...u){if(!n)throw new Error("World renderer not initialized");let v=xge(n)[d];if(!v)throw new Error(`Backend method ${String(d)} is unavailable`);return v(...u)}})}}};globalThis.structuredClone??=i=>JSON.parse(JSON.stringify(i));var Ege=i=>{AC(i);let e=globalThis;e.mcData=i,e.loadedData=i,self.postMessage({type:"mcDataApplied"})};self.addEventListener("message",i=>{let e=i.data;if(e.type==="mcData"){Ege(e.mcData),console.log("data loaded");return}Array.isArray(e)&&e.forEach(t=>{t.type==="mcData"&&Ege(t.mcData)})});var xje=wge();xje.workerProxy();})();
|
|
28832
|
+
}`})}},VT=class{constructor(e){this.worldRenderer=e}points;clock=new Rs;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.set(0,0,0),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,o=new it,a=b=>new K().setFromSpherical(new E5(b,Math.acos(1-Math.random()*2),Math.random()*2*Math.PI)),l=[],c=[],d=Array.from({length:n},()=>(.5+.5*Math.random())*r),u=new Fe,p=e+t,v=t/n;for(let b=0;b<n;b++)p-=v*Math.random(),l.push(...a(p).toArray()),u.setHSL(b/n,s,.9),c.push(u.r,u.g,u.b);o.setAttribute("position",new qe(l,3)),o.setAttribute("color",new qe(c,3)),o.setAttribute("size",new qe(d,1));let _=new DT;_.blending=Pi,_.depthTest=!0,_.depthWrite=!1,_.transparent=!0,this.points=new tr(o,_),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)}},T3e={id:"starfield",controller:VT,enabledDefault:!0,cannotBeDisabled:!0};var I3e={starfield:T3e,futuristicReveal:k3e,rain:A3e,cameraBobbing:x3e,blockBreakParticles:b3e};f();m();h();f();m();h();var UT=()=>({longRenderTime:!1,constantLongRenderTime:!1,tooManyEntities:!1,tooManyTextures:!1,unknownReason:!1});f();m();h();f();m();h();var a2=class{constructor(e){this.factors=e}renderTimeHistory=[];onFrame(e){this.pushRenderTime(e.totalMs),this.recompute(e)}pushRenderTime(e){this.renderTimeHistory.push(e),this.renderTimeHistory.length>24&&this.renderTimeHistory.shift()}recompute(e){let t=e.fps>0&&e.fps<=45,n=Math.max(0,e.totalMs-e.entitiesMs),r=e.totalMs>=30,s=this.renderTimeHistory.length,o=this.renderTimeHistory.filter(p=>p>=30).length,a=s>=8&&o/s>=.65,l=e.loadedTextureCount>=100,c=t&&e.entitiesMs>=8&&n<=20,u=t&&!(r||a||c||l);this.factors.longRenderTime=r,this.factors.constantLongRenderTime=a,this.factors.tooManyEntities=c,this.factors.tooManyTextures=l,this.factors.unknownReason=u}reset(){this.renderTimeHistory.length=0,this.factors.longRenderTime=!1,this.factors.constantLongRenderTime=!1,this.factors.tooManyEntities=!1,this.factors.tooManyTextures=!1,this.factors.unknownReason=!1}};f();m();h();var DGe=[{key:"longRenderTime",code:"LR"},{key:"constantLongRenderTime",code:"CLR"},{key:"tooManyEntities",code:"ENT"},{key:"tooManyTextures",code:"TEX"},{key:"unknownReason",code:"UNK"}];function zT(i){let e=DGe.filter(({key:t})=>i[t]).map(({code:t})=>t);return e.length>0?e.join("+"):""}var _d=class _d extends U7{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.performanceMonitor=new a2(this.reactiveState.world.instabilityFactors),this.renderer=t;let s=_d.getRendererInfo(t)??"...";r.rendererState.renderer=s,this.chunkMeshManager=new o2(this,this.scene,this.material,this.worldSizeParams.worldHeight,this.viewDistance),this.onRenderDistanceChanged=o=>{this.chunkMeshManager.updateViewDistance(o)},this.cursorBlock=new z_(this),this.holdingBlock=t2(this),this.holdingBlockLeft=t2(this,!0);for(let o of Object.values(I3e))this.registerModule(o);this.skyboxRenderer=new J_(this.realScene,!1,null),this.skyboxRenderer.init(),this.addDebugOverlay(),this.resetScene(),this.init(),this.soundSystem=new q_(this),this.cameraShake=new G_(this,this.onRender),this.media=new W_(this),this.fireworksLegacy=new X_(this),this.waypoints=new $_(this),this.cinimaticScript=new Y_(this,(o,a,l)=>this.setCinimaticCamera(o,a,l),o=>this.setCinimaticFov(o),()=>({position:new ut(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z),yaw:this.cameraShake.getBaseRotation().yaw,pitch:this.cameraShake.getBaseRotation().pitch,fov:this.camera.fov})),this.fireworks=new K_(this.realScene,this.sceneOrigin),this.renderUpdateEmitter.on("chunkFinished",o=>{this.finishChunk(o)}),this.worldSwitchActions(),this.initializeModules()}outputFormat="threeJs";isShaderCubeBlocksEnabled(){return this.worldRendererConfig.shaderCubeBlocks===!0&&!!this.renderer?.capabilities?.isWebGL2}chunkMeshManager;get sectionObjects(){return this.chunkMeshManager.sectionObjects}chunkTextures=new Map;signsCache=new Map;cameraSectionPos=new ut(0,0,0);holdingBlock;holdingBlockLeft;scene=new _r;get realScene(){return this.scene}ambientLight=new go(13421772);directionalLight=new ss(16777215,.5);entities=new F_(this,globalThis.mcData);performanceMonitor;cameraGroupVr;material=new st({vertexColors:!0,transparent:!0,alphaTest:.1});itemsTexture;cursorBlock;onRender=[];lastRenderTime=0;animatedFov=0;lastFovAnimTime=0;cameraShake;cameraContainer;media;get waitingChunksToDisplay(){return this.chunkMeshManager.waitingChunksToDisplay}waypoints;cinimaticScript;camera;renderTimeAvg=0;pendingSectionUpdates=new Map;pendingSectionBufferStartTimes=new Map;get estimatedMemoryUsage(){return this.chunkMeshManager.getEstimatedMemoryUsage().total}modules={};sectionsOffsetsAnimations={};fountains=[];fireworksLegacy;DEBUG_RAYCAST=!1;skyboxRenderer;fireworks;sceneOrigin=new Z_(this.scene);cameraWorldPos={x:0,y:0,z:0};_cameraPositionAccessWarned=!1;_tmpCameraPos=new K;currentPosTween;currentRotTween;_tpDirection=new K;_tpPitchQuat=new Vt;_tpYawQuat=new Vt;_tpFinalQuat=new Vt;_tpScenePos=new K;_tpAxisX=new K(1,0,0);_tpAxisY=new K(0,1,0);_tpRaycaster=new _a;_tpChunkWorldPos=new K;get tilesRendered(){return this.chunkMeshManager.getTotalTiles()}get blocksRendered(){return this.chunkMeshManager.getTotalBlocks()}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 o=this.onRender.indexOf(r.controller.render);o>-1&&this.onRender.splice(o,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}_wrapCameraPositionWithWarning(){let t=this.camera.position,n=this,r=20,s=(l,c,d)=>Math.abs(l)>r||Math.abs(c)>r||Math.abs(d)>r,o=()=>{!n._cameraPositionAccessWarned&&typeof process<"u"},a=new Proxy(t,{set(l,c,d){return(c==="x"||c==="y"||c==="z")&&typeof d=="number"&&Math.abs(d)>r&&o(),l[c]=d,!0},get(l,c,d){let u=l[c];return c==="set"?function(p,v,_){return s(p,v,_)&&o(),l.set(p,v,_)}:c==="setX"||c==="setY"||c==="setZ"?function(p){return Math.abs(p)>r&&o(),l[c](p)}:c==="copy"?function(p){return s(p.x,p.y,p.z)&&o(),l.copy(p)}:typeof u=="function"?u.bind(l):u}});Object.defineProperty(this.camera,"position",{value:a,configurable:!0,enumerable:!0})}worldSwitchActions(){this.onWorldSwitched.push(()=>{this.protocolCustomBlocks.clear(),this.sectionsOffsetsAnimations={},this.waypoints.clear(),this.cinimaticScript.stopScript(),this.fireworks.clear()})}downloadWorldGeometry(){MT(this,new K(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z),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.sceneOrigin.update(0,0,0),this.cameraWorldPos.x=0,this.cameraWorldPos.y=0,this.cameraWorldPos.z=0,this.scene.matrixAutoUpdate=!1,this.scene.background=new Fe(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 Yt(75,t.x/t.y,.1,1e3),this._wrapCameraPositionWithWarning(),this.cameraContainer=new At,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 ut(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 ut(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z);this.updateCamera(n,this.cameraShake.getBaseRotation().yaw,this.cameraShake.getBaseRotation().pitch)})}watchReactiveConfig(){super.watchReactiveConfig(),this.onReactiveConfigUpdated("showChunkBorders",n=>{this.updateShowChunksBorder(n)}),this.onReactiveConfigUpdated("defaultSkybox",n=>{this.skyboxRenderer.updateDefaultSkybox(n)}),this.onReactiveConfigUpdated("shaderCubeDebugMode",()=>{this.chunkMeshManager.syncCubeShaderUniforms()}),this.onReactiveConfigUpdated("futuristicReveal",()=>{this.updateModulesFromConfig()});let t=this.displayOptions.inWorldRenderingConfig.handRenderer;this.onReactiveConfigUpdated("handRenderer",n=>{if(n===t)return;t=n;let r=this.holdingBlock.ready,s=this.holdingBlockLeft.ready;this.holdingBlock.dispose(),this.holdingBlockLeft.dispose(),this.holdingBlock=t2(this),this.holdingBlockLeft=t2(this,!0),r&&(this.holdingBlock.ready=!0,this.holdingBlock.updateItem()),s&&(this.holdingBlockLeft.ready=!0,this.holdingBlockLeft.updateItem())}),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 o=r.controller.autoEnableCheck();o&&!r.enabled?this.toggleModule(n,!0):!o&&r.enabled&&!r.manifest.cannotBeDisabled&&this.toggleModule(n,!1)}else{let o=r.manifest.enabledDefault??!1;o&&!r.enabled?this.toggleModule(n,!0):!o&&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=f0(t.blocksAtlasImage);s.needsUpdate=!0,s.flipY=!1,this.material.map=s,this.chunkMeshManager.syncCubeShaderUniforms();let o=f0(t.itemsAtlasImage);o.needsUpdate=!0,o.flipY=!1,this.itemsTexture=o,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.realScene.background=new Fe(t[0],t[1],t[2])}changeCardinalLight(t){this.worldRendererConfig.cardinalLight=t}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(yT)}getItemRenderData(t,n){return G2e(t,n,this.resourcesManager,this.playerStateReactive)}async demoModel(){let t=cursorBlockRel(0,1,0).position,n=await Tp();Ghe(n,t);let r=new yo(n,16776960);n.add(r),this.realScene.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 yo(n,16776960);n.add(r),this.realScene.add(n)}debugOverlayAdded=!1;addDebugOverlay(){if(this.debugOverlayAdded)return;this.debugOverlayAdded=!0;let t=N7("debug-overlay",80,0,void 0,{className:O7});setInterval(()=>{if(t.setVisibility(this.displayAdvancedStats),this.displayAdvancedStats){let n=l=>new Intl.NumberFormat("en-US",{}).format(l),r=l=>new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1}).format(l),s="";s+=`TE: ${n(this.renderer.info.memory.textures)} `,s+=`F: ${r(this.tilesRendered)} `,s+=`B: ${r(this.blocksRendered)} `,s+=`MEM: ${this.chunkMeshManager.getEstimatedMemoryUsage().total} `;let o=this.chunkMeshManager.getStats();s+=`POOL: ${o.activeCount}/${o.poolSize} `;let a=zT(this.reactiveState.world.instabilityFactors);a&&(s+=`PF: ${a} `),t.updateText(s),this.backendInfoReport=s}},200)}updatePosDataChunk(t){let n=this.sectionObjects[t];if(!n)return;let[r,s,o]=t.split(",").map(d=>Math.floor(+d/16)),l=500-(Math.abs(r-this.cameraSectionPos.x)+Math.abs(s-this.cameraSectionPos.y)+Math.abs(o-this.cameraSectionPos.z)),c=n.mesh??n.shaderMesh??n.children.find(d=>d.name==="mesh"||d.name==="shaderMesh");c&&(c.renderOrder=l)}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.chunkMeshManager.finishChunkDisplay(t)}applyPendingSectionUpdates(){if(this.pendingSectionUpdates.size===0)return;let t=performance.now(),n=this.getSectionHeight(),r=[];for(let s of this.pendingSectionUpdates.keys()){let o=this.pendingSectionBufferStartTimes.get(s)??t;if(t-o<_d.MAX_SECTION_UPDATE_BUFFER_MS){let[l,c,d]=s.split(",").map(Number),u=[`${l-16},${c},${d}`,`${l+16},${c},${d}`,`${l},${c-n},${d}`,`${l},${c+n},${d}`,`${l},${c},${d-16}`,`${l},${c},${d+16}`],p=!1;for(let v of u)if(this.sectionsWaiting.has(v)&&!this.pendingSectionUpdates.has(v)&&this.sectionObjects[v]){p=!0;break}if(p)continue}r.push(s)}if(r.length!==0)for(let s of r){let o=this.pendingSectionUpdates.get(s);this.pendingSectionUpdates.delete(s),this.pendingSectionBufferStartTimes.delete(s);let a=o.key.split(","),l=`${a[0]},${a[2]}`;if(!this.loadedChunks[l]||!this.active){this.chunkMeshManager.releaseSection(o.key);continue}if(!this.chunkMeshManager.sectionHasRenderableContent(o.geometry)){this.chunkMeshManager.releaseSection(o.key);continue}this.chunkMeshManager.updateSection(o.key,o.geometry),this.updatePosDataChunk(o.key)}}clearPendingSectionUpdatesForChunk(t,n){for(let r of[...this.pendingSectionUpdates.keys()])r.startsWith(`${t},`)&&r.endsWith(`,${n}`)&&(this.pendingSectionUpdates.delete(r),this.pendingSectionBufferStartTimes.delete(r))}handleWorkerMessage(t){if(t.type==="geometry"){let n=t.key.split(","),r=`${n[0]},${n[2]}`;if(!this.loadedChunks[r]||!this.active){this.pendingSectionUpdates.delete(t.key),this.pendingSectionBufferStartTimes.delete(t.key);return}if(this.sectionObjects[t.key]){this.pendingSectionUpdates.set(t.key,t),this.pendingSectionBufferStartTimes.has(t.key)||this.pendingSectionBufferStartTimes.set(t.key,performance.now());return}if(!this.chunkMeshManager.sectionHasRenderableContent(t.geometry)){this.chunkMeshManager.releaseSection(t.key);return}this.chunkMeshManager.updateSection(t.key,t.geometry),this.updatePosDataChunk(t.key)}}getSignTexture(t,n,r,s=!1){let o=m1(t),a=this.chunkTextures.get(`${o[0]},${o[1]}`);a||(a={},this.chunkTextures.set(`${o[0]},${o[1]}`,a));let l=`${t.x},${t.y},${t.z}`;if(a[l])return a[l];let c=(0,P3e.default)(this.version),d=B7(n,r,c);if(!d)return;let u=new Gt(d);return u.magFilter=Qe,u.minFilter=Qe,u.needsUpdate=!0,a[l]=u,u}getCameraPosition(t){return(t??this._tmpCameraPos).set(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z)}getSectionCameraPosition(){let t=this.getCameraPosition();return new ut(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.updateCameraSectionPos()}getThirdPersonCamera(t,n,r){t??=new K(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z);let s=this.playerStateReactive.perspective==="third_person_back",o=4,a=this._tpDirection.set(0,0,-1),l=this._tpPitchQuat.setFromAxisAngle(this._tpAxisX,r),c=this._tpYawQuat.setFromAxisAngle(this._tpAxisY,n),d=this._tpFinalQuat.multiplyQuaternions(c,l);a.applyQuaternion(d),s&&a.multiplyScalar(-1),this.DEBUG_RAYCAST&&this.debugRaycast(t,a,o);let u=this._tpScenePos.set(this.sceneOrigin.toSceneX(t.x),this.sceneOrigin.toSceneY(t.y),this.sceneOrigin.toSceneZ(t.z)),p=this._tpRaycaster;p.set(u,a),p.far=o;let v=80,_=v*v,b=t.x,y=t.y,g=t.z,w=[];for(let C of Object.values(this.sectionObjects)){if(C.name!=="chunk"||!C.visible||C.worldX===void 0)continue;let L=C.worldX-b,M=C.worldY-y,k=C.worldZ-g;if(L*L+M*M+k*k>_)continue;let F=C.children.find(Z=>Z.name==="mesh"||Z.name==="shaderMesh");F&&w.push(F)}let x=p.intersectObjects(w,!1),E=o;x.length>0&&(E=Math.max(.5,x[0].distance-.2));let A=this.chunkMeshManager.raycastShaderSectionAABBs(t,a,E,v);return A!==void 0&&(E=Math.max(.5,A-.2)),new ut(t.x+a.x*E,t.y+a.y*E,t.z+a.z*E)}debugRaycastHelper;debugHitPoint;debugRaycast(t,n,r){this.debugRaycastHelper&&(this.realScene.remove(this.debugRaycastHelper),this.debugRaycastHelper=void 0),this.debugHitPoint&&(this.realScene.remove(this.debugHitPoint),this.debugHitPoint=void 0);let s=new K(this.sceneOrigin.toSceneX(t.x),this.sceneOrigin.toSceneY(t.y),this.sceneOrigin.toSceneZ(t.z));this.debugRaycastHelper=new bc(n.clone().normalize(),s,r,16711680,r*.1,r*.05),this.realScene.add(this.debugRaycastHelper);let o=new rs(.2,8,8),a=new st({color:65280});this.debugHitPoint=new je(o,a),this.debugHitPoint.position.copy(s).add(n.clone().multiplyScalar(r)),this.realScene.add(this.debugHitPoint)}prevFramePerspective=null;setCinimaticCamera(t,n,r){this.cameraWorldPos.x=t.x,this.cameraWorldPos.y=t.y,this.cameraWorldPos.z=t.z,this.sceneOrigin.update(t.x,t.y,t.z),this.cameraObject.position.set(0,0,0),this.cameraShake.setBaseRotation(r,n),this.updateCameraSectionPos()}setCinimaticFov(t){this.animatedFov=t,this.camera.fov=t,this.camera.updateProjectionMatrix()}updateSmoothFov(){if(this.cinimaticScript.running)return;let t=this.displayOptions.inWorldRenderingConfig.fov,n=this.playerStateReactive.fovMultiplier,r=t*(Number.isFinite(n)?n:1),s=performance.now();if(this.animatedFov===0&&(this.animatedFov=r),Math.abs(this.animatedFov-r)>=.01){let o=s-this.lastFovAnimTime,a=Math.min(o/_d.FOV_TRANSITION_MS,1),l=c=>1-(1-c)**3;this.animatedFov+=(r-this.animatedFov)*l(a),Math.abs(this.animatedFov-r)<.01&&(this.animatedFov=r)}else this.animatedFov=r;this.lastFovAnimTime=s,this.camera.fov!==this.animatedFov&&(this.camera.fov=this.animatedFov,this.camera.updateProjectionMatrix())}updateCamera(t,n,r){if(!this.cinimaticScript.running){if(t){this.renderer.xr.isPresenting&&(t.y-=this.camera.position.y),this.currentPosTween?.stop();let s=this.displayOptions.inWorldRenderingConfig.instantCameraUpdate?0:this.playerStateUtils.isSpectatingEntity()?150:50;this.currentPosTween=new br(this.cameraWorldPos).to({x:t.x,y:t.y,z:t.z},s).onUpdate(()=>{this.sceneOrigin.update(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z),this.cameraObject.position.set(0,0,0)}).start()}if(this.playerStateUtils.isSpectatingEntity()){let s=this.cameraShake.getBaseRotation(),o=0,a=Math.PI/2;s.yaw<a&&n>Math.PI+a?o=-Math.PI*2:n<a&&s.yaw>Math.PI+a&&(o=Math.PI*2),this.currentRotTween?.stop(),this.currentRotTween=new br(s).to({pitch:r,yaw:n+o},100).onUpdate(l=>this.cameraShake.setBaseRotation(l.pitch,l.yaw-o)).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 o=new K(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z),a=this.getThirdPersonCamera(o,n,r),l=o.distanceTo(new K(a.x,a.y,a.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.z=0,this.camera.rotation.set(0,0,0),this.debugRaycastHelper&&(this.realScene.remove(this.debugRaycastHelper),this.debugRaycastHelper=void 0),this.debugHitPoint&&(this.realScene.remove(this.debugHitPoint),this.debugHitPoint=void 0)}this.updateCameraSectionPos()}}debugChunksVisibilityOverride(){let{chunksRenderAboveOverride:t,chunksRenderBelowOverride:n,chunksRenderDistanceOverride:r,chunksRenderAboveEnabled:s,chunksRenderBelowEnabled:o,chunksRenderDistanceEnabled:a}=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[d,u]of Object.entries(this.sectionObjects)){if(u._waitingForChunkDisplay)continue;let[p,v,_]=d.split(",").map(Number),b=s&&t!==void 0?v<=c+t:o&&n!==void 0?v>=c-n:a&&r!==void 0?Math.abs(v-c)<=r:!0;u.visible=b}else this.chunkMeshManager.updateSectionsVisibility()}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),this.updateSmoothFov(),t){let u=this.renderer.getSize(new Ve);this.camera.aspect=u.width/u.height,this.camera.updateProjectionMatrix()}let o=0;if(!this.reactiveDebugParams.disableEntities){let u=performance.now();this.entities.render(),o=performance.now()-u}let a=this.cameraGroupVr instanceof at?this.cameraGroupVr.children.find(u=>u instanceof Yt):this.camera;this.applyPendingSectionUpdates();let l=this.chunkMeshManager.globalBlockBuffer;l&&(l.setCameraOrigin(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z),l.compactStep(),l.uploadDirtyRange()),this.renderer.render(this.scene,a),this.displayOptions.inWorldRenderingConfig.showHand&&this.playerStateReactive.gameMode!=="spectator"&&this.playerStateReactive.perspective==="first_person"&&!this.renderer.xr.isPresenting&&(this.holdingBlock.render(this.camera,this.renderer,this.ambientLight,this.directionalLight),this.holdingBlockLeft.render(this.camera,this.renderer,this.ambientLight,this.directionalLight));for(let 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 d=performance.now()-n;this.worldRendererConfig.autoLowerRenderDistance&&this.chunkMeshManager.recordRenderTime(d),this.renderTimeAvgCount++,this.renderTimeAvg=(this.renderTimeAvg*(this.renderTimeAvgCount-1)+d)/this.renderTimeAvgCount,this.renderTimeMax=Math.max(this.renderTimeMax,d),this.performanceMonitor.onFrame({totalMs:d,entitiesMs:o,loadedTextureCount:this.renderer.info.memory.textures,fps:this.lastFps})}renderHead(t,n,r,s){let o;if(s.SkullOwner?o=s.SkullOwner.Properties?.textures?.[0]?.Value:o=s.profile?.properties?.find(a=>a.name==="textures")?.value,!!o)try{let l=JSON.parse(Buffer.from(o,"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 d=R0(this,l,C0.head),u=new at;return r&&d.position.set(0,.3125,.3125),d.position.y-=23/16,u.add(d),this.sceneOrigin.track(u),u.position.set(t.x+.5,t.y+.045,t.z+.5),u.rotation.set(0,-_t.degToRad(n*(r?90:45/2)),0),u.scale.set(.8,.8,.8),u}catch(a){console.error("Error decoding player texture:",a)}}renderSign(t,n,r,s,o){let a=this.getSignTexture(t,o,s);if(!a)return;let l=new je(new _n(1,1),new st({map:a,transparent:!0}));l.renderOrder=999;let c=7/16,d=s?1.3:1;l.scale.set(1*d,c*d,1*d);let u=(s?2:1.5)/16,p=.25/16;r&&!s?l.position.set(0,0,-.5+u+p+1e-4):l.position.set(0,0,u/2+1e-4);let v=new at;v.rotation.set(0,-_t.degToRad(n*(r?90:45/2)),0),v.add(l);let _=(s?10:8)/16,b=(s?0:r?4.333:9.333)/16,y=_/2+b;return this.sceneOrigin.track(v),v.position.set(t.x+.5,t.y+y,t.z+.5),v}lightUpdate(t,n){for(let r=this.worldSizeParams.minY;r<this.worldSizeParams.worldHeight;r+=16)this.setSectionDirty(new ut(t,r,n))}rerenderAllChunks(){for(let t of Object.keys(this.sectionObjects)){let[n,r,s]=t.split(",").map(Number);this.setSectionDirty(new ut(n,r,s))}}updateShowChunksBorder(t){this.chunkMeshManager.updateAllBoxHelpers(t)}resetWorld(){super.resetWorld(),this.pendingSectionUpdates.clear(),this.pendingSectionBufferStartTimes.clear(),this.chunkMeshManager.dispose(),this.chunkMeshManager=new o2(this,this.scene,this.material,this.worldSizeParams.worldHeight,this.viewDistance),this.debugRaycastHelper&&(this.realScene.remove(this.debugRaycastHelper),this.debugRaycastHelper=void 0),this.debugHitPoint&&(this.realScene.remove(this.debugHitPoint),this.debugHitPoint=void 0)}getLoadedChunksRelative(t,n=!1){let[r,s,o]=PA(t);return Object.fromEntries(Object.entries(this.sectionObjects).map(([a,l])=>{let[c,d,u]=a.split(",").map(Number),[p,v,_]=PA({x:c,y:d,z:u});return[n?`${p-r},${v-s},${_-o}`:`${p-r},${_-o}`,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];this.chunkMeshManager.cleanSignChunkTextures(t,n)}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.clearPendingSectionUpdatesForChunk(t,n);let r=this.getSectionHeight(),s=this.worldMinYRender;for(let o=s;o<this.worldSizeParams.worldHeight;o+=r){let a=`${t},${o},${n}`;this.chunkMeshManager.sectionObjects[a]&&this.chunkMeshManager.releaseSection(a)}this.chunkMeshManager.onChunkRemovedFromGate(`${t},${n}`)}updateViewerPosition(t){super.updateViewerPosition(t),this.chunkMeshManager.pendingNearReveal.size>0&&this.chunkMeshManager.tryRevealPending()}onViewerChunkPositionChanged(){this.chunkMeshManager.tryRevealPending()}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.performanceMonitor?.reset(),this.pendingSectionUpdates.clear(),this.pendingSectionBufferStartTimes.clear(),this.chunkMeshManager.dispose(),this.disposeModules(),this.fireworksLegacy.destroy(),super.destroy(),this.skyboxRenderer.dispose(),this.fireworks.dispose()}shouldObjectVisible(t){let r=this.getSectionHeight(),s,o,a,l=this.sceneOrigin.getWorldPosition(t);l?(s=l.x,o=l.y,a=l.z):(s=this.sceneOrigin.toWorldX(t.position.x),o=this.sceneOrigin.toWorldY(t.position.y),a=this.sceneOrigin.toWorldZ(t.position.z));let c=Math.floor(s/16)*16,d=Math.floor(a/16)*16,u=Math.floor(o/r)*r,p=`${c},${d}`,v=`${c},${u},${d}`;return!!this.finishedChunks[p]||!!this.sectionObjects[v]}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 o=this.sectionObjects[n];o&&(o.position.set(r.currentOffsetX,r.currentOffsetY,r.currentOffsetZ),o.updateMatrix())}}reloadWorld(){this.entities.reloadEntities()}};Cn(_d,"FOV_TRANSITION_MS",200),Cn(_d,"MAX_SECTION_UPDATE_BUFFER_MS",500);var yd=_d;f();m();h();f();m();h();var l2="1.21.4";f();m();h();function bd(i,e){i.aspect=e.width/e.height,i.updateProjectionMatrix()}f();m();h();f();m();h();var nl={mode:"v2",minecraftTextures:!0,v2Scene:"light",v2Camera:"dive",v2BlockGroup:"stainedGlass",v2CameraSpeedPercent:80,v2BlockSpeedPercent:40},HT=i=>i/100,h4={camera:HT(nl.v2CameraSpeedPercent),block:HT(nl.v2BlockSpeedPercent)};function qT(i,e=!1){return i?.mode?i.mode:e?"worldBlocks":nl.mode}f();m();h();yt();f();m();h();var GT={};function WT(...i){let e=i.filter(n=>n.length>0).join("/"),t=typeof globalThis.location<"u"&&globalThis.location.href?globalThis.location.href:typeof GT<"u"&>.url?GT.url:`/${e}`;try{return new URL(e,t).href}catch{return`/${e}`}}var jT=new Date,L3e=jT.getMonth()===11&&jT.getDate()>=24&&jT.getDate()<=26,VGe=["panorama_3.webp","panorama_1.webp","panorama_4.webp","panorama_5.webp","panorama_0.webp","panorama_2.webp"],UGe=200,c2=class{constructor(e){this.documentRenderer=e;this.scene=new _r,this.scene.background=new Fe(3294568);let t=new go(13421772);this.scene.add(t);let n=new ss(16777215,.5);n.position.set(1,1,.5).normalize(),n.castShadow=!0,this.scene.add(n),this.camera=new Yt(85,e.canvas.width/e.canvas.height,.05,1e3),this.camera.position.set(0,0,0),this.camera.rotation.set(0,0,0)}scene;camera;startTimes=new Map;time=0;panoramaGroup=null;async init(){this.buildCubemap()}update(e,t){t&&bd(this.camera,this.documentRenderer.canvas)}dispose(){this.scene.clear(),this.panoramaGroup=null,this.startTimes.clear()}buildCubemap(){let e=new nn(1e3,1e3,1e3),t=[];for(let s of VGe)(async()=>{let a=WT("background",L3e?"christmas":"",s),l=await $c(a),c=f0(l);c.matrixAutoUpdate=!1,c.matrix.set(-1,0,1,0,1,0,0,0,1),c.wrapS=gn,c.wrapT=gn,c.minFilter=jt,c.magFilter=jt;let d=new st({map:c,transparent:!0,side:cn,depthWrite:!1,opacity:0});this.startTimes.set(d,Date.now()),t.push(d)})().catch(a=>{console.warn("[ClassicMenuBackground] Failed to load panorama face:",s,a)});let n=new je(e,t);n.onBeforeRender=()=>{this.time+=.01,n.rotation.y=Math.PI+this.time*.01,n.rotation.z=Math.sin(-this.time*.001)*.001;for(let s of t){let o=this.startTimes.get(s);if(o){let a=Date.now()-o;s.opacity=Math.min(1,a/UGe)}}};let r=new At;if(r.add(n),!L3e)for(let s=0;s<20;s++){let o=new tl("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 a=Math.random()*.01;o.children[0].onBeforeRender=()=>{o.rotation.y+=a,o.rotation.z=Math.cos(n.rotation.y*3)*Math.PI/4-Math.PI/2},r.add(o)}this.scene.add(r),this.panoramaGroup=r}async debugImageInFrontOfCamera(){let e=await $c(WT("background","panorama_0.webp")),t=f0(e),n=new je(new _n(1e3,1e3),new st({map:t}));n.position.set(0,0,-500),this.scene.add(n)}};f();m();h();yt();f();m();h();var ih=["galaxy","nether","end","cyber","light"],sh=["cruise","barrel","dive","orbit","snake"],m4={galaxy:"Galaxy",nether:"Nether",end:"The End",cyber:"Cyber",light:"Light Space"},p4={cruise:"Cruise",barrel:"Barrel",dive:"Dive",orbit:"Orbit",snake:"Snake"},oh=["mixed","stainedGlass","wool","construction","glow","world"],v4={mixed:"Mixed",stainedGlass:"Stained glass",wool:"Wool",construction:"Construction",glow:"Glow",world:"World (grass & ores)"};var B3e=.1,D3e={mixed:["white_wool","cyan_wool","blue_wool","purple_wool","white_stained_glass","cyan_stained_glass","blue_stained_glass","purple_stained_glass","glowstone","sea_lantern","amethyst_block","copper_block","gold_block","diamond_block"],stainedGlass:["white_stained_glass","orange_stained_glass","magenta_stained_glass","light_blue_stained_glass","yellow_stained_glass","lime_stained_glass","pink_stained_glass","gray_stained_glass","light_gray_stained_glass","cyan_stained_glass","purple_stained_glass","blue_stained_glass","brown_stained_glass","green_stained_glass","red_stained_glass","black_stained_glass"],wool:["white_wool","orange_wool","magenta_wool","light_blue_wool","yellow_wool","lime_wool","pink_wool","gray_wool","light_gray_wool","cyan_wool","purple_wool","blue_wool","brown_wool","green_wool","red_wool","black_wool"],construction:["copper_block","exposed_copper","weathered_copper","oxidized_copper","cut_copper","exposed_cut_copper","weathered_cut_copper","oxidized_cut_copper","iron_block","gold_block","diamond_block","emerald_block","netherite_block","lapis_block","redstone_block","coal_block","quartz_block","amethyst_block","bricks","stone_bricks","deepslate_bricks","polished_blackstone"],glow:["glowstone","sea_lantern","shroomlight","ochre_froglight","verdant_froglight","pearlescent_froglight","redstone_lamp","beacon"],world:["grass_block","podzol","mycelium","dirt","coarse_dirt","rooted_dirt","mud","clay","stone","cobblestone","mossy_cobblestone","deepslate","cobbled_deepslate","tuff","calcite","sand","red_sand","gravel","snow_block","coal_ore","deepslate_coal_ore","iron_ore","deepslate_iron_ore","copper_ore","deepslate_copper_ore","gold_ore","deepslate_gold_ore","diamond_ore","deepslate_diamond_ore","emerald_ore","deepslate_emerald_ore","lapis_ore","deepslate_lapis_ore","redstone_ore","deepslate_redstone_ore","nether_gold_ore","ancient_debris","oak_log","birch_log","spruce_log","jungle_log","acacia_log","dark_oak_log","mangrove_log","cherry_log","netherrack","soul_sand","basalt","end_stone"]},O3e={galaxy:{bg:132114,fog:132114,fogD:.011,blocks:[61695,54527,47359,59647,2280703,43263],emit:[13158,8789,6724],nebula:[4403,1114146,4386],galFn:i=>new Fe(i*.05,i*.2,i),ambient:264216,dir:3368703,pt1:43775,pt2:16729343,name:"GALAXY"},nether:{bg:917760,fog:917760,fogD:.016,blocks:[16720384,16737792,16750848,13373696,16729122,16755200],emit:[2230272,1114112,3346688],nebula:[1704960,851968,1705984],galFn:i=>new Fe(i,i*.15,0),ambient:1573376,dir:16724736,pt1:16729088,pt2:16755200,name:"NETHER"},end:{bg:0,fog:0,fogD:.009,blocks:[7807658,11158732,5570679,14527231,3342421,12299007],emit:[655381,1572901,327696],nebula:[524312,851989,262158],galFn:i=>new Fe(i*.4,0,i),ambient:393232,dir:10040319,pt1:11158783,pt2:4456618,name:"THE END"},cyber:{bg:792610,fog:792610,fogD:.008,blocks:[65535,4521932,11206468,6741503,8978278,65450],emit:[666163,668450,665656],nebula:[1192e3,1587240,1323588],galFn:i=>new Fe(i*.15,i*.85,i*.95),ambient:1716288,dir:6750156,pt1:4521966,pt2:10092356,name:"CYBER",starColor:13431039,starOpacity:.75,galaxyOpacity:.62,nebulaOpacity:.36,edgeLineColor:4521949,blockOpacity:[.38,.54]},light:{bg:8951984,fog:7899296,fogD:.006,gradientBg:{top:14214392,mid:10531016,bottom:6846608,radial:!0},blocks:[15266559,13691135,12114175,10537208,8960240,7383272,10012927,12640511,15792383,7909608,14216447,14739711],emit:[6854864,8958176,11061488,12638456],nebula:[9480392,11059424,12637420,14215416,7901360],galFn:i=>{let e=new Fe;return i<.4?e.lerpColors(new Fe(16054527),new Fe(14215423),i/.4):i<.75?e.lerpColors(new Fe(14215423),new Fe(11061488),(i-.4)/.35):e.lerpColors(new Fe(11061488),new Fe(9482464),(i-.75)/.25),e},ambient:7899296,dir:13688040,pt1:11061503,pt2:13162751,name:"LIGHT",starColor:15266047,starOpacity:.5,galaxyOpacity:.7,nebulaOpacity:.32,edgeLineColor:10010856,blockOpacity:[.42,.56]}},FGe={cruise:{pos:(i,e,t)=>({x:Math.sin(i*.28)*18+Math.cos(i*.11)*7+e*10,y:Math.sin(i*.19)*6+Math.cos(i*.31)*3+t*6,z:0}),look:(i,e,t)=>({x:Math.sin((i+.18)*.28)*18+e*8,y:Math.sin((i+.18)*.19)*6+t*4,z:-25}),roll:(i,e=0)=>e*.05+Math.sin(i*.22)*.015,spd:.18},barrel:{pos:(i,e,t)=>{let r=i*2.4;return{x:Math.cos(r)*10+e*4,y:Math.sin(r)*10+t*4,z:Math.sin(i*.4)*8}},look:i=>({x:Math.sin(i*.5)*5,y:Math.cos(i*.5)*5,z:-30}),roll:i=>i*2.4+Math.PI*.5,spd:.24},dive:{pos:(i,e,t)=>({x:Math.sin(i*.6)*30+e*8,y:Math.cos(i*.4)*18+t*6,z:Math.sin(i*.3)*12}),look:(i,e,t)=>({x:Math.sin(i*.6+.2)*30+e*6,y:Math.cos(i*.4+.2)*18-8+t*4,z:-35}),roll:(i,e=0)=>e*.08+Math.sin(i*.6)*.12,spd:.3},orbit:{pos:(i,e,t)=>({x:Math.cos(i*.5)*20+e*5,y:Math.sin(i*.25)*10+t*5,z:Math.sin(i*.5)*20}),look:()=>({x:0,y:0,z:-60}),roll:i=>Math.sin(i*.5)*.08,spd:.15},snake:{pos:(i,e,t)=>({x:Math.sin(i*1.1)*22+Math.sin(i*.37)*8+e*10,y:Math.sin(i*.7)*10+e*4+t*8,z:0}),look:(i,e,t)=>{let n=i+.12;return{x:Math.sin(n*1.1)*22+Math.sin(n*.37)*8+e*8,y:Math.sin(n*.7)*10+t*6,z:-22}},roll:(i,e=0)=>e*.1+Math.sin(i*1.1)*.06,spd:.22}},zGe={cruise:1,barrel:1.6,dive:2.2,orbit:.7,snake:1.4},HGe=250,g4=1e4,_4=3e3,ah=i=>i[Math.floor(Math.random()*i.length)],$T=i=>"#"+i.toString(16).padStart(6,"0"),N3e=i=>{if(typeof document>"u")return null;let e=document.createElement("canvas");e.width=4,e.height=512;let t=e.getContext("2d");if(!t)return null;let n=e.width,r=e.height,s=i.radial?t.createRadialGradient(n/2,r*.32,0,n/2,r*.32,r*.85):t.createLinearGradient(0,0,0,r);s.addColorStop(0,$T(i.top)),i.mid!=null&&s.addColorStop(.45,$T(i.mid)),s.addColorStop(1,$T(i.bottom)),t.fillStyle=s,t.fillRect(0,0,n,r);let o=new mn(e);return o.needsUpdate=!0,o},lh=class{constructor(e,t={},n){this.documentRenderer=e;this.abortSignal=n;let r=nl;this.curScene=t.initialScene??r.v2Scene,this.curCam=t.initialCamera??r.v2Camera,this.blockGroup=t.initialBlockGroup??r.v2BlockGroup,this.cameraSpeed=t.initialCameraSpeed??h4.camera,this.blockSpeed=t.initialBlockSpeed??h4.block,this.useMinecraftTextures=t.useMinecraftTextures??r.minecraftTextures,this.resourcesManager=t.resourcesManager;let s=O3e[this.curScene];this.scene=new _r,this.scene.fog=new oa(s.fog,s.fogD),this.applyScenePalette(s),this.camera=new Yt(80,this.documentRenderer.canvas.width/this.documentRenderer.canvas.height,.1,700),this.ambient=new go(s.ambient,2.5),this.scene.add(this.ambient),this.dir=new ss(s.dir,4),this.dir.position.set(1,1,0),this.scene.add(this.dir),this.pt1=new va(s.pt1,5,100),this.scene.add(this.pt1),this.pt2=new va(s.pt2,4,80),this.pt2.position.set(30,20,-30),this.scene.add(this.pt2);for(let p=0;p<HGe;p++)this.spawnBlock(s,!0);if(!this.useMinecraftTextures){let p=s.edgeLineColor??62975;for(let v=0;v<40;v++){let _=new fn({color:p,transparent:!0,opacity:.25});ah(this.blocks).mesh.add(new Ln(this.eGeo,_))}}this.scene.add(this.bGroup);let o=new it,a=new Float32Array(5e3*3);for(let p=0;p<5e3*3;p++)a[p]=(Math.random()-.5)*500;o.setAttribute("position",new ht(a,3)),this.stars=new tr(o,new Lr({color:s.starColor??16777215,size:.3,transparent:!0,opacity:s.starOpacity??.7,sizeAttenuation:!0})),this.scene.add(this.stars),this.galGeo=new it;let l=new Float32Array(g4*3),c=new Float32Array(g4*3);for(let p=0;p<g4;p++){let v=p%3,_=Math.random(),b=v/3*Math.PI*2+_*Math.PI*5,y=_*90+Math.random()*10,g=(1-_)*18;l[p*3]=Math.cos(b)*y+(Math.random()-.5)*g,l[p*3+1]=(Math.random()-.5)*7,l[p*3+2]=Math.sin(b)*y+(Math.random()-.5)*g-180;let w=.2+_*.8,x=s.galFn(w);c[p*3]=x.r,c[p*3+1]=x.g,c[p*3+2]=x.b}this.galGeo.setAttribute("position",new ht(l,3)),this.galGeo.setAttribute("color",new ht(c,3)),this.galaxy=new tr(this.galGeo,new Lr({size:.9,vertexColors:!0,transparent:!0,opacity:s.galaxyOpacity??.55,sizeAttenuation:!0})),this.scene.add(this.galaxy),this.nebGeo=new it;let d=new Float32Array(_4*3),u=new Float32Array(_4*3);for(let p=0;p<_4;p++){let v=25+Math.random()*110,_=Math.random()*Math.PI*2,b=(Math.random()-.5)*Math.PI*.5;d[p*3]=v*Math.cos(_)*Math.cos(b),d[p*3+1]=v*Math.sin(b)*.6,d[p*3+2]=v*Math.sin(_)*Math.cos(b)-80;let y=new Fe(ah(s.nebula));u[p*3]=y.r,u[p*3+1]=y.g,u[p*3+2]=y.b}this.nebGeo.setAttribute("position",new ht(d,3)),this.nebGeo.setAttribute("color",new ht(u,3)),this.nebula=new tr(this.nebGeo,new Lr({size:3,vertexColors:!0,transparent:!0,opacity:s.nebulaOpacity??.3,sizeAttenuation:!0})),this.scene.add(this.nebula),this.addBackgroundTextPlane(),this.setupMouseTracking()}scene;camera;ambient;dir;pt1;pt2;blocks=[];bGroup=new at;galaxy;nebula;stars;galGeo;nebGeo;bGeo=new nn(1,1,1);eGeo=new Cl(this.bGeo);curScene;curCam;blockGroup;cameraSpeed;blockSpeed;camT=0;mx=0;my=0;tmx=0;tmy=0;transitioning=!1;useMinecraftTextures=!1;resourcesManager;atlasTexture=null;blockMaterialPool=new Map;gradientSky=null;gradientSkyTexture=null;disposed=!1;animTime=0;texturesApplied=!1;textureLoadInProgress=!1;onAssetsTexturesUpdated;async init(){this.useMinecraftTextures&&this.scheduleMinecraftTextureLoad()}scheduleMinecraftTextureLoad(){!this.useMinecraftTextures||this.disposed||this.texturesApplied||this.textureLoadInProgress||this.tryApplyMinecraftTextures()}attachAssetsListener(){let e=this.resourcesManager;!e||this.onAssetsTexturesUpdated||(this.onAssetsTexturesUpdated=()=>this.scheduleMinecraftTextureLoad(),e.on("assetsTexturesUpdated",this.onAssetsTexturesUpdated))}detachAssetsListener(){let e=this.resourcesManager;!e||!this.onAssetsTexturesUpdated||(e.off("assetsTexturesUpdated",this.onAssetsTexturesUpdated),this.onAssetsTexturesUpdated=void 0)}hasBlockAtlas(e){let t=e.currentResources;return!!(t?.blocksAtlasImage&&t.blocksAtlasJson)}async ensureAtlasReady(e){if(await this.ensureMcDataLoaded(),this.hasBlockAtlas(e))return!0;if(typeof document>"u"&&e!==this.resourcesManager)return!1;e.currentConfig={...e.currentConfig,version:l2,noInventoryGui:!0};try{await e.updateAssetsData?.({})}catch{return!1}return this.hasBlockAtlas(e)}async tryApplyMinecraftTextures(){if(!(this.disposed||!this.useMinecraftTextures||this.texturesApplied)){this.textureLoadInProgress=!0;try{let e=this.resourcesManager??new Ql;if(!await this.ensureAtlasReady(e)){this.resourcesManager&&this.attachAssetsListener();return}if(this.disposed)return;this.applyMinecraftTexturesFromAtlas(e),this.texturesApplied=!0,this.detachAssetsListener()}catch(e){console.warn("[V2MenuBackground] Failed to load Minecraft textures, using solid colors:",e),this.useMinecraftTextures=!1,this.detachAssetsListener()}finally{this.textureLoadInProgress=!1}}}applyScenePalette(e){if(this.documentRenderer.renderer.setClearColor(e.bg),e.gradientBg)if(this.scene.background=null,this.gradientSky){if(this.gradientSky.visible=!0,this.gradientSkyTexture&&e.gradientBg){let s=N3e(e.gradientBg);s&&(this.gradientSkyTexture.dispose(),this.gradientSkyTexture=s,this.gradientSky.material.map=s,this.gradientSky.material.needsUpdate=!0)}}else{let s=N3e(e.gradientBg);s?(this.gradientSkyTexture=s,this.gradientSky=new je(new _n(900,700),new st({map:s,depthWrite:!1,side:cn})),this.gradientSky.position.set(0,0,-280),this.gradientSky.renderOrder=-1e3,this.scene.add(this.gradientSky)):this.scene.background=new Fe(e.bg)}else this.scene.background=new Fe(e.bg),this.gradientSky&&(this.gradientSky.visible=!1);this.scene.fog instanceof oa&&(this.scene.fog.color.set(e.fog),this.scene.fog.density=e.fogD);let t=this.stars?.material;t&&(t.color.set(e.starColor??16777215),t.opacity=e.starOpacity??.7);let n=this.galaxy?.material;n&&(n.opacity=e.galaxyOpacity??.55);let r=this.nebula?.material;r&&(r.opacity=e.nebulaOpacity??.3)}setupMouseTracking(){let e=n=>{let r=typeof window<"u"?window.innerWidth:this.documentRenderer.canvas.width,s=typeof window<"u"?window.innerHeight:this.documentRenderer.canvas.height;this.tmx=(n.clientX/r-.5)*2,this.tmy=-(n.clientY/s-.5)*2};(typeof document<"u"?document:void 0)?.addEventListener("mousemove",e,{signal:this.abortSignal})}addBackgroundTextPlane(){let n=typeof document<"u"?document.createElement("canvas"):null;if(!n)return;n.width=2048,n.height=768;let r=n.getContext("2d");if(!r)return;r.clearRect(0,0,2048,768),r.save(),r.font="bold 560px Orbitron, sans-serif",r.textAlign="center",r.textBaseline="middle",r.shadowColor="rgba(0,200,255,0.35)",r.shadowBlur=80,r.fillStyle="rgba(255,255,255,0.055)",r.fillText("V2",2048*.28,768*.5),r.restore(),r.save(),r.font="bold 148px Orbitron, sans-serif",r.textAlign="center",r.textBaseline="middle",r.shadowColor="rgba(0,200,255,0.2)",r.shadowBlur=40,r.fillStyle="rgba(255,255,255,0.038)",r.fillText("by ZARDOY",2048*.72,768*.52),r.restore();let s=new mn(n),o=new je(new _n(280,105),new st({map:s,transparent:!0,opacity:1,depthWrite:!1,side:cn,blending:Pi}));o.position.set(8,4,-320),this.scene.add(o)}spawnBlock(e,t,n){let r=this.createBlockMaterial(e,n),s=new je(this.bGeo,r),o=.3+Math.random()*3;s.scale.setScalar(o),s.position.set((Math.random()-.5)*140,(Math.random()-.5)*70,t?-(Math.random()*140):-155-Math.random()*30),s.rotation.set(Math.random()*Math.PI*2,Math.random()*Math.PI*2,Math.random()*Math.PI*2);let a={mesh:s,spd:.04+Math.random()*.12,dx:(Math.random()-.5)*.012,dy:(Math.random()-.5)*.008,rx:(Math.random()-.5)*.012,ry:(Math.random()-.5)*.012,rz:(Math.random()-.5)*.01,minecraftBlockName:n};this.blocks.push(a),this.bGroup.add(s)}createBlockMaterial(e,t){if(this.useMinecraftTextures&&t){let s=this.blockMaterialPool.get(t);if(s)return s.clone()}let[n,r]=e.blockOpacity??[.32,.46];return new st({color:ah(e.blocks),transparent:!0,opacity:n+Math.random()*(r-n),depthWrite:!1,blending:Pi})}removeBlockEdgeLines(){for(let e of this.blocks){let t=e.mesh.children.filter(n=>n instanceof Ln);for(let n of t){e.mesh.remove(n),n.geometry?.dispose();let r=n.material;Array.isArray(r)?r.forEach(s=>s.dispose()):r.dispose()}}}async ensureMcDataLoaded(){let e=globalThis._LOAD_MC_DATA;e&&await e()}resolveBlockAtlasUv(e,t,n){let r=s=>{let o=t[s];return o?{u:o.u,v:o.v,su:o.su??n.suSv,sv:o.sv??n.suSv}:null};if(t[e])return r(e);for(let s of["_top","_side","_front","_0"]){let o=r(`${e}${s}`);if(o)return o}for(let s of Object.keys(t))if(s.startsWith(e))return r(s);return null}applyMinecraftTexturesFromAtlas(e){let t=e.currentResources;if(!t?.blocksAtlasImage||!t.blocksAtlasJson)throw new Error("Block atlas not available");let n=t.blocksAtlasJson,r=n.textures;this.atlasTexture=f0(t.blocksAtlasImage),this.atlasTexture.flipY=!1,this.atlasTexture.needsUpdate=!0;for(let s of D3e[this.blockGroup]){let o=this.resolveBlockAtlasUv(s,r,n);if(!o)continue;let a=this.atlasTexture.clone();a.flipY=!1,a.offset.set(o.u,o.v),a.repeat.set(o.su,o.sv),a.needsUpdate=!0;let l=s.includes("glass"),c=new st({map:a,side:cn,transparent:l,opacity:l?.85:1,alphaTest:l?.08:0,depthWrite:!0,toneMapped:!1});this.blockMaterialPool.set(s,c)}if(this.blockMaterialPool.size===0)throw new Error("No block textures resolved from atlas (check block names vs atlas keys)");this.removeBlockEdgeLines();for(let s of this.blocks){let o=ah([...this.blockMaterialPool.keys()]);s.minecraftBlockName=o,s.mesh.material=this.blockMaterialPool.get(o).clone()}}setScene(e){if(!ih.includes(e)||e===this.curScene||this.transitioning)return;this.transitioning=!0,this.curScene=e;let t=O3e[e];setTimeout(()=>{if(this.disposed)return;this.applyScenePalette(t),this.ambient.color.set(t.ambient),this.dir.color.set(t.dir),this.pt1.color.set(t.pt1),this.pt2.color.set(t.pt2);for(let s of this.blocks)this.useMinecraftTextures&&s.minecraftBlockName||s.mesh.material instanceof st&&s.mesh.material.color.set(ah(t.blocks));let n=this.nebGeo.attributes.color;for(let s=0;s<_4;s++){let o=new Fe(ah(t.nebula));n.setXYZ(s,o.r,o.g,o.b)}n.needsUpdate=!0;let r=this.galGeo.attributes.color;for(let s=0;s<g4;s++){let o=.2+Math.random()*.8,a=t.galFn(o);r.setXYZ(s,a.r,a.g,a.b)}r.needsUpdate=!0,this.transitioning=!1},150)}setCamera(e){sh.includes(e)&&(this.curCam=e)}setCameraSpeed(e){this.cameraSpeed=Math.max(0,e)}setBlockSpeed(e){this.blockSpeed=Math.max(0,e)}async setBlockGroup(e){if(oh.includes(e)&&e!==this.blockGroup&&(this.blockGroup=e,!(!this.useMinecraftTextures||this.disposed))){for(let t of this.blockMaterialPool.values())t.map?.dispose(),t.dispose();this.blockMaterialPool.clear(),this.texturesApplied=!1,this.scheduleMinecraftTextureLoad()}}getSceneId(){return this.curScene}getCameraId(){return this.curCam}getBlockGroupId(){return this.blockGroup}update(e,t){t&&bd(this.camera,this.documentRenderer.canvas);let n=FGe[this.curCam],r=this.cameraSpeed,s=this.blockSpeed;this.camT+=e*n.spd*r,this.mx+=(this.tmx-this.mx)*.05,this.my+=(this.tmy-this.my)*.05;let o=this.mx*B3e,a=this.my*B3e,l=n.pos(this.camT,o,a),c=n.look(this.camT,o,a);this.camera.position.set(l.x,l.y,l.z),this.camera.lookAt(c.x,c.y,c.z),this.camera.rotation.z=n.roll(this.camT,o);let d=zGe[this.curCam]*s;this.animTime+=e*1e3*s;for(let u of this.blocks){if(u.mesh.position.z+=u.spd*d*60*e,u.mesh.position.x+=u.dx*60*e*s,u.mesh.position.y+=u.dy*60*e*s,u.mesh.rotation.x+=u.rx*d,u.mesh.rotation.y+=u.ry*d,u.mesh.rotation.z+=u.rz,!this.useMinecraftTextures&&u.mesh.material instanceof st){let p=u.mesh.userData.baseOpacity??.38;u.mesh.userData.baseOpacity==null&&(u.mesh.userData.baseOpacity=p);let v=.88+Math.abs(Math.sin(this.animTime*8e-4+u.mesh.position.x*.3))*.12;u.mesh.material.opacity=p*v}u.mesh.position.z>this.camera.position.z+15&&u.mesh.position.set((Math.random()-.5)*140,(Math.random()-.5)*70,this.camera.position.z-155-Math.random()*30)}this.pt1.position.set(Math.sin(this.camT*.8)*25+this.camera.position.x,Math.cos(this.camT*.6)*12+this.camera.position.y,this.camera.position.z-18),this.pt2.position.set(Math.cos(this.camT*.5)*20+this.camera.position.x,Math.sin(this.camT*.9)*15+this.camera.position.y,this.camera.position.z-30),this.galaxy.rotation.y+=e*.006*s,this.nebula.rotation.y-=e*.003*s,this.stars.rotation.y+=e*4e-4*s}dispose(){this.disposed=!0,this.detachAssetsListener(),this.scene.clear(),this.bGeo.dispose(),this.eGeo.dispose(),this.galGeo.dispose(),this.nebGeo.dispose(),this.gradientSkyTexture?.dispose(),this.atlasTexture?.dispose();for(let e of this.blockMaterialPool.values())e.map?.dispose(),e.dispose();this.blockMaterialPool.clear()}};f();m();h();yt();f();m();h();var gge=Jr(G3e(),1),_ge=Jr(vge(),1);var yge=i=>{let e=(0,gge.default)(i),t=(0,_ge.default)(i),n=new e(i).sync,r=vje(n);for(let s of r)if(s.startsWith("set")&&s!=="setColumn"){let o=n[s].bind(n);n[s]=(...a)=>{let l=a[0];l.x!==void 0&&!n.getColumnAt(l)&&n.setColumn(Math.floor(l.x/16),Math.floor(l.z/16),new t(void 0)),o(...a)}}return n};function vje(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]}f();m();h();var bge={paused:!1,showChunkBorders:!1,enableDebugOverlay:!1,debugWasmPerf:!1,debugModelVariant:void 0,futuristicReveal:!1,wasmMesher:!0,shaderCubeBlocks:!1,shaderCubeDebugMode:0,mesherWorkers:1,addChunksBatchWaitTime:200,_experimentalSmoothChunkLoading:!0,_renderByChunks:!1,autoLowerRenderDistance:!1,disableMesherConversionCache:!1,dedicatedChangeWorker:!1,shadingTheme:"high-contrast",cardinalLight:"default",dayCycle:!0,smoothLighting:!0,enableLighting:!0,starfield:!0,defaultSkybox:!0,renderEntities:!0,extraBlockRenderers:!0,foreground:!0,fov:75,volume:1,showHand:!1,viewBobbing:!1,handRenderer:"vanilla",renderEars:!0,highlightBlockColor:"blue",fetchPlayerSkins:!0,skinTexturesProxy:void 0,vrSupport:!0,vrPageGameRendering:!0,clipWorldBelowY:void 0,isPlayground:!1,instantCameraUpdate:!1,isRaining:!1,moduleStates:{}};var KI=()=>({reactive:ba({world:{chunksLoaded:{},heightmaps:{},allChunksLoaded:!1,mesherWork:!1,instabilityFactors:UT(),intersectMedia:null},renderer:"...",preventEscapeMenu:!1}),nonReactive:{fps:0,worstRenderTime:0,avgRenderTime:0,world:{chunksLoadedCount:0,chunksTotalNumber:0,chunksFullInfo:"-"},renderer:{timeline:{live:[],frozen:[],lastSecond:[]}}}});f();m();h();f();m();h();f();m();h();Cs();var D2=i=>[Math.floor(i.x/16),Math.floor(i.z/16)];var gje=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)},bh=new WeakMap,V2=class V2 extends Nl{static restoreTransferred(e,t){let n=new V2;if(!t)return n;let r=bh.get(t);if(r)r.activeWorldView=n;else{let s=({data:o})=>{let l=bh.get(t)?.activeWorldView;!l||o?.class!==V2.restorerName||o.type==="event"&&l.emit(o.eventName,...o.args)};t.addEventListener("message",s),r={activeWorldView:n,handler:s},bh.set(t,r)}return n}static clearWorkerBridgeForTest(e){let t=bh.get(e);t&&(e.removeEventListener("message",t.handler),bh.delete(e))}static getWorkerBridgeListenerCountForTest(e){return bh.has(e)?1:0}};Cn(V2,"restorerName","WorldViewWorker");var xh=V2,s8=class extends Nl{constructor(t,n,r=new ut(0,0,0)){super();this.world=t;this.viewDistance=n;this.lastPos=new ut(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:xh.restorerName,type:"event",eventName:r,args:Z6(s)})}}return{__restorer:xh.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]=D2(t),o=Mp(this.viewDistance).map(([a,l])=>new ut((r+a)*16,0,(s+l)*16));this.lastPos.update(t),await this._loadChunks(o,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 o of Object.keys(this.waitingSpiralChunksLoad))this.waitingSpiralChunksLoad[o](!1),delete this.waitingSpiralChunksLoad[o];let s=!0;this.inLoading=!0,await gje(t,this.addWaitTime,async o=>{!s||this.loadedChunks[`${o.x},${o.z}`]||(this.world.getColumnAt(o)||(s=await new Promise(a=>{this.waitingSpiralChunksLoad[`${o.x},${o.z}`]=a})),s&&(await this.loadChunk(o,void 0,`spiral ${r} from ${n.x},${n.z}`),this.chunkProgress()))}),r===this.spiralNumber&&(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,o]=D2(this.lastPos),a=Math.abs(s-Math.floor(t.x/16)),l=Math.abs(o-Math.floor(t.z/16));if(a<=this.viewDistance&&l<=this.viewDistance){let c=await this.world.getColumnAt(t.y!==void 0?t:new ut(t.x,0,t.z));if(c){let d=c.toJson(),u={minY:c.minY??0,worldHeight:c.worldHeight??256};this.emit("loadChunk",{x:t.x,z:t.z,chunk:d,blockEntities:c.blockEntities,worldConfig:u,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:d.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,o){if(typeof s!="string")return;let[a,l,c]=s.split(",").map(Number);return t.world.getBlock(new ut(a,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,o]=D2(this.lastPos),[a,l]=D2(t);if(s!==a||o!==l||n){this.emit("chunkPosUpdate",{pos:t});let c=[],d=n?this.viewDistance:this.viewDistance+this.keepChunksDistance;for(let p of Object.keys(this.loadedChunks)){let[v,_]=p.split(",").map(Number),b=new ut(v,0,_),[y,g]=D2(b),w=Math.abs(a-y),x=Math.abs(l-g);(w>d||x>d)&&c.push(b)}for(let p of c)this.unloadChunk(p);let u=Mp(this.viewDistance).map(([p,v])=>{let _=new ut((a+p)*16,0,(l+v)*16);if(!this.loadedChunks[`${_.x},${_.z}`])return _}).filter(p=>!!p);this.lastPos.update(t),this._loadChunks(u,t)}else this.emit("chunkPosUpdate",{pos:t}),this.lastPos.update(t)}};var U2=class{constructor(e,t,n){this.documentRenderer=e;this.options=t;this.abortSignal=n;this._scene=new _r,this._scene.background=new Fe(3294568),this._camera=new Yt(85,e.canvas.width/e.canvas.height,.05,1e3),this.camera.position.set(0,0,0),this.camera.rotation.set(0,0,0)}_scene;_camera;get scene(){return this._scene}get camera(){return this._camera}worldRenderer;WorldRendererClass=yd;async init(){let e=l2,t=new Ql;if(t.currentConfig={version:e,noInventoryGui:!0},await t.updateAssetsData?.({}),this.abortSignal.aborted)return;console.time("load menu background scene");let n=yge(e),s=oi()(e),a=globalThis.mcData.blocksArray.filter(v=>{if(!v.name.includes("stained_glass"))return!1;let _=s.fromStateId(v.defaultState,0);if(_.shapes?.length!==1)return!1;let b=_.shapes[0];return b[0]===0&&b[1]===0&&b[2]===0&&b[3]===1&&b[4]===1&&b[5]===1}),l=-15,c=100,d=100;for(let v=-c;v<c;v++)for(let _=-d;_<d;_++){let b=a[Math.floor(Math.random()*a.length)];n.setBlockStateId(new ut(v,_,l),b.defaultState)}this._camera.updateProjectionMatrix(),this._camera.position.set(.5,d/2+.5,.5),this._camera.rotation.set(0,0,0);let u=new ut(...this._camera.position.toArray()),p=new s8(n,2,u);this.abortSignal.aborted||(this.worldRenderer=new this.WorldRendererClass(this.documentRenderer.renderer,this.options,{version:e,worldView:p,inWorldRenderingConfig:bge,playerStateReactive:Ohe().reactive,rendererState:KI().reactive,nonReactiveState:KI().nonReactive,resourcesManager:t}),this.worldRenderer instanceof yd&&(this._scene=this.worldRenderer.realScene,this._camera=this.worldRenderer.camera),p.init(u),await this.worldRenderer.waitForChunksToRender(),!this.abortSignal.aborted&&(this.setupMouseParallax(),console.timeEnd("load menu background scene")))}update(e,t){t&&bd(this.camera,this.documentRenderer.canvas)}dispose(){this.worldRenderer?.destroy(),this.worldRenderer=void 0,this._scene.clear()}setupMouseParallax(){let e=this._camera,t=e.position.x,n=e.position.y,r;document.body.addEventListener("pointermove",s=>{if(s.pointerType!=="mouse")return;let o=.2,a=s.clientX/window.innerWidth-.5,l=-(s.clientY/window.innerHeight-.5);r?.stop(),r=new br(e.position).to({x:t+a*o,y:n+l*o},0),r.start(),e.updateProjectionMatrix()},{signal:this.abortSignal})}};f();m();h();yt();var F2=class{constructor(e,t,n={},r=!1){this.documentRenderer=e;this.options=t;this.mode=qT(n,r)}active;abortController=new AbortController;mode;lastFrameTime=0;get v2(){return this.active instanceof lh?this.active:void 0}get scene(){return this.active?.scene}get camera(){return this.active?.camera}async start(e={}){this.active=this.createImplementation(e),await this.active.init(),this.active.scene.background instanceof Fe&&this.documentRenderer.renderer.setClearColor(this.active.scene.background),this.lastFrameTime=performance.now(),this.documentRenderer.render=(t=!1)=>{let n=performance.now(),r=Math.min((n-this.lastFrameTime)/1e3,.05);this.lastFrameTime=n;let s=this.active;s&&(s.update(r,t),this.documentRenderer.renderer.render(s.scene,s.camera))}}createImplementation(e){switch(this.mode){case"v2":return new lh(this.documentRenderer,{useMinecraftTextures:e.useMinecraftTextures,initialScene:e.v2Scene,initialCamera:e.v2Camera,initialBlockGroup:e.v2BlockGroup,initialCameraSpeed:e.v2CameraSpeed,initialBlockSpeed:e.v2BlockSpeed,resourcesManager:e.resourcesManager},this.abortController.signal);case"worldBlocks":return new U2(this.documentRenderer,this.options,this.abortController.signal);default:return new c2(this.documentRenderer)}}dispose(){this.active?.dispose(),this.active=void 0,this.abortController.abort()}};f();m();h();var Dd=nl,_je={rendererWorldPerformance:"normal",rendererMeshersCountOverride:null,starfieldRendering:!0,defaultSkybox:!0,menuBackgroundMode:Dd.mode,menuBackgroundMinecraftTextures:Dd.minecraftTextures,menuBackgroundV2Scene:Dd.v2Scene,menuBackgroundV2Camera:Dd.v2Camera,menuBackgroundV2BlockGroup:Dd.v2BlockGroup,menuBackgroundV2CameraSpeed:Dd.v2CameraSpeedPercent,menuBackgroundV2BlockSpeed:Dd.v2BlockSpeedPercent,rendererFuturisticReveal:!1,rendererPerfDebugOverlay:!1,disableBlockEntityTextures:!1,rendererMesher:"wasm",rendererShaderCubeBlocks:!1,rendererShaderCubeDebugMode:"off",showChunkBorders:!1,renderEntities:!0,renderDebug:"basic",frameLimit:!1,backgroundRendering:"20fps",vanillaLook:!1,smoothLighting:!0,newVersionsLighting:!1,vrSupport:!0,vrPageGameRendering:!1,clipWorldBelowY:void 0,highlightBlockColor:"auto",loadPlayerSkins:!0,renderEars:!0,showHand:!0,viewBobbing:!0,dayCycleAndLighting:!0,keepChunksDistance:1,gpuPreference:"default",fov:75};var yje={menuBackgroundMode:{possibleValues:[["classic","Classic"],["v2","V2"]],requiresRestart:!0},menuBackgroundMinecraftTextures:{text:"Minecraft block textures",tooltip:"Use block atlas on V2 menu cubes (loads assets on menu)"},menuBackgroundV2Scene:{possibleValues:ih.map(i=>[i,m4[i]])},menuBackgroundV2Camera:{possibleValues:sh.map(i=>[i,p4[i]])},menuBackgroundV2BlockGroup:{possibleValues:oh.map(i=>[i,v4[i]]),text:"Block pool",tooltip:"Block set for textured menu cubes (requires Minecraft textures)"},menuBackgroundV2CameraSpeed:{text:"Camera speed",tooltip:"Orbit / fly-through camera path speed. 0 freezes the path; mouse parallax still works.",min:0,max:200,unit:"%"},menuBackgroundV2BlockSpeed:{text:"Block speed",tooltip:"Floating blocks and sky rotation. Independent of camera path speed.",min:0,max:200,unit:"%"},rendererWorldPerformance:{text:"World performance",tooltip:"Background workers for chunk geometry. Reload to apply.",requiresRestart:!0,possibleValues:[["low-energy","Low Energy"],["normal","Normal"],["maximum","Maximum"]]},starfieldRendering:{text:"Starfield"},defaultSkybox:{text:"Default skybox"},rendererFuturisticReveal:{text:"Futuristic world reveal"},rendererPerfDebugOverlay:{text:"Performance debug overlay"},disableBlockEntityTextures:{text:"Disable block entity textures",tooltip:"Skips signs, banners, heads, maps, etc."},rendererMesher:{possibleValues:[["wasm","WASM"],["legacy-js","Legacy JS"]],text:"Mesher pipeline",tooltip:"WASM is faster. Use JS if WASM is not working. Requires reload.",requiresRestart:!0},rendererShaderCubeBlocks:{text:"(UNSTABLE) Instanced shader cubes",tooltip:"Render full blocks through the global GPU instanced path. Requires WASM mesher and WebGL2.",requiresChunksReload:!0},rendererShaderCubeDebugMode:{text:"Shader cube debug",tooltip:"Instanced cube path visualization (requires shader cubes enabled).",possibleValues:[["off","Off"],["holes","Hole test (red)"],["texIndex","Tile index colors"],["faces","Face id colors"],["atlasAlpha","Atlas alpha"]]},showChunkBorders:{text:"Chunk borders"},renderEntities:{text:"Render entities"},renderDebug:{possibleValues:["advanced","basic","none"]},frameLimit:{text:"Frame limit",tooltip:"false = VSync / unlimited when focused"},backgroundRendering:{text:"Background FPS limit",possibleValues:[["full","NO"],["5fps","5 FPS"],["20fps","20 FPS"]]},vanillaLook:{text:"Vanilla shading",tooltip:"On: Minecraft-style face shading. Off: higher-contrast client shading."},smoothLighting:{},newVersionsLighting:{text:"Lighting in newer versions"},vrSupport:{text:"VR support",tooltip:"Shows VR entry; does not force VR on."},vrPageGameRendering:{text:"VR page game rendering"},clipWorldBelowY:{text:"Clip world below Y"},highlightBlockColor:{possibleValues:[["auto","Auto"],["blue","Blue"],["classic","Classic"]]},loadPlayerSkins:{},renderEars:{tooltip:"Deadmau5 ears when the skin texture includes them"},showHand:{},viewBobbing:{},dayCycleAndLighting:{text:"Day cycle"},keepChunksDistance:{text:"Keep chunks distance",tooltip:"Extra distance before unloading chunks",max:5,unit:""},fov:{min:30,max:110,unit:"\xB0",text:"FOV"},gpuPreference:{text:"GPU preference",tooltip:"WebGL power preference. Requires reload / backend restart to apply.",requiresRestart:!0,possibleValues:[["default","Auto"],["high-performance","Dedicated"],["low-power","Low power"]]}};hi.enabled=!1;globalThis.THREE=Lt;var xge=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),spawnBlockBreakParticles(e,t,n,r,s,o){i.getModule("blockBreakParticles")?.spawnBlockBreakParticles(e,t,n,r,s,o)},spawnBlockCrackParticle(e,t,n,r,s,o,a){i.getModule("blockBreakParticles")?.spawnCrackParticle(e,t,n,r,s,o,a)},async loadGeometryExport(e){let{applyWorldGeometryExport:t}=await Promise.resolve().then(()=>(kT(),a3e));return t(i,e)},feedChunkPacket(e){let{kind:t,...n}=e,r={type:t,...n};for(let s of i.workers)s.postMessage(r)},getChunksDebugState(){let e={};for(let t of Object.keys(i.sectionObjects)){let[n,,r]=t.split(",").map(Number);e[`${n},${r}`]=!0}return{loadedSectionsChunks:e,loadedChunks:{...i.loadedChunks},finishedChunks:{...i.finishedChunks}}}}),bje=[],o8=(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)}},wge=()=>{let i,e=null,t=null,n=null,r=null,s=(d,u)=>{dn?i=R5(d,bje,globalThis):i=d,e=new K6(i,u?.canvas),globalThis.renderer=e.renderer,globalThis.documentRenderer=e,globalThis.threeJsBackend=c,o8("default",c)},o=async d=>{if(!e)throw new Error("Document renderer not initialized");n&&(n.destroy(),n=null,r=null,globalThis.world=void 0,globalThis.frameTimingCollector=void 0),t&&(t.dispose(),t=null);let u={...i.config.menuBackground,...d};t=new F2(e,{...i},u,!!process.env.SINGLE_FILE_BUILD_MODE),o8("menuBackgroundCreated",t),await t.start(u),o8("menuBackgroundReady",t)},a=async d=>{if(!e)throw new Error("Document renderer not initialized");t&&(t.dispose(),t=null),n&&(n.destroy(),n=null,r=null,globalThis.world=void 0,globalThis.frameTimingCollector=void 0);let p=dn?R5(d,[Ql,xh],globalThis):d;e.nonReactiveState=p.nonReactiveState,globalThis.resourcesManager=p.resourcesManager,n=new yd(e.renderer,i,p),await n.worldReadyPromise,r=p.inWorldRenderingConfig.enableDebugOverlay?new eg(p.nonReactiveState):null,globalThis.frameTimingCollector=r;let v=e.render;e.render=function(_){v.call(this,_),r?.markFrameStart(),p.inWorldRenderingConfig.paused||n?.render(_),r?.markFrameEnd(),r?.markFrameDisplay()},e.inWorldRenderingConfig=p.inWorldRenderingConfig,globalThis.world=n,o8("worldReady",n)},l=()=>{t&&(t.dispose(),t=null),e&&e.dispose(),n&&(n.destroy(),n=null)},c={id:"threejs",displayName:`three.js ${bo}`,startMenuBackground:o,startWorld:a,disconnect:l,setRendering(d){e.setPaused(!d),n&&(n.renderingActive=d)},getMenuBackground:()=>t??void 0,getDebugOverlay:()=>({get entitiesString(){return n?.entities.getDebugString()},get left(){return{"Geo Memory":n?.chunkMeshManager.getEstimatedMemoryUsage().total??"-"}}}),updateCamera(d,u,p){r?.markCameraUpdate(!d),n?.setFirstPersonCamera(d,u,p)},get soundSystem(){return n?.soundSystem},get backendMethods(){if(n)return xge(n)}};return{main:{init:s,backend:c},workerProxy(){return yB({init(d,u){s(d,{canvas:u})},updateSizeExternal(d,u,p){e?.updateSizeExternal(d,u,p)},startMenuBackground:o,startWorld:a,disconnect:l,setRendering:c.setRendering,updateCamera(d,u,p){let v=d?new ut(d.x,d.y,d.z):null;r?.markCameraUpdate(!v),c.updateCamera(v,u,p)},async callBackendMethod(d,...u){if(!n)throw new Error("World renderer not initialized");let v=xge(n)[d];if(!v)throw new Error(`Backend method ${String(d)} is unavailable`);return v(...u)}})}}};globalThis.structuredClone??=i=>JSON.parse(JSON.stringify(i));var Ege=i=>{AC(i);let e=globalThis;e.mcData=i,e.loadedData=i,self.postMessage({type:"mcDataApplied"})};self.addEventListener("message",i=>{let e=i.data;if(e.type==="mcData"){Ege(e.mcData),console.log("data loaded");return}Array.isArray(e)&&e.forEach(t=>{t.type==="mcData"&&Ege(t.mcData)})});var xje=wge();xje.workerProxy();})();
|
|
28833
28833
|
/*! Bundled license information:
|
|
28834
28834
|
|
|
28835
28835
|
@jspm/core/nodelibs/browser/chunk-DtuTasat.js:
|
package/package.json
CHANGED
|
@@ -197,7 +197,7 @@ export const RENDERER_OPTIONS_META: Partial<Record<RendererDefaultOptionKey, Ren
|
|
|
197
197
|
requiresRestart: true
|
|
198
198
|
},
|
|
199
199
|
rendererShaderCubeBlocks: {
|
|
200
|
-
text: 'Instanced shader cubes',
|
|
200
|
+
text: '(UNSTABLE) Instanced shader cubes',
|
|
201
201
|
tooltip: 'Render full blocks through the global GPU instanced path. Requires WASM mesher and WebGL2.',
|
|
202
202
|
requiresChunksReload: true,
|
|
203
203
|
},
|
|
@@ -152,8 +152,9 @@ export const createGraphicsBackendOffThread: GraphicsBackendLoader = async (init
|
|
|
152
152
|
return backend
|
|
153
153
|
}
|
|
154
154
|
createGraphicsBackendOffThread.id = 'threejs-off-thread'
|
|
155
|
-
createGraphicsBackendOffThread.displayName = 'three.js Multi-thread'
|
|
155
|
+
createGraphicsBackendOffThread.displayName = 'three.js Multi-thread EXPERIMENTAL'
|
|
156
156
|
createGraphicsBackendOffThread.description = [
|
|
157
|
+
'(UNSTABLE, DO NOT USE ON ANDROID).',
|
|
157
158
|
'Edge-cutting technology that uses a dedicated thread for graphics.',
|
|
158
159
|
'Slightly higher power and RAM usage.',
|
|
159
160
|
'More stable FPS (mid-range devices), but possible inputlag if TPS is low.',
|
|
@@ -19,7 +19,7 @@ const createGraphicsBackendSingleThread: GraphicsBackendLoader = (initOptions: G
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
createGraphicsBackendSingleThread.id = 'threejs'
|
|
22
|
-
createGraphicsBackendSingleThread.displayName = 'three.js Blocking'
|
|
22
|
+
createGraphicsBackendSingleThread.displayName = 'three.js Blocking Beta'
|
|
23
23
|
createGraphicsBackendSingleThread.description = 'Simple, old and stable main thread graphics backend providing balanced performance on top of WebGL2.'
|
|
24
24
|
|
|
25
25
|
export default createGraphicsBackendSingleThread
|