minecraft-renderer 0.1.68 → 0.1.69
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.
|
@@ -21506,7 +21506,7 @@ void main() {
|
|
|
21506
21506
|
|
|
21507
21507
|
#include <tonemapping_fragment>
|
|
21508
21508
|
#include <${r9>=154?"colorspace_fragment":"encodings_fragment"}>
|
|
21509
|
-
}`})}},vn=class{constructor(e){this.worldRenderer=e;d(this,"points");d(this,"clock",new Te.Clock);d(this,"enabled",!1);d(this,"currentTime");d(this,"enablementCheck",()=>this.currentTime?this.currentTime>13500&&this.currentTime<23e3:!1);d(this,"render",e=>{this.points&&(this.points.position.set(0,0,0),this.points.material.uniforms.time.value=this.clock.getElapsedTime()*.2)})}enable(){this.enabled||(this.enabled=!0,this.updateVisibility())}disable(){this.enabled&&(this.enabled=!1,this.removeStars())}toggle(){return this.enabled?this.disable():this.enable(),this.enabled}updateTimeOfDay(e){this.currentTime=e,this.enabled&&this.updateVisibility()}updateVisibility(){if(!this.enabled)return;let e=this.enablementCheck?.()??!1;e&&!this.points?this.createStars():!e&&this.points&&this.removeStars()}createStars(){if(this.points)return;let e=80,t=50,r=7e3,i=7,s=10,o=new Te.BufferGeometry,a=y=>new Te.Vector3().setFromSpherical(new Te.Spherical(y,Math.acos(1-Math.random()*2),Math.random()*2*Math.PI)),v=[],l=[],c=Array.from({length:r},()=>(.5+.5*Math.random())*i),u=new Te.Color,h=e+t,p=t/r;for(let y=0;y<r;y++)h-=p*Math.random(),v.push(...a(h).toArray()),u.setHSL(y/r,s,.9),l.push(u.r,u.g,u.b);o.setAttribute("position",new Te.Float32BufferAttribute(v,3)),o.setAttribute("color",new Te.Float32BufferAttribute(l,3)),o.setAttribute("size",new Te.Float32BufferAttribute(c,1));let g=new an;g.blending=Te.AdditiveBlending,g.depthTest=!0,g.depthWrite=!1,g.transparent=!0,this.points=new Te.Points(o,g),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)}},Ha={id:"starfield",controller:vn,enabledDefault:!0,cannotBeDisabled:!0};var Oa={starfield:Ha,futuristicReveal:Ia,rain:Ba,cameraBobbing:Ta,blockBreakParticles:ka};var yt=class yt extends g1{constructor(t,r,i){if(!i.resourcesManager)throw new Error("resourcesManager is required in displayOptions");super(i.resourcesManager,i,r);this.renderer=t;this.initOptions=r;this.displayOptions=i;d(this,"outputFormat","threeJs");d(this,"chunkMeshManager");d(this,"chunkTextures",new Map);d(this,"signsCache",new Map);d(this,"cameraSectionPos",new G0(0,0,0));d(this,"holdingBlock");d(this,"holdingBlockLeft");d(this,"scene",new Q.Scene);d(this,"ambientLight",new Q.AmbientLight(13421772));d(this,"directionalLight",new Q.DirectionalLight(16777215,.5));d(this,"entities",new z1(this,globalThis.mcData));d(this,"performanceMonitor");d(this,"cameraGroupVr");d(this,"material",new Q.MeshBasicMaterial({vertexColors:!0,transparent:!0,alphaTest:.1}));d(this,"itemsTexture");d(this,"cursorBlock");d(this,"onRender",[]);d(this,"lastRenderTime",0);d(this,"animatedFov",0);d(this,"lastFovAnimTime",0);d(this,"cameraShake");d(this,"cameraContainer");d(this,"media");d(this,"waypoints");d(this,"cinimaticScript");d(this,"camera");d(this,"renderTimeAvg",0);d(this,"pendingSectionUpdates",new Map);d(this,"pendingSectionBufferStartTimes",new Map);d(this,"modules",{});d(this,"sectionsOffsetsAnimations",{});d(this,"fountains",[]);d(this,"fireworksLegacy");d(this,"DEBUG_RAYCAST",!1);d(this,"skyboxRenderer");d(this,"fireworks");d(this,"sceneOrigin",new Z1(this.scene));d(this,"cameraWorldPos",{x:0,y:0,z:0});d(this,"_cameraPositionAccessWarned",!1);d(this,"_tmpCameraPos",new Q.Vector3);d(this,"currentPosTween");d(this,"currentRotTween");d(this,"_tpDirection",new Q.Vector3);d(this,"_tpPitchQuat",new Q.Quaternion);d(this,"_tpYawQuat",new Q.Quaternion);d(this,"_tpFinalQuat",new Q.Quaternion);d(this,"_tpScenePos",new Q.Vector3);d(this,"_tpAxisX",new Q.Vector3(1,0,0));d(this,"_tpAxisY",new Q.Vector3(0,1,0));d(this,"_tpRaycaster",new Q.Raycaster);d(this,"_tpChunkWorldPos",new Q.Vector3);d(this,"debugOverlayAdded",!1);d(this,"debugRaycastHelper");d(this,"debugHitPoint");d(this,"prevFramePerspective",null);this.performanceMonitor=new l5(this.reactiveState.world.instabilityFactors),this.renderer=t;let s=yt.getRendererInfo(t)??"...";i.rendererState.renderer=s,this.chunkMeshManager=new Y5(this,this.scene,this.material,this.worldSizeParams.worldHeight,this.viewDistance),this.onRenderDistanceChanged=o=>{this.chunkMeshManager.updateViewDistance(o)},this.cursorBlock=new L1(this),this.holdingBlock=U5(this),this.holdingBlockLeft=U5(this,!0);for(let o of Object.values(Oa))this.registerModule(o);this.skyboxRenderer=new K1(this.realScene,!1,null),this.skyboxRenderer.init(),this.addDebugOverlay(),this.resetScene(),this.init(),this.soundSystem=new G1(this),this.cameraShake=new N1(this,this.onRender),this.media=new W1(this),this.fireworksLegacy=new Y1(this),this.waypoints=new j1(this),this.cinimaticScript=new Q1(this,(o,a,v)=>this.setCinimaticCamera(o,a,v),o=>this.setCinimaticFov(o),()=>({position:new G0(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 J1(this.realScene,this.sceneOrigin),this.renderUpdateEmitter.on("chunkFinished",o=>{this.finishChunk(o)}),this.worldSwitchActions(),this.initializeModules()}isShaderCubeBlocksEnabled(){return this.worldRendererConfig.shaderCubeBlocks===!0&&!!this.renderer?.capabilities?.isWebGL2}get sectionObjects(){return this.chunkMeshManager.sectionObjects}get realScene(){return this.scene}get waitingChunksToDisplay(){return this.chunkMeshManager.waitingChunksToDisplay}get estimatedMemoryUsage(){return this.chunkMeshManager.getEstimatedMemoryUsage().total}get tilesRendered(){return this.chunkMeshManager.getTotalTiles()}get blocksRendered(){return this.chunkMeshManager.getTotalBlocks()}registerModule(t){if(t.id in this.modules)return;let r=new t.controller(this),i={manifest:t,controller:r,enabled:!1,toggle:()=>this.toggleModule(t.id)};this.modules[t.id]=i,t.enabledDefault&&this.toggleModule(t.id,!0)}enableModule(t){let r=this.modules[t];r&&(r.enabled||(r.enabled=!0,r.controller.enable(),r.controller.render&&this.onRender.push(r.controller.render)))}disableModule(t){let r=this.modules[t];if(r&&!r.manifest.cannotBeDisabled&&r.enabled&&(r.enabled=!1,r.controller.disable(),r.controller.render)){let i=this.onRender.indexOf(r.controller.render);i>-1&&this.onRender.splice(i,1)}}toggleModule(t,r){let i=this.modules[t];if(!i)return!1;let s=r!==void 0?r:!i.enabled;if(s===i.enabled)return i.enabled;if(!s&&i.manifest.cannotBeDisabled)return!0;if(i.enabled=s,s)i.controller.enable(),i.controller.render&&!this.onRender.includes(i.controller.render)&&this.onRender.push(i.controller.render);else if(i.controller.disable(),i.controller.render){let o=this.onRender.indexOf(i.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,r=this,i=20,s=(v,l,c)=>Math.abs(v)>i||Math.abs(l)>i||Math.abs(c)>i,o=()=>{!r._cameraPositionAccessWarned&&typeof D<"u"},a=new Proxy(t,{set(v,l,c){return(l==="x"||l==="y"||l==="z")&&typeof c=="number"&&Math.abs(c)>i&&o(),v[l]=c,!0},get(v,l,c){let u=v[l];return l==="set"?function(h,p,g){return s(h,p,g)&&o(),v.set(h,p,g)}:l==="setX"||l==="setY"||l==="setZ"?function(h){return Math.abs(h)>i&&o(),v[l](h)}:l==="copy"?function(h){return s(h.x,h.y,h.z)&&o(),v.copy(h)}:typeof u=="function"?u.bind(v):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(){Ki(this,new Q.Vector3(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z),this.cameraShake.getBaseRotation(),"world-geometry.json")}updateEntity(t,r=!1){let i={rotation:{head:{x:t.headPitch??t.pitch,y:t.headYaw,z:0}}};r?this.entities.updateEntityPosition(t,!1,i):this.entities.update(t,i)}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 Q.Color(this.initOptions.config.sceneBackground),this.scene.add(this.ambientLight),this.directionalLight.position.set(1,1,.5).normalize(),this.directionalLight.castShadow=!0,this.scene.add(this.directionalLight);let t=this.renderer.getSize(new Q.Vector2);this.camera=new Q.PerspectiveCamera(75,t.x/t.y,.1,1e3),this._wrapCameraPositionWithWarning(),this.cameraContainer=new Q.Object3D,this.cameraContainer.add(this.camera),this.scene.add(this.cameraContainer)}watchReactivePlayerState(){super.watchReactivePlayerState(),this.onReactivePlayerStateUpdated("inWater",t=>{this.skyboxRenderer.updateWaterState(t,this.playerStateReactive.waterBreathing)}),this.onReactivePlayerStateUpdated("waterBreathing",t=>{this.skyboxRenderer.updateWaterState(this.playerStateReactive.inWater,t)}),this.onReactivePlayerStateUpdated("ambientLight",t=>{t&&(this.ambientLight.intensity=t)}),this.onReactivePlayerStateUpdated("directionalLight",t=>{t&&(this.directionalLight.intensity=t)}),this.onReactivePlayerStateUpdated("lookingAtBlock",t=>{this.cursorBlock.setHighlightCursorBlock(t?new G0(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 r=new G0(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z);this.updateCamera(r,this.cameraShake.getBaseRotation().yaw,this.cameraShake.getBaseRotation().pitch)})}watchReactiveConfig(){super.watchReactiveConfig(),this.onReactiveConfigUpdated("showChunkBorders",r=>{this.updateShowChunksBorder(r)}),this.onReactiveConfigUpdated("defaultSkybox",r=>{this.skyboxRenderer.updateDefaultSkybox(r)}),this.onReactiveConfigUpdated("shaderCubeDebugMode",()=>{this.chunkMeshManager.syncCubeShaderUniforms()}),this.onReactiveConfigUpdated("futuristicReveal",()=>{this.updateModulesFromConfig()});let t=this.displayOptions.inWorldRenderingConfig.handRenderer;this.onReactiveConfigUpdated("handRenderer",r=>{if(r===t)return;t=r;let i=this.holdingBlock.ready,s=this.holdingBlockLeft.ready;this.holdingBlock.dispose(),this.holdingBlockLeft.dispose(),this.holdingBlock=U5(this),this.holdingBlockLeft=U5(this,!0),i&&(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[r,i]of Object.entries(this.modules)){let s=t[r];if(s==="enabled"){i.enabled||this.toggleModule(r,!0);continue}if(s==="disabled"){i.enabled&&!i.manifest.cannotBeDisabled&&this.toggleModule(r,!1);continue}if(s==="auto"||s===void 0)if(i.controller.autoEnableCheck){let o=i.controller.autoEnableCheck();o&&!i.enabled?this.toggleModule(r,!0):!o&&i.enabled&&!i.manifest.cannotBeDisabled&&this.toggleModule(r,!1)}else{let o=i.manifest.enabledDefault??!1;o&&!i.enabled?this.toggleModule(r,!0):!o&&i.enabled&&!i.manifest.cannotBeDisabled&&this.toggleModule(r,!1)}}}changeHandSwingingState(t,r=!1){let i=r?this.holdingBlockLeft:this.holdingBlock;t?i.startSwing():i.stopSwing()}async updateAssetsData(){let t=this.resourcesManager.currentResources,r=this.material.map,i=this.itemsTexture,s=I0(t.blocksAtlasImage);s.needsUpdate=!0,s.flipY=!1,this.material.map=s,this.chunkMeshManager.syncCubeShaderUniforms();let o=I0(t.itemsAtlasImage);o.needsUpdate=!0,o.flipY=!1,this.itemsTexture=o,r&&r.dispose(),i&&i.dispose(),await super.updateAssetsData(),this.onAllTexturesLoaded(),Object.keys(this.loadedChunks).length>0&&this.rerenderAllChunks()}onAllTexturesLoaded(){this.holdingBlock.ready=!0,this.holdingBlock.updateItem(),this.holdingBlockLeft.ready=!0,this.holdingBlockLeft.updateItem()}changeBackgroundColor(t){this.realScene.background=new Q.Color(t[0],t[1],t[2])}changeCardinalLight(t){this.worldRendererConfig.cardinalLight=t}timeUpdated(t){let r=this.getModule("starfield");r?.updateTimeOfDay&&r.updateTimeOfDay(t),this.skyboxRenderer.updateTime(t)}biomeUpdated(t){t?.temperature!==void 0&&this.skyboxRenderer.updateTemperature(t.temperature)}biomeReset(){this.skyboxRenderer.updateTemperature(Gi)}getItemRenderData(t,r){return Z3(t,r,this.resourcesManager,this.playerStateReactive)}async demoModel(){let t=cursorBlockRel(0,1,0).position,r=await R5();Ps(r,t);let i=new Q.BoxHelper(r,16776960);r.add(i),this.realScene.add(r)}demoItem(){let t=cursorBlockRel(0,1,0).position,{mesh:r}=this.entities.getItemMesh({itemId:541},{});r.position.set(t.x+.5,t.y+.5,t.z+.5);let i=new Q.BoxHelper(r,16776960);r.add(i),this.realScene.add(r)}addDebugOverlay(){if(this.debugOverlayAdded)return;this.debugOverlayAdded=!0;let t=lt("debug-overlay",80,0,void 0,{className:vt});setInterval(()=>{if(t.setVisibility(this.displayAdvancedStats),this.displayAdvancedStats){let r=v=>new Intl.NumberFormat("en-US",{}).format(v),i=v=>new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1}).format(v),s="";s+=`TE: ${r(this.renderer.info.memory.textures)} `,s+=`F: ${i(this.tilesRendered)} `,s+=`B: ${i(this.blocksRendered)} `,s+=`MEM: ${this.chunkMeshManager.getEstimatedMemoryUsage().total} `;let o=this.chunkMeshManager.getStats();s+=`POOL: ${o.activeCount}/${o.poolSize} `;let a=Er(this.reactiveState.world.instabilityFactors);a&&(s+=`PF: ${a} `),t.updateText(s),this.backendInfoReport=s}},200)}updatePosDataChunk(t){let r=this.sectionObjects[t];if(!r)return;let[i,s,o]=t.split(",").map(c=>Math.floor(+c/16)),v=500-(Math.abs(i-this.cameraSectionPos.x)+Math.abs(s-this.cameraSectionPos.y)+Math.abs(o-this.cameraSectionPos.z)),l=r.mesh??r.shaderMesh??r.children.find(c=>c.name==="mesh"||c.name==="shaderMesh");l&&(l.renderOrder=v)}updateViewerPosition(t){this.viewerChunkPosition=t}cameraSectionPositionUpdate(){for(let t in this.sectionObjects)this.sectionObjects[t]&&this.updatePosDataChunk(t)}getDir(t,r){return t===r?0:t<r?1:-1}finishChunk(t){this.chunkMeshManager.finishChunkDisplay(t)}applyPendingSectionUpdates(){if(this.pendingSectionUpdates.size===0)return;let t=performance.now(),r=this.getSectionHeight(),i=[];for(let s of this.pendingSectionUpdates.keys()){let o=this.pendingSectionBufferStartTimes.get(s)??t;if(t-o<yt.MAX_SECTION_UPDATE_BUFFER_MS){let[v,l,c]=s.split(",").map(Number),u=[`${v-16},${l},${c}`,`${v+16},${l},${c}`,`${v},${l-r},${c}`,`${v},${l+r},${c}`,`${v},${l},${c-16}`,`${v},${l},${c+16}`],h=!1;for(let p of u)if(this.sectionsWaiting.has(p)&&!this.pendingSectionUpdates.has(p)&&this.sectionObjects[p]){h=!0;break}if(h)continue}i.push(s)}if(i.length!==0)for(let s of i){let o=this.pendingSectionUpdates.get(s);this.pendingSectionUpdates.delete(s),this.pendingSectionBufferStartTimes.delete(s);let a=o.key.split(","),v=`${a[0]},${a[2]}`;if(!this.loadedChunks[v]||!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,r){for(let i of[...this.pendingSectionUpdates.keys()])i.startsWith(`${t},`)&&i.endsWith(`,${r}`)&&(this.pendingSectionUpdates.delete(i),this.pendingSectionBufferStartTimes.delete(i))}handleWorkerMessage(t){if(t.type==="geometry"){let r=t.key.split(","),i=`${r[0]},${r[2]}`;if(!this.loadedChunks[i]||!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,r,i,s=!1){let o=Ht(t),a=this.chunkTextures.get(`${o[0]},${o[1]}`);a||(a={},this.chunkTextures.set(`${o[0]},${o[1]}`,a));let v=`${t.x},${t.y},${t.z}`;if(a[v])return a[v];let l=i9(this.version),c=m1(r,i,l);if(!c)return;let u=new Q.Texture(c);return u.magFilter=Q.NearestFilter,u.minFilter=Q.NearestFilter,u.needsUpdate=!0,a[v]=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 G0(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,r,i){let s=this.playerStateReactive.eyeHeight;this.updateCamera(t?.offset(0,s,0)??null,r,i),this.updateCameraSectionPos()}getThirdPersonCamera(t,r,i){t??(t=new Q.Vector3(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),v=this._tpPitchQuat.setFromAxisAngle(this._tpAxisX,i),l=this._tpYawQuat.setFromAxisAngle(this._tpAxisY,r),c=this._tpFinalQuat.multiplyQuaternions(l,v);a.applyQuaternion(c),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)),h=this._tpRaycaster;h.set(u,a),h.far=o;let p=80,g=p*p,y=t.x,A=t.y,b=t.z,w=[];for(let B of Object.values(this.sectionObjects)){if(B.name!=="chunk"||!B.visible||B.worldX===void 0)continue;let H=B.worldX-y,G=B.worldY-A,O=B.worldZ-b;if(H*H+G*G+O*O>g)continue;let j=B.children.find(J=>J.name==="mesh"||J.name==="shaderMesh");j&&w.push(j)}let S=h.intersectObjects(w,!1),C=o;S.length>0&&(C=Math.max(.5,S[0].distance-.2));let M=this.chunkMeshManager.raycastShaderSectionAABBs(t,a,C,p);return M!==void 0&&(C=Math.max(.5,M-.2)),new G0(t.x+a.x*C,t.y+a.y*C,t.z+a.z*C)}debugRaycast(t,r,i){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 Q.Vector3(this.sceneOrigin.toSceneX(t.x),this.sceneOrigin.toSceneY(t.y),this.sceneOrigin.toSceneZ(t.z));this.debugRaycastHelper=new Q.ArrowHelper(r.clone().normalize(),s,i,16711680,i*.1,i*.05),this.realScene.add(this.debugRaycastHelper);let o=new Q.SphereGeometry(.2,8,8),a=new Q.MeshBasicMaterial({color:65280});this.debugHitPoint=new Q.Mesh(o,a),this.debugHitPoint.position.copy(s).add(r.clone().multiplyScalar(i)),this.realScene.add(this.debugHitPoint)}setCinimaticCamera(t,r,i){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(i,r),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,r=this.playerStateReactive.fovMultiplier,i=t*(Number.isFinite(r)?r:1),s=performance.now();if(this.animatedFov===0&&(this.animatedFov=i),Math.abs(this.animatedFov-i)>=.01){let o=s-this.lastFovAnimTime,a=Math.min(o/yt.FOV_TRANSITION_MS,1),v=l=>1-(1-l)**3;this.animatedFov+=(i-this.animatedFov)*v(a),Math.abs(this.animatedFov-i)<.01&&(this.animatedFov=i)}else this.animatedFov=i;this.lastFovAnimTime=s,this.camera.fov!==this.animatedFov&&(this.camera.fov=this.animatedFov,this.camera.updateProjectionMatrix())}updateCamera(t,r,i){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 Oe(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&&r>Math.PI+a?o=-Math.PI*2:r<a&&s.yaw>Math.PI+a&&(o=Math.PI*2),this.currentRotTween?.stop(),this.currentRotTween=new Oe(s).to({pitch:i,yaw:r+o},100).onUpdate(v=>this.cameraShake.setBaseRotation(v.pitch,v.yaw-o)).start()}else{this.currentRotTween?.stop(),this.cameraShake.setBaseRotation(i,r);let{perspective:s}=this.playerStateReactive;if(s==="third_person_back"||s==="third_person_front"){let o=new Q.Vector3(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z),a=this.getThirdPersonCamera(o,r,i),v=o.distanceTo(new Q.Vector3(a.x,a.y,a.z)),l=s==="third_person_back"?v:-v;this.camera.position.set(0,0,l),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:r,chunksRenderDistanceOverride:i,chunksRenderAboveEnabled:s,chunksRenderBelowEnabled:o,chunksRenderDistanceEnabled:a}=this.reactiveDebugParams,v=this.getSectionHeight(),l=this.cameraSectionPos.y*v;if(this.displayOptions.inWorldRenderingConfig.enableDebugOverlay&&t!==void 0||r!==void 0||i!==void 0)for(let[c,u]of Object.entries(this.sectionObjects)){if(u._waitingForChunkDisplay)continue;let[h,p,g]=c.split(",").map(Number),y=s&&t!==void 0?p<=l+t:o&&r!==void 0?p>=l-r:a&&i!==void 0?Math.abs(p-l)<=i:!0;u.visible=y}else this.chunkMeshManager.updateSectionsVisibility()}render(t=!1){if(this.currentRenderedFrames++,this.reactiveDebugParams.stopRendering)return;this.debugChunksVisibilityOverride();let r=performance.now();this.lastRendered=performance.now();let i=this.lastRenderTime>0?Math.min(Math.max((r-this.lastRenderTime)/1e3,0),.1):1/60;this.lastRenderTime=r,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 Q.Vector2);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 Q.Group?this.cameraGroupVr.children.find(u=>u instanceof Q.PerspectiveCamera):this.camera;this.applyPendingSectionUpdates();let v=this.chunkMeshManager.globalBlockBuffer;v&&(v.setCameraOrigin(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z),v.compactStep(),v.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(i);let c=performance.now()-r;this.worldRendererConfig.autoLowerRenderDistance&&this.chunkMeshManager.recordRenderTime(c),this.renderTimeAvgCount++,this.renderTimeAvg=(this.renderTimeAvg*(this.renderTimeAvgCount-1)+c)/this.renderTimeAvgCount,this.renderTimeMax=Math.max(this.renderTimeMax,c),this.performanceMonitor.onFrame({totalMs:c,entitiesMs:o,loadedTextureCount:this.renderer.info.memory.textures,fps:this.lastFps})}renderHead(t,r,i,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 v=JSON.parse(z.from(o,"base64").toString()).textures?.SKIN?.url,{skinTexturesProxy:l}=this.worldRendererConfig;l&&(v=v?.replace("http://textures.minecraft.net/",l).replace("https://textures.minecraft.net/",l));let c=D0(this,v,F0.head),u=new Q.Group;return i&&c.position.set(0,.3125,.3125),c.position.y-=23/16,u.add(c),this.sceneOrigin.track(u),u.position.set(t.x+.5,t.y+.045,t.z+.5),u.rotation.set(0,-Q.MathUtils.degToRad(r*(i?90:45/2)),0),u.scale.set(.8,.8,.8),u}catch{}}renderSign(t,r,i,s,o){let a=this.getSignTexture(t,o,s);if(!a)return;let v=new Q.Mesh(new Q.PlaneGeometry(1,1),new Q.MeshBasicMaterial({map:a,transparent:!0}));v.renderOrder=999;let l=7/16,c=s?1.3:1;v.scale.set(1*c,l*c,1*c);let u=(s?2:1.5)/16,h=.25/16;i&&!s?v.position.set(0,0,-.5+u+h+1e-4):v.position.set(0,0,u/2+1e-4);let p=new Q.Group;p.rotation.set(0,-Q.MathUtils.degToRad(r*(i?90:45/2)),0),p.add(v);let g=(s?10:8)/16,y=(s?0:i?4.333:9.333)/16,A=g/2+y;return this.sceneOrigin.track(p),p.position.set(t.x+.5,t.y+A,t.z+.5),p}lightUpdate(t,r){for(let i=this.worldSizeParams.minY;i<this.worldSizeParams.worldHeight;i+=16)this.setSectionDirty(new G0(t,i,r))}rerenderAllChunks(){for(let t of Object.keys(this.sectionObjects)){let[r,i,s]=t.split(",").map(Number);this.setSectionDirty(new G0(r,i,s))}}updateShowChunksBorder(t){this.chunkMeshManager.updateAllBoxHelpers(t)}resetWorld(){super.resetWorld(),this.pendingSectionUpdates.clear(),this.pendingSectionBufferStartTimes.clear(),this.chunkMeshManager.dispose(),this.chunkMeshManager=new Y5(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,r=!1){let[i,s,o]=Qr(t);return Object.fromEntries(Object.entries(this.sectionObjects).map(([a,v])=>{let[l,c,u]=a.split(",").map(Number),[h,p,g]=Qr({x:l,y:c,z:u});return[r?`${h-i},${p-s},${g-o}`:`${h-i},${g-o}`,v]}))}cleanChunkTextures(t,r){let i=this.chunkTextures.get(`${Math.floor(t/16)},${Math.floor(r/16)}`)??{};for(let s of Object.keys(i))i[s].dispose(),delete i[s];this.chunkMeshManager.cleanSignChunkTextures(t,r)}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 r of t)r.matrixWorldNeedsUpdate=!1,this.disableUpdates(r.children??[])}removeColumn(t,r){super.removeColumn(t,r),this.cleanChunkTextures(t,r),this.clearPendingSectionUpdatesForChunk(t,r);let i=this.getSectionHeight(),s=this.worldMinYRender;for(let o=s;o<this.worldSizeParams.worldHeight;o+=i){let a=`${t},${o},${r}`;this.chunkMeshManager.sectionObjects[a]&&this.chunkMeshManager.releaseSection(a)}this.chunkMeshManager.onChunkRemovedFromGate(`${t},${r}`)}updateViewerPosition(t){super.updateViewerPosition(t),this.chunkMeshManager.pendingNearReveal.size>0&&this.chunkMeshManager.tryRevealPending()}onViewerChunkPositionChanged(){this.chunkMeshManager.tryRevealPending()}setSectionDirty(...t){let[r]=t;this.cleanChunkTextures(r.x,r.z),super.setSectionDirty(...t)}static getRendererInfo(t){try{let r=t.getContext();return`${r.getParameter(r.getExtension("WEBGL_debug_renderer_info").UNMASKED_RENDERER_WEBGL)}`}catch{}}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 i=this.getSectionHeight(),s,o,a,v=this.sceneOrigin.getWorldPosition(t);v?(s=v.x,o=v.y,a=v.z):(s=this.sceneOrigin.toWorldX(t.position.x),o=this.sceneOrigin.toWorldY(t.position.y),a=this.sceneOrigin.toWorldZ(t.position.z));let l=Math.floor(s/16)*16,c=Math.floor(a/16)*16,u=Math.floor(o/i)*i,h=`${l},${c}`,p=`${l},${u},${c}`;return!!this.finishedChunks[h]||!!this.sectionObjects[p]}handleUserClick(t){this.media.handleUserClick(t)}updateSectionOffsets(){let t=performance.now();for(let[r,i]of Object.entries(this.sectionsOffsetsAnimations)){let s=(t-i.time)/1e3;i.time=t,i.currentOffsetX+=i.speedX*s,i.currentOffsetY+=i.speedY*s,i.currentOffsetZ+=i.speedZ*s,i.limitX!==void 0&&(i.speedX>0?i.currentOffsetX=Math.min(i.currentOffsetX,i.limitX):i.currentOffsetX=Math.max(i.currentOffsetX,i.limitX)),i.limitY!==void 0&&(i.speedY>0?i.currentOffsetY=Math.min(i.currentOffsetY,i.limitY):i.currentOffsetY=Math.max(i.currentOffsetY,i.limitY)),i.limitZ!==void 0&&(i.speedZ>0?i.currentOffsetZ=Math.min(i.currentOffsetZ,i.limitZ):i.currentOffsetZ=Math.max(i.currentOffsetZ,i.limitZ));let o=this.sectionObjects[r];o&&(o.position.set(i.currentOffsetX,i.currentOffsetY,i.currentOffsetZ),o.updateMatrix())}}reloadWorld(){this.entities.reloadEntities()}};d(yt,"FOV_TRANSITION_MS",200),d(yt,"MAX_SECTION_UPDATE_BUFFER_MS",500);var _t=yt;E();x();k();R();E();x();k();R();var N0="1.21.4";E();x();k();R();function wt(n,e){n.aspect=e.width/e.height,n.updateProjectionMatrix()}E();x();k();R();function ln(n,e=!1){return n?.mode?n.mode:e?"worldBlocks":b0.mode}E();x();k();R();import*as ve from"three";E();x();k();R();function cn(...n){let e=n.filter(r=>r.length>0).join("/"),t=typeof globalThis.location<"u"&&globalThis.location.href?globalThis.location.href:typeof import.meta<"u"&&import.meta.url?import.meta.url:`/${e}`;try{return new URL(e,t).href}catch{return`/${e}`}}var dn=new Date,Da=dn.getMonth()===11&&dn.getDate()>=24&&dn.getDate()<=26,n9=["panorama_3.webp","panorama_1.webp","panorama_4.webp","panorama_5.webp","panorama_0.webp","panorama_2.webp"],s9=200,Xt=class{constructor(e){this.documentRenderer=e;d(this,"scene");d(this,"camera");d(this,"startTimes",new Map);d(this,"time",0);d(this,"panoramaGroup",null);this.scene=new ve.Scene,this.scene.background=new ve.Color(3294568);let t=new ve.AmbientLight(13421772);this.scene.add(t);let r=new ve.DirectionalLight(16777215,.5);r.position.set(1,1,.5).normalize(),r.castShadow=!0,this.scene.add(r),this.camera=new ve.PerspectiveCamera(85,e.canvas.width/e.canvas.height,.05,1e3),this.camera.position.set(0,0,0),this.camera.rotation.set(0,0,0)}async init(){this.buildCubemap()}update(e,t){t&&wt(this.camera,this.documentRenderer.canvas)}dispose(){this.scene.clear(),this.panoramaGroup=null,this.startTimes.clear()}buildCubemap(){let e=new ve.BoxGeometry(1e3,1e3,1e3),t=[];for(let s of n9)(async()=>{let a=cn("background",Da?"christmas":"",s),v=await st(a),l=I0(v);l.matrixAutoUpdate=!1,l.matrix.set(-1,0,1,0,1,0,0,0,1),l.wrapS=ve.ClampToEdgeWrapping,l.wrapT=ve.ClampToEdgeWrapping,l.minFilter=ve.LinearFilter,l.magFilter=ve.LinearFilter;let c=new ve.MeshBasicMaterial({map:l,transparent:!0,side:ve.DoubleSide,depthWrite:!1,opacity:0});this.startTimes.set(c,Date.now()),t.push(c)})().catch(a=>{});let r=new ve.Mesh(e,t);r.onBeforeRender=()=>{this.time+=.01,r.rotation.y=Math.PI+this.time*.01,r.rotation.z=Math.sin(-this.time*.001)*.001;for(let s of t){let o=this.startTimes.get(s);if(o){let a=Date.now()-o;s.opacity=Math.min(1,a/s9)}}};let i=new ve.Object3D;if(i.add(r),!Da)for(let s=0;s<20;s++){let o=new M0("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(r.rotation.y*3)*Math.PI/4-Math.PI/2},i.add(o)}this.scene.add(i),this.panoramaGroup=i}async debugImageInFrontOfCamera(){let e=await st(cn("background","panorama_0.webp")),t=I0(e),r=new ve.Mesh(new ve.PlaneGeometry(1e3,1e3),new ve.MeshBasicMaterial({map:t}));r.position.set(0,0,-500),this.scene.add(r)}};E();x();k();R();import*as W from"three";var Fa=.1,fn={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"]},za={galaxy:{bg:132114,fog:132114,fogD:.011,blocks:[61695,54527,47359,59647,2280703,43263],emit:[13158,8789,6724],nebula:[4403,1114146,4386],galFn:n=>new W.Color(n*.05,n*.2,n),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:n=>new W.Color(n,n*.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:n=>new W.Color(n*.4,0,n),ambient:393232,dir:10040319,pt1:11158783,pt2:4456618,name:"THE END"},cyber:{bg:2566,fog:2566,fogD:.01,blocks:[65535,65416,11206400,52479,6749952,65518],emit:[8721,6656,6690],nebula:[6674,5120,4634],galFn:n=>new W.Color(0,n,n*.6),ambient:6669,dir:65450,pt1:65484,pt2:4521728,name:"CYBER"},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:n=>{let e=new W.Color;return n<.4?e.lerpColors(new W.Color(16054527),new W.Color(14215423),n/.4):n<.75?e.lerpColors(new W.Color(14215423),new W.Color(11061488),(n-.4)/.35):e.lerpColors(new W.Color(11061488),new W.Color(9482464),(n-.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]}},o9={cruise:{pos:(n,e,t)=>({x:Math.sin(n*.28)*18+Math.cos(n*.11)*7+e*10,y:Math.sin(n*.19)*6+Math.cos(n*.31)*3+t*6,z:0}),look:(n,e,t)=>({x:Math.sin((n+.18)*.28)*18+e*8,y:Math.sin((n+.18)*.19)*6+t*4,z:-25}),roll:(n,e=0)=>e*.05+Math.sin(n*.22)*.015,spd:.18},barrel:{pos:(n,e,t)=>{let i=n*2.4;return{x:Math.cos(i)*10+e*4,y:Math.sin(i)*10+t*4,z:Math.sin(n*.4)*8}},look:n=>({x:Math.sin(n*.5)*5,y:Math.cos(n*.5)*5,z:-30}),roll:n=>n*2.4+Math.PI*.5,spd:.24},dive:{pos:(n,e,t)=>({x:Math.sin(n*.6)*30+e*8,y:Math.cos(n*.4)*18+t*6,z:Math.sin(n*.3)*12}),look:(n,e,t)=>({x:Math.sin(n*.6+.2)*30+e*6,y:Math.cos(n*.4+.2)*18-8+t*4,z:-35}),roll:(n,e=0)=>e*.08+Math.sin(n*.6)*.12,spd:.3},orbit:{pos:(n,e,t)=>({x:Math.cos(n*.5)*20+e*5,y:Math.sin(n*.25)*10+t*5,z:Math.sin(n*.5)*20}),look:()=>({x:0,y:0,z:-60}),roll:n=>Math.sin(n*.5)*.08,spd:.15},snake:{pos:(n,e,t)=>({x:Math.sin(n*1.1)*22+Math.sin(n*.37)*8+e*10,y:Math.sin(n*.7)*10+e*4+t*8,z:0}),look:(n,e,t)=>{let r=n+.12;return{x:Math.sin(r*1.1)*22+Math.sin(r*.37)*8+e*8,y:Math.sin(r*.7)*10+t*6,z:-22}},roll:(n,e=0)=>e*.1+Math.sin(n*1.1)*.06,spd:.22}},a9={cruise:1,barrel:1.6,dive:2.2,orbit:.7,snake:1.4},v9=250,dr=1e4,ur=3e3,$t=n=>n[Math.floor(Math.random()*n.length)],un=n=>"#"+n.toString(16).padStart(6,"0"),La=n=>{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 r=e.width,i=e.height,s=n.radial?t.createRadialGradient(r/2,i*.32,0,r/2,i*.32,i*.85):t.createLinearGradient(0,0,0,i);s.addColorStop(0,un(n.top)),n.mid!=null&&s.addColorStop(.45,un(n.mid)),s.addColorStop(1,un(n.bottom)),t.fillStyle=s,t.fillRect(0,0,r,i);let o=new W.CanvasTexture(e);return o.needsUpdate=!0,o},At=class{constructor(e,t={},r){this.documentRenderer=e;this.abortSignal=r;d(this,"scene");d(this,"camera");d(this,"ambient");d(this,"dir");d(this,"pt1");d(this,"pt2");d(this,"blocks",[]);d(this,"bGroup",new W.Group);d(this,"galaxy");d(this,"nebula");d(this,"stars");d(this,"galGeo");d(this,"nebGeo");d(this,"bGeo",new W.BoxGeometry(1,1,1));d(this,"eGeo",new W.EdgesGeometry(this.bGeo));d(this,"curScene");d(this,"curCam");d(this,"blockGroup");d(this,"cameraSpeed");d(this,"blockSpeed");d(this,"camT",0);d(this,"mx",0);d(this,"my",0);d(this,"tmx",0);d(this,"tmy",0);d(this,"transitioning",!1);d(this,"useMinecraftTextures",!1);d(this,"resourcesManager");d(this,"atlasTexture",null);d(this,"blockMaterialPool",new Map);d(this,"gradientSky",null);d(this,"gradientSkyTexture",null);d(this,"disposed",!1);d(this,"animTime",0);d(this,"texturesApplied",!1);d(this,"textureLoadInProgress",!1);d(this,"onAssetsTexturesUpdated");let i=b0;this.curScene=t.initialScene??i.v2Scene,this.curCam=t.initialCamera??i.v2Camera,this.blockGroup=t.initialBlockGroup??i.v2BlockGroup,this.cameraSpeed=t.initialCameraSpeed??b5.camera,this.blockSpeed=t.initialBlockSpeed??b5.block,this.useMinecraftTextures=t.useMinecraftTextures??i.minecraftTextures,this.resourcesManager=t.resourcesManager;let s=za[this.curScene];this.scene=new W.Scene,this.scene.fog=new W.FogExp2(s.fog,s.fogD),this.applyScenePalette(s),this.camera=new W.PerspectiveCamera(80,this.documentRenderer.canvas.width/this.documentRenderer.canvas.height,.1,700),this.ambient=new W.AmbientLight(s.ambient,2.5),this.scene.add(this.ambient),this.dir=new W.DirectionalLight(s.dir,4),this.dir.position.set(1,1,0),this.scene.add(this.dir),this.pt1=new W.PointLight(s.pt1,5,100),this.scene.add(this.pt1),this.pt2=new W.PointLight(s.pt2,4,80),this.pt2.position.set(30,20,-30),this.scene.add(this.pt2);for(let h=0;h<v9;h++)this.spawnBlock(s,!0);if(!this.useMinecraftTextures){let h=s.edgeLineColor??62975;for(let p=0;p<40;p++){let g=new W.LineBasicMaterial({color:h,transparent:!0,opacity:.25});$t(this.blocks).mesh.add(new W.LineSegments(this.eGeo,g))}}this.scene.add(this.bGroup);let o=new W.BufferGeometry,a=new Float32Array(5e3*3);for(let h=0;h<5e3*3;h++)a[h]=(Math.random()-.5)*500;o.setAttribute("position",new W.BufferAttribute(a,3)),this.stars=new W.Points(o,new W.PointsMaterial({color:s.starColor??16777215,size:.3,transparent:!0,opacity:s.starOpacity??.7,sizeAttenuation:!0})),this.scene.add(this.stars),this.galGeo=new W.BufferGeometry;let v=new Float32Array(dr*3),l=new Float32Array(dr*3);for(let h=0;h<dr;h++){let p=h%3,g=Math.random(),y=p/3*Math.PI*2+g*Math.PI*5,A=g*90+Math.random()*10,b=(1-g)*18;v[h*3]=Math.cos(y)*A+(Math.random()-.5)*b,v[h*3+1]=(Math.random()-.5)*7,v[h*3+2]=Math.sin(y)*A+(Math.random()-.5)*b-180;let w=.2+g*.8,S=s.galFn(w);l[h*3]=S.r,l[h*3+1]=S.g,l[h*3+2]=S.b}this.galGeo.setAttribute("position",new W.BufferAttribute(v,3)),this.galGeo.setAttribute("color",new W.BufferAttribute(l,3)),this.galaxy=new W.Points(this.galGeo,new W.PointsMaterial({size:.9,vertexColors:!0,transparent:!0,opacity:s.galaxyOpacity??.55,sizeAttenuation:!0})),this.scene.add(this.galaxy),this.nebGeo=new W.BufferGeometry;let c=new Float32Array(ur*3),u=new Float32Array(ur*3);for(let h=0;h<ur;h++){let p=25+Math.random()*110,g=Math.random()*Math.PI*2,y=(Math.random()-.5)*Math.PI*.5;c[h*3]=p*Math.cos(g)*Math.cos(y),c[h*3+1]=p*Math.sin(y)*.6,c[h*3+2]=p*Math.sin(g)*Math.cos(y)-80;let A=new W.Color($t(s.nebula));u[h*3]=A.r,u[h*3+1]=A.g,u[h*3+2]=A.b}this.nebGeo.setAttribute("position",new W.BufferAttribute(c,3)),this.nebGeo.setAttribute("color",new W.BufferAttribute(u,3)),this.nebula=new W.Points(this.nebGeo,new W.PointsMaterial({size:3,vertexColors:!0,transparent:!0,opacity:s.nebulaOpacity??.3,sizeAttenuation:!0})),this.scene.add(this.nebula),this.addBackgroundTextPlane(),this.setupMouseTracking()}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:N0,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 h0;if(!await this.ensureAtlasReady(e)){this.resourcesManager&&this.attachAssetsListener();return}if(this.disposed)return;this.applyMinecraftTexturesFromAtlas(e),this.texturesApplied=!0,this.detachAssetsListener()}catch{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=La(e.gradientBg);s&&(this.gradientSkyTexture.dispose(),this.gradientSkyTexture=s,this.gradientSky.material.map=s,this.gradientSky.material.needsUpdate=!0)}}else{let s=La(e.gradientBg);s?(this.gradientSkyTexture=s,this.gradientSky=new W.Mesh(new W.PlaneGeometry(900,700),new W.MeshBasicMaterial({map:s,depthWrite:!1,side:W.DoubleSide})),this.gradientSky.position.set(0,0,-280),this.gradientSky.renderOrder=-1e3,this.scene.add(this.gradientSky)):this.scene.background=new W.Color(e.bg)}else this.scene.background=new W.Color(e.bg),this.gradientSky&&(this.gradientSky.visible=!1);this.scene.fog instanceof W.FogExp2&&(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 r=this.galaxy?.material;r&&(r.opacity=e.galaxyOpacity??.55);let i=this.nebula?.material;i&&(i.opacity=e.nebulaOpacity??.3)}setupMouseTracking(){let e=r=>{let i=typeof window<"u"?window.innerWidth:this.documentRenderer.canvas.width,s=typeof window<"u"?window.innerHeight:this.documentRenderer.canvas.height;this.tmx=(r.clientX/i-.5)*2,this.tmy=-(r.clientY/s-.5)*2};(typeof document<"u"?document:void 0)?.addEventListener("mousemove",e,{signal:this.abortSignal})}addBackgroundTextPlane(){let r=typeof document<"u"?document.createElement("canvas"):null;if(!r)return;r.width=2048,r.height=768;let i=r.getContext("2d");if(!i)return;i.clearRect(0,0,2048,768),i.save(),i.font="bold 560px Orbitron, sans-serif",i.textAlign="center",i.textBaseline="middle",i.shadowColor="rgba(0,200,255,0.35)",i.shadowBlur=80,i.fillStyle="rgba(255,255,255,0.055)",i.fillText("V2",2048*.28,768*.5),i.restore(),i.save(),i.font="bold 148px Orbitron, sans-serif",i.textAlign="center",i.textBaseline="middle",i.shadowColor="rgba(0,200,255,0.2)",i.shadowBlur=40,i.fillStyle="rgba(255,255,255,0.038)",i.fillText("by ZARDOY",2048*.72,768*.52),i.restore();let s=new W.CanvasTexture(r),o=new W.Mesh(new W.PlaneGeometry(280,105),new W.MeshBasicMaterial({map:s,transparent:!0,opacity:1,depthWrite:!1,side:W.DoubleSide,blending:W.AdditiveBlending}));o.position.set(8,4,-320),this.scene.add(o)}spawnBlock(e,t,r){let i=this.createBlockMaterial(e,r),s=new W.Mesh(this.bGeo,i),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:r};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[r,i]=e.blockOpacity??[.32,.46];return new W.MeshBasicMaterial({color:$t(e.blocks),transparent:!0,opacity:r+Math.random()*(i-r),depthWrite:!1,blending:W.AdditiveBlending})}removeBlockEdgeLines(){for(let e of this.blocks){let t=e.mesh.children.filter(r=>r instanceof W.LineSegments);for(let r of t){e.mesh.remove(r),r.geometry?.dispose();let i=r.material;Array.isArray(i)?i.forEach(s=>s.dispose()):i.dispose()}}}async ensureMcDataLoaded(){let e=globalThis._LOAD_MC_DATA;e&&await e()}resolveBlockAtlasUv(e,t,r){let i=s=>{let o=t[s];return o?{u:o.u,v:o.v,su:o.su??r.suSv,sv:o.sv??r.suSv}:null};if(t[e])return i(e);for(let s of["_top","_side","_front","_0"]){let o=i(`${e}${s}`);if(o)return o}for(let s of Object.keys(t))if(s.startsWith(e))return i(s);return null}applyMinecraftTexturesFromAtlas(e){let t=e.currentResources;if(!t?.blocksAtlasImage||!t.blocksAtlasJson)throw new Error("Block atlas not available");let r=t.blocksAtlasJson,i=r.textures;this.atlasTexture=I0(t.blocksAtlasImage),this.atlasTexture.flipY=!1,this.atlasTexture.needsUpdate=!0;for(let s of fn[this.blockGroup]){let o=this.resolveBlockAtlasUv(s,i,r);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 v=s.includes("glass"),l=new W.MeshBasicMaterial({map:a,side:W.DoubleSide,transparent:v,opacity:v?.85:1,alphaTest:v?.08:0,depthWrite:!0,toneMapped:!1});this.blockMaterialPool.set(s,l)}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=$t([...this.blockMaterialPool.keys()]);s.minecraftBlockName=o,s.mesh.material=this.blockMaterialPool.get(o).clone()}}setScene(e){if(!tt.includes(e)||e===this.curScene||this.transitioning)return;this.transitioning=!0,this.curScene=e;let t=za[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 W.MeshBasicMaterial&&s.mesh.material.color.set($t(t.blocks));let r=this.nebGeo.attributes.color;for(let s=0;s<ur;s++){let o=new W.Color($t(t.nebula));r.setXYZ(s,o.r,o.g,o.b)}r.needsUpdate=!0;let i=this.galGeo.attributes.color;for(let s=0;s<dr;s++){let o=.2+Math.random()*.8,a=t.galFn(o);i.setXYZ(s,a.r,a.g,a.b)}i.needsUpdate=!0,this.transitioning=!1},150)}setCamera(e){rt.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(it.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&&wt(this.camera,this.documentRenderer.canvas);let r=o9[this.curCam],i=this.cameraSpeed,s=this.blockSpeed;this.camT+=e*r.spd*i,this.mx+=(this.tmx-this.mx)*.05,this.my+=(this.tmy-this.my)*.05;let o=this.mx*Fa,a=this.my*Fa,v=r.pos(this.camT,o,a),l=r.look(this.camT,o,a);this.camera.position.set(v.x,v.y,v.z),this.camera.lookAt(l.x,l.y,l.z),this.camera.rotation.z=r.roll(this.camT,o);let c=a9[this.curCam]*s;this.animTime+=e*1e3*s;for(let u of this.blocks){if(u.mesh.position.z+=u.spd*c*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*c,u.mesh.rotation.y+=u.ry*c,u.mesh.rotation.z+=u.rz,!this.useMinecraftTextures&&u.mesh.material instanceof W.MeshBasicMaterial){let h=u.mesh.userData.baseOpacity??.38;u.mesh.userData.baseOpacity==null&&(u.mesh.userData.baseOpacity=h);let p=.88+Math.abs(Math.sin(this.animTime*8e-4+u.mesh.position.x*.3))*.12;u.mesh.material.opacity=h*p}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()}};E();x();k();R();import*as t5 from"three";import{Vec3 as Ga}from"vec3";E();x();k();R();import l9 from"prismarine-world";import c9 from"prismarine-chunk";var Ua=n=>{let e=l9(n),t=c9(n),r=new e(n).sync,i=d9(r);for(let s of i)if(s.startsWith("set")&&s!=="setColumn"){let o=r[s].bind(r);r[s]=(...a)=>{let v=a[0];v.x!==void 0&&!r.getColumnAt(v)&&r.setColumn(Math.floor(v.x/16),Math.floor(v.z/16),new t(void 0)),o(...a)}}return r};function d9(n){let e=new Set,t=n;do for(let r of Object.getOwnPropertyNames(t))typeof n[r]=="function"&&r!=="constructor"&&e.add(r);while(t=Object.getPrototypeOf(t));return[...e]}var e5=class{constructor(e,t,r){this.documentRenderer=e;this.options=t;this.abortSignal=r;d(this,"_scene");d(this,"_camera");d(this,"worldRenderer");d(this,"WorldRendererClass",_t);this._scene=new t5.Scene,this._scene.background=new t5.Color(3294568),this._camera=new t5.PerspectiveCamera(85,e.canvas.width/e.canvas.height,.05,1e3),this.camera.position.set(0,0,0),this.camera.rotation.set(0,0,0)}get scene(){return this._scene}get camera(){return this._camera}async init(){let e=N0,t=new h0;if(t.currentConfig={version:e,noInventoryGui:!0},await t.updateAssetsData?.({}),this.abortSignal.aborted)return;let r=Ua(e),s=Xa("prismarine-block")(e),a=globalThis.mcData.blocksArray.filter(p=>{if(!p.name.includes("stained_glass"))return!1;let g=s.fromStateId(p.defaultState,0);if(g.shapes?.length!==1)return!1;let y=g.shapes[0];return y[0]===0&&y[1]===0&&y[2]===0&&y[3]===1&&y[4]===1&&y[5]===1}),v=-15,l=100,c=100;for(let p=-l;p<l;p++)for(let g=-c;g<c;g++){let y=a[Math.floor(Math.random()*a.length)];r.setBlockStateId(new Ga(p,g,v),y.defaultState)}this._camera.updateProjectionMatrix(),this._camera.position.set(.5,c/2+.5,.5),this._camera.rotation.set(0,0,0);let u=new Ga(...this._camera.position.toArray()),h=new $0(r,2,u);this.abortSignal.aborted||(this.worldRenderer=new this.WorldRendererClass(this.documentRenderer.renderer,this.options,{version:e,worldView:h,inWorldRenderingConfig:c5,playerStateReactive:G2().reactive,rendererState:J0().reactive,nonReactiveState:J0().nonReactive,resourcesManager:t}),this.worldRenderer instanceof _t&&(this._scene=this.worldRenderer.realScene,this._camera=this.worldRenderer.camera),h.init(u),await this.worldRenderer.waitForChunksToRender(),!this.abortSignal.aborted&&this.setupMouseParallax())}update(e,t){t&&wt(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,r=e.position.y,i;document.body.addEventListener("pointermove",s=>{if(s.pointerType!=="mouse")return;let o=.2,a=s.clientX/window.innerWidth-.5,v=-(s.clientY/window.innerHeight-.5);i?.stop(),i=new Oe(e.position).to({x:t+a*o,y:r+v*o},0),i.start(),e.updateProjectionMatrix()},{signal:this.abortSignal})}};E();x();k();R();import*as Na from"three";var r5=class{constructor(e,t,r={},i=!1){this.documentRenderer=e;this.options=t;d(this,"active");d(this,"abortController",new AbortController);d(this,"mode");d(this,"lastFrameTime",0);this.mode=ln(r,i)}get v2(){return this.active instanceof At?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 Na.Color&&this.documentRenderer.renderer.setClearColor(this.active.scene.background),this.lastFrameTime=performance.now(),this.documentRenderer.render=(t=!1)=>{let r=performance.now(),i=Math.min((r-this.lastFrameTime)/1e3,.05);this.lastFrameTime=r;let s=this.active;s&&(s.update(i,t),this.documentRenderer.renderer.render(s.scene,s.camera))}}createImplementation(e){switch(this.mode){case"v2":return new At(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 e5(this.documentRenderer,this.options,this.abortController.signal);default:return new Xt(this.documentRenderer)}}dispose(){this.active?.dispose(),this.active=void 0,this.abortController.abort()}};Q5.ColorManagement.enabled=!1;globalThis.THREE=Q5;var Wa=n=>({updateMap:n.entities.updateMap.bind(n.entities),updateCustomBlock:n.updateCustomBlock.bind(n),getBlockInfo:n.getBlockInfo.bind(n),playEntityAnimation:n.entities.playAnimation.bind(n.entities),damageEntity:n.entities.handleDamageEvent.bind(n.entities),updatePlayerSkin:n.entities.updatePlayerSkin.bind(n.entities),changeHandSwingingState:n.changeHandSwingingState.bind(n),getHighestBlocks:n.getHighestBlocks.bind(n),reloadWorld:n.reloadWorld.bind(n),updateEntityModel:n.entities.updateEntityModel.bind(n.entities),playEntityModelAnimation:n.entities.playEntityModelAnimation.bind(n.entities),addMedia:n.media.addMedia.bind(n.media),destroyMedia:n.media.destroyMedia.bind(n.media),setControlMode:n.media.setControlMode.bind(n.media),setVideoPlaying:n.media.setVideoPlaying.bind(n.media),setVideoSeeking:n.media.setVideoSeeking.bind(n.media),setVideoVolume:n.media.setVideoVolume.bind(n.media),setVideoSpeed:n.media.setVideoSpeed.bind(n.media),handleUserClick:n.media.handleUserClick.bind(n.media),addSectionAnimation(e,t){n.sectionsOffsetsAnimations[e]=t},removeSectionAnimation(e){delete n.sectionsOffsetsAnimations[e]},shakeFromDamage:n.cameraShake.shakeFromDamage.bind(n.cameraShake),onPageInteraction:n.media.onPageInteraction.bind(n.media),downloadMesherLog:n.downloadMesherLog.bind(n),explodeFirework:n.fireworksLegacy.explode.bind(n.fireworksLegacy),explodeFireworkFacingCamera:n.fireworksLegacy.explodeFacingCamera.bind(n.fireworksLegacy),addWaypoint:n.waypoints.addWaypoint.bind(n.waypoints),removeWaypoint:n.waypoints.removeWaypoint.bind(n.waypoints),startCinimaticScript:n.cinimaticScript.startScript.bind(n.cinimaticScript),stopCinimaticScript:n.cinimaticScript.stopScript.bind(n.cinimaticScript),launchFirework:n.fireworks.launchFirework.bind(n.fireworks),setSkyboxImage:n.skyboxRenderer.setSkyboxImage.bind(n.skyboxRenderer),setRain:e=>n.toggleModule("rain",e),spawnBlockBreakParticles(e,t,r,i,s,o){n.getModule("blockBreakParticles")?.spawnBlockBreakParticles(e,t,r,i,s,o)},spawnBlockCrackParticle(e,t,r,i,s,o,a){n.getModule("blockBreakParticles")?.spawnCrackParticle(e,t,r,i,s,o,a)},async loadGeometryExport(e){let{applyWorldGeometryExport:t}=await Promise.resolve().then(()=>(Ji(),ha));return t(n,e)},feedChunkPacket(e){let{kind:t,...r}=e,i={type:t,...r};for(let s of n.workers)s.postMessage(i)},getChunksDebugState(){let e={};for(let t of Object.keys(n.sectionObjects)){let[r,,i]=t.split(",").map(Number);e[`${r},${i}`]=!0}return{loadedSectionsChunks:e,loadedChunks:{...n.loadedChunks},finishedChunks:{...n.finishedChunks}}}}),f9=[],fr=(n,...e)=>{for(let t of Object.values(globalThis.loadedMods??{}))try{t.threeJsBackendModule?.[n]?.(...e)}catch(r){let i=`[mod three.js] Error calling ${n} on ${t.name}: ${r}`;throw new Error(i)}},Va=()=>{let n,e=null,t=null,r=null,i=null,s=(c,u)=>{ae?n=E5(c,f9,globalThis):n=c,e=new h5(n,u?.canvas),globalThis.renderer=e.renderer,globalThis.documentRenderer=e,globalThis.threeJsBackend=l,fr("default",l)},o=async c=>{if(!e)throw new Error("Document renderer not initialized");r&&(r.destroy(),r=null,i=null,globalThis.world=void 0,globalThis.frameTimingCollector=void 0),t&&(t.dispose(),t=null);let u={...n.config.menuBackground,...c};t=new r5(e,{...n},u,!!D.env.SINGLE_FILE_BUILD_MODE),fr("menuBackgroundCreated",t),await t.start(u),fr("menuBackgroundReady",t)},a=async c=>{if(!e)throw new Error("Document renderer not initialized");t&&(t.dispose(),t=null),r&&(r.destroy(),r=null,i=null,globalThis.world=void 0,globalThis.frameTimingCollector=void 0);let h=ae?E5(c,[h0,X0],globalThis):c;e.nonReactiveState=h.nonReactiveState,globalThis.resourcesManager=h.resourcesManager,r=new _t(e.renderer,n,h),await r.worldReadyPromise,i=h.inWorldRenderingConfig.enableDebugOverlay?new h1(h.nonReactiveState):null,globalThis.frameTimingCollector=i;let p=e.render;e.render=function(g){p.call(this,g),i?.markFrameStart(),h.inWorldRenderingConfig.paused||r?.render(g),i?.markFrameEnd(),i?.markFrameDisplay()},e.inWorldRenderingConfig=h.inWorldRenderingConfig,globalThis.world=r,fr("worldReady",r)},v=()=>{t&&(t.dispose(),t=null),e&&e.dispose(),r&&(r.destroy(),r=null)},l={id:"threejs",displayName:`three.js ${Q5.REVISION}`,startMenuBackground:o,startWorld:a,disconnect:v,setRendering(c){e.setPaused(!c),r&&(r.renderingActive=c)},getMenuBackground:()=>t??void 0,getDebugOverlay:()=>({get entitiesString(){return r?.entities.getDebugString()},get left(){return{"Geo Memory":r?.chunkMeshManager.getEstimatedMemoryUsage().total??"-"}}}),updateCamera(c,u,h){i?.markCameraUpdate(!c),r?.setFirstPersonCamera(c,u,h)},get soundSystem(){return r?.soundSystem},get backendMethods(){if(r)return Wa(r)}};return{main:{init:s,backend:l},workerProxy(){return ps({init(c,u){s(c,{canvas:u})},updateSizeExternal(c,u,h){e?.updateSizeExternal(c,u,h)},startMenuBackground:o,startWorld:a,disconnect:v,setRendering:l.setRendering,updateCamera(c,u,h){let p=c?new u9(c.x,c.y,c.z):null;i?.markCameraUpdate(!p),l.updateCamera(p,u,h)},async callBackendMethod(c,...u){if(!r)throw new Error("World renderer not initialized");let p=Wa(r)[c];if(!p)throw new Error(`Backend method ${String(c)} is unavailable`);return p(...u)}})}}};var hr=n=>{let{main:e}=Va();return e.init(n),e.backend};hr.id="threejs";hr.displayName="three.js Blocking";hr.description="Simple, old and stable main thread graphics backend providing balanced performance on top of WebGL2.";E();x();k();R();import*as ja from"three";function h9(n){let e="threeWorker.js",t;if(D.env.SINGLE_FILE_BUILD){let r=document.getElementById("three-worker-code").textContent,i=new Blob([r],{type:"text/javascript"});t=new Worker(window.URL.createObjectURL(i))}else t=new Worker(e);return t.onmessage=({data:r})=>{n(r)},t.on&&t.on("message",r=>{t.onmessage({data:r})}),t}var mr=async n=>{let e=h9(()=>{}),t=gs(e),r=Pr();r.onSizeChanged((a,v)=>{t.updateSizeExternal(a,v,window.devicePixelRatio||1)});let i=A5(n,e);try{t.init(i,r.canvas)}catch(a){throw ot(i),a}let s=new Proxy({},{get(a,v){if(typeof v=="string")return async(...l)=>t.callBackendMethod(v,...l)}});return{id:"threejs",displayName:`three.js ${ja.REVISION}`,async startMenuBackground(a){let v=a?.resourcesManager?.currentResources?.mcData;if(v){let c={...at,items:"itemsArray",entities:"entitiesArray"};await Xr([e],N0,c,v)}let l=A5(a??{},e);try{await t.startMenuBackground(structuredClone(l))}catch(c){throw ot(l),c}},async startWorld(a){let v={...at,items:"itemsArray",entities:"entitiesArray"};await Xr([e],a.version,v,a.resourcesManager.currentResources.mcData),a.inWorldRenderingConfig.__syncToWorker=!0,a.playerStateReactive&&(a.playerStateReactive.__syncToWorker=!0),a.rendererState&&(a.rendererState.__syncFromWorker=!0),a.nonReactiveState&&(a.nonReactiveState.__syncFromWorker=!0),a.nonReactiveState.__syncFromWorkerInterval=200;let l=A5(a,e);try{await t.startWorld(structuredClone(l))}catch(h){throw ot(l),h}t.updateSizeExternal(r.size.width,r.size.height,window.devicePixelRatio||1);let c=lt("fps");setInterval(()=>{let{fps:h,avgRenderTime:p,worstRenderTime:g}=a.nonReactiveState;c.updateText(`FPS: ${h.toFixed(0)} (${p.toFixed(0)}ms/${g.toFixed(0)}ms)`),a.nonReactiveState.fps=0},1e3);let u=lt("downloaded-chunks",100,140,20,{className:vt});setInterval(()=>{let h=(n.config.statsVisible??0)>1;u.setVisibility(h),h&&u.updateText(a.nonReactiveState.world.chunksFullInfo)},200)},disconnect(){r.destroy(),t.disconnect(),e.terminate()},setRendering(a){t.setRendering(a)},updateCamera(a,v,l){t.updateCamera(a?{x:a.x,y:a.y,z:a.z}:null,v,l)},soundSystem:void 0,backendMethods:s}};mr.id="threejs-off-thread";mr.displayName="three.js Multi-thread";mr.description=["Edge-cutting technology that uses a dedicated thread for graphics.","Slightly higher power and RAM usage.","More stable FPS (mid-range devices), but possible inputlag if TPS is low.","On low-end devices it might result in device throttling and stuttering."].join(" ");export{ns as AppViewer,Xt as ClassicMenuBackground,h5 as DocumentRenderer,Ar as HIGH_TEXTURE_COUNT,r1 as LONG_RENDER_TIME_MS,wr as LOW_FPS_THRESHOLD,Bt as LoadedResourcesTransferrable,vt as MC_RENDERER_DEBUG_OVERLAY_CLASS,N0 as MENU_BACKGROUND_MC_VERSION,b5 as MENU_BACKGROUND_MOTION_DEFAULTS,b0 as MENU_BACKGROUND_OPTION_DEFAULTS,fn as MINECRAFT_BLOCK_GROUPS,it as MINECRAFT_BLOCK_GROUP_IDS,g5 as MINECRAFT_BLOCK_GROUP_LABELS,r5 as MenuBackgroundRenderer,l5 as PerformanceMonitor,ss as RENDERER_DEFAULT_OPTIONS,os as RENDERER_OPTIONS_META,as as RENDERER_RENDER_GUI_SECTIONS,h0 as ResourcesManager,At as V2MenuBackground,rt as V2_CAMERA_IDS,p5 as V2_CAMERA_LABELS,tt as V2_SCENE_IDS,m5 as V2_SCENE_LABELS,e5 as WorldBlocksMenuBackground,$0 as WorldView,X0 as WorldViewWorker,Pr as addCanvasForWorker,H6 as applyMenuBackgroundLiveOptions,_f as applyRendererEnableLighting,L6 as applyRendererOptions,bf as applyRendererWorldViewOptions,Mt as chunkPos,mr as createGraphicsBackendOffThread,hr as createGraphicsBackendSingleThread,El as createWorldRendererConfig,L2 as defaultGraphicsBackendConfig,_r as defaultPerformanceInstabilityFactors,c5 as defaultWorldRendererConfig,W2 as delayedIterator,Er as formatPerformanceFactorsDebug,J0 as getDefaultRendererState,ds as getInitialPlayerState,N6 as getInitialPlayerStateRenderer,G6 as getPlayerStateUtils,ae as isWebWorker,gf as menuBackgroundOptionsFromStorage,E0 as menuBackgroundSpeedToMultiplier,x6 as migrateRendererOptions,Or as rendererShaderCubeDebugModeToValue,d6 as sectionPos,yf as subscribeRendererOptions};
|
|
21509
|
+
}`})}},vn=class{constructor(e){this.worldRenderer=e;d(this,"points");d(this,"clock",new Te.Clock);d(this,"enabled",!1);d(this,"currentTime");d(this,"enablementCheck",()=>this.currentTime?this.currentTime>13500&&this.currentTime<23e3:!1);d(this,"render",e=>{this.points&&(this.points.position.set(0,0,0),this.points.material.uniforms.time.value=this.clock.getElapsedTime()*.2)})}enable(){this.enabled||(this.enabled=!0,this.updateVisibility())}disable(){this.enabled&&(this.enabled=!1,this.removeStars())}toggle(){return this.enabled?this.disable():this.enable(),this.enabled}updateTimeOfDay(e){this.currentTime=e,this.enabled&&this.updateVisibility()}updateVisibility(){if(!this.enabled)return;let e=this.enablementCheck?.()??!1;e&&!this.points?this.createStars():!e&&this.points&&this.removeStars()}createStars(){if(this.points)return;let e=80,t=50,r=7e3,i=7,s=10,o=new Te.BufferGeometry,a=y=>new Te.Vector3().setFromSpherical(new Te.Spherical(y,Math.acos(1-Math.random()*2),Math.random()*2*Math.PI)),v=[],l=[],c=Array.from({length:r},()=>(.5+.5*Math.random())*i),u=new Te.Color,h=e+t,p=t/r;for(let y=0;y<r;y++)h-=p*Math.random(),v.push(...a(h).toArray()),u.setHSL(y/r,s,.9),l.push(u.r,u.g,u.b);o.setAttribute("position",new Te.Float32BufferAttribute(v,3)),o.setAttribute("color",new Te.Float32BufferAttribute(l,3)),o.setAttribute("size",new Te.Float32BufferAttribute(c,1));let g=new an;g.blending=Te.AdditiveBlending,g.depthTest=!0,g.depthWrite=!1,g.transparent=!0,this.points=new Te.Points(o,g),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)}},Ha={id:"starfield",controller:vn,enabledDefault:!0,cannotBeDisabled:!0};var Oa={starfield:Ha,futuristicReveal:Ia,rain:Ba,cameraBobbing:Ta,blockBreakParticles:ka};var yt=class yt extends g1{constructor(t,r,i){if(!i.resourcesManager)throw new Error("resourcesManager is required in displayOptions");super(i.resourcesManager,i,r);this.renderer=t;this.initOptions=r;this.displayOptions=i;d(this,"outputFormat","threeJs");d(this,"chunkMeshManager");d(this,"chunkTextures",new Map);d(this,"signsCache",new Map);d(this,"cameraSectionPos",new G0(0,0,0));d(this,"holdingBlock");d(this,"holdingBlockLeft");d(this,"scene",new Q.Scene);d(this,"ambientLight",new Q.AmbientLight(13421772));d(this,"directionalLight",new Q.DirectionalLight(16777215,.5));d(this,"entities",new z1(this,globalThis.mcData));d(this,"performanceMonitor");d(this,"cameraGroupVr");d(this,"material",new Q.MeshBasicMaterial({vertexColors:!0,transparent:!0,alphaTest:.1}));d(this,"itemsTexture");d(this,"cursorBlock");d(this,"onRender",[]);d(this,"lastRenderTime",0);d(this,"animatedFov",0);d(this,"lastFovAnimTime",0);d(this,"cameraShake");d(this,"cameraContainer");d(this,"media");d(this,"waypoints");d(this,"cinimaticScript");d(this,"camera");d(this,"renderTimeAvg",0);d(this,"pendingSectionUpdates",new Map);d(this,"pendingSectionBufferStartTimes",new Map);d(this,"modules",{});d(this,"sectionsOffsetsAnimations",{});d(this,"fountains",[]);d(this,"fireworksLegacy");d(this,"DEBUG_RAYCAST",!1);d(this,"skyboxRenderer");d(this,"fireworks");d(this,"sceneOrigin",new Z1(this.scene));d(this,"cameraWorldPos",{x:0,y:0,z:0});d(this,"_cameraPositionAccessWarned",!1);d(this,"_tmpCameraPos",new Q.Vector3);d(this,"currentPosTween");d(this,"currentRotTween");d(this,"_tpDirection",new Q.Vector3);d(this,"_tpPitchQuat",new Q.Quaternion);d(this,"_tpYawQuat",new Q.Quaternion);d(this,"_tpFinalQuat",new Q.Quaternion);d(this,"_tpScenePos",new Q.Vector3);d(this,"_tpAxisX",new Q.Vector3(1,0,0));d(this,"_tpAxisY",new Q.Vector3(0,1,0));d(this,"_tpRaycaster",new Q.Raycaster);d(this,"_tpChunkWorldPos",new Q.Vector3);d(this,"debugOverlayAdded",!1);d(this,"debugRaycastHelper");d(this,"debugHitPoint");d(this,"prevFramePerspective",null);this.performanceMonitor=new l5(this.reactiveState.world.instabilityFactors),this.renderer=t;let s=yt.getRendererInfo(t)??"...";i.rendererState.renderer=s,this.chunkMeshManager=new Y5(this,this.scene,this.material,this.worldSizeParams.worldHeight,this.viewDistance),this.onRenderDistanceChanged=o=>{this.chunkMeshManager.updateViewDistance(o)},this.cursorBlock=new L1(this),this.holdingBlock=U5(this),this.holdingBlockLeft=U5(this,!0);for(let o of Object.values(Oa))this.registerModule(o);this.skyboxRenderer=new K1(this.realScene,!1,null),this.skyboxRenderer.init(),this.addDebugOverlay(),this.resetScene(),this.init(),this.soundSystem=new G1(this),this.cameraShake=new N1(this,this.onRender),this.media=new W1(this),this.fireworksLegacy=new Y1(this),this.waypoints=new j1(this),this.cinimaticScript=new Q1(this,(o,a,v)=>this.setCinimaticCamera(o,a,v),o=>this.setCinimaticFov(o),()=>({position:new G0(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 J1(this.realScene,this.sceneOrigin),this.renderUpdateEmitter.on("chunkFinished",o=>{this.finishChunk(o)}),this.worldSwitchActions(),this.initializeModules()}isShaderCubeBlocksEnabled(){return this.worldRendererConfig.shaderCubeBlocks===!0&&!!this.renderer?.capabilities?.isWebGL2}get sectionObjects(){return this.chunkMeshManager.sectionObjects}get realScene(){return this.scene}get waitingChunksToDisplay(){return this.chunkMeshManager.waitingChunksToDisplay}get estimatedMemoryUsage(){return this.chunkMeshManager.getEstimatedMemoryUsage().total}get tilesRendered(){return this.chunkMeshManager.getTotalTiles()}get blocksRendered(){return this.chunkMeshManager.getTotalBlocks()}registerModule(t){if(t.id in this.modules)return;let r=new t.controller(this),i={manifest:t,controller:r,enabled:!1,toggle:()=>this.toggleModule(t.id)};this.modules[t.id]=i,t.enabledDefault&&this.toggleModule(t.id,!0)}enableModule(t){let r=this.modules[t];r&&(r.enabled||(r.enabled=!0,r.controller.enable(),r.controller.render&&this.onRender.push(r.controller.render)))}disableModule(t){let r=this.modules[t];if(r&&!r.manifest.cannotBeDisabled&&r.enabled&&(r.enabled=!1,r.controller.disable(),r.controller.render)){let i=this.onRender.indexOf(r.controller.render);i>-1&&this.onRender.splice(i,1)}}toggleModule(t,r){let i=this.modules[t];if(!i)return!1;let s=r!==void 0?r:!i.enabled;if(s===i.enabled)return i.enabled;if(!s&&i.manifest.cannotBeDisabled)return!0;if(i.enabled=s,s)i.controller.enable(),i.controller.render&&!this.onRender.includes(i.controller.render)&&this.onRender.push(i.controller.render);else if(i.controller.disable(),i.controller.render){let o=this.onRender.indexOf(i.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,r=this,i=20,s=(v,l,c)=>Math.abs(v)>i||Math.abs(l)>i||Math.abs(c)>i,o=()=>{!r._cameraPositionAccessWarned&&typeof D<"u"},a=new Proxy(t,{set(v,l,c){return(l==="x"||l==="y"||l==="z")&&typeof c=="number"&&Math.abs(c)>i&&o(),v[l]=c,!0},get(v,l,c){let u=v[l];return l==="set"?function(h,p,g){return s(h,p,g)&&o(),v.set(h,p,g)}:l==="setX"||l==="setY"||l==="setZ"?function(h){return Math.abs(h)>i&&o(),v[l](h)}:l==="copy"?function(h){return s(h.x,h.y,h.z)&&o(),v.copy(h)}:typeof u=="function"?u.bind(v):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(){Ki(this,new Q.Vector3(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z),this.cameraShake.getBaseRotation(),"world-geometry.json")}updateEntity(t,r=!1){let i={rotation:{head:{x:t.headPitch??t.pitch,y:t.headYaw,z:0}}};r?this.entities.updateEntityPosition(t,!1,i):this.entities.update(t,i)}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 Q.Color(this.initOptions.config.sceneBackground),this.scene.add(this.ambientLight),this.directionalLight.position.set(1,1,.5).normalize(),this.directionalLight.castShadow=!0,this.scene.add(this.directionalLight);let t=this.renderer.getSize(new Q.Vector2);this.camera=new Q.PerspectiveCamera(75,t.x/t.y,.1,1e3),this._wrapCameraPositionWithWarning(),this.cameraContainer=new Q.Object3D,this.cameraContainer.add(this.camera),this.scene.add(this.cameraContainer)}watchReactivePlayerState(){super.watchReactivePlayerState(),this.onReactivePlayerStateUpdated("inWater",t=>{this.skyboxRenderer.updateWaterState(t,this.playerStateReactive.waterBreathing)}),this.onReactivePlayerStateUpdated("waterBreathing",t=>{this.skyboxRenderer.updateWaterState(this.playerStateReactive.inWater,t)}),this.onReactivePlayerStateUpdated("ambientLight",t=>{t&&(this.ambientLight.intensity=t)}),this.onReactivePlayerStateUpdated("directionalLight",t=>{t&&(this.directionalLight.intensity=t)}),this.onReactivePlayerStateUpdated("lookingAtBlock",t=>{this.cursorBlock.setHighlightCursorBlock(t?new G0(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 r=new G0(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z);this.updateCamera(r,this.cameraShake.getBaseRotation().yaw,this.cameraShake.getBaseRotation().pitch)})}watchReactiveConfig(){super.watchReactiveConfig(),this.onReactiveConfigUpdated("showChunkBorders",r=>{this.updateShowChunksBorder(r)}),this.onReactiveConfigUpdated("defaultSkybox",r=>{this.skyboxRenderer.updateDefaultSkybox(r)}),this.onReactiveConfigUpdated("shaderCubeDebugMode",()=>{this.chunkMeshManager.syncCubeShaderUniforms()}),this.onReactiveConfigUpdated("futuristicReveal",()=>{this.updateModulesFromConfig()});let t=this.displayOptions.inWorldRenderingConfig.handRenderer;this.onReactiveConfigUpdated("handRenderer",r=>{if(r===t)return;t=r;let i=this.holdingBlock.ready,s=this.holdingBlockLeft.ready;this.holdingBlock.dispose(),this.holdingBlockLeft.dispose(),this.holdingBlock=U5(this),this.holdingBlockLeft=U5(this,!0),i&&(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[r,i]of Object.entries(this.modules)){let s=t[r];if(s==="enabled"){i.enabled||this.toggleModule(r,!0);continue}if(s==="disabled"){i.enabled&&!i.manifest.cannotBeDisabled&&this.toggleModule(r,!1);continue}if(s==="auto"||s===void 0)if(i.controller.autoEnableCheck){let o=i.controller.autoEnableCheck();o&&!i.enabled?this.toggleModule(r,!0):!o&&i.enabled&&!i.manifest.cannotBeDisabled&&this.toggleModule(r,!1)}else{let o=i.manifest.enabledDefault??!1;o&&!i.enabled?this.toggleModule(r,!0):!o&&i.enabled&&!i.manifest.cannotBeDisabled&&this.toggleModule(r,!1)}}}changeHandSwingingState(t,r=!1){let i=r?this.holdingBlockLeft:this.holdingBlock;t?i.startSwing():i.stopSwing()}async updateAssetsData(){let t=this.resourcesManager.currentResources,r=this.material.map,i=this.itemsTexture,s=I0(t.blocksAtlasImage);s.needsUpdate=!0,s.flipY=!1,this.material.map=s,this.chunkMeshManager.syncCubeShaderUniforms();let o=I0(t.itemsAtlasImage);o.needsUpdate=!0,o.flipY=!1,this.itemsTexture=o,r&&r.dispose(),i&&i.dispose(),await super.updateAssetsData(),this.onAllTexturesLoaded(),Object.keys(this.loadedChunks).length>0&&this.rerenderAllChunks()}onAllTexturesLoaded(){this.holdingBlock.ready=!0,this.holdingBlock.updateItem(),this.holdingBlockLeft.ready=!0,this.holdingBlockLeft.updateItem()}changeBackgroundColor(t){this.realScene.background=new Q.Color(t[0],t[1],t[2])}changeCardinalLight(t){this.worldRendererConfig.cardinalLight=t}timeUpdated(t){let r=this.getModule("starfield");r?.updateTimeOfDay&&r.updateTimeOfDay(t),this.skyboxRenderer.updateTime(t)}biomeUpdated(t){t?.temperature!==void 0&&this.skyboxRenderer.updateTemperature(t.temperature)}biomeReset(){this.skyboxRenderer.updateTemperature(Gi)}getItemRenderData(t,r){return Z3(t,r,this.resourcesManager,this.playerStateReactive)}async demoModel(){let t=cursorBlockRel(0,1,0).position,r=await R5();Ps(r,t);let i=new Q.BoxHelper(r,16776960);r.add(i),this.realScene.add(r)}demoItem(){let t=cursorBlockRel(0,1,0).position,{mesh:r}=this.entities.getItemMesh({itemId:541},{});r.position.set(t.x+.5,t.y+.5,t.z+.5);let i=new Q.BoxHelper(r,16776960);r.add(i),this.realScene.add(r)}addDebugOverlay(){if(this.debugOverlayAdded)return;this.debugOverlayAdded=!0;let t=lt("debug-overlay",80,0,void 0,{className:vt});setInterval(()=>{if(t.setVisibility(this.displayAdvancedStats),this.displayAdvancedStats){let r=v=>new Intl.NumberFormat("en-US",{}).format(v),i=v=>new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1}).format(v),s="";s+=`TE: ${r(this.renderer.info.memory.textures)} `,s+=`F: ${i(this.tilesRendered)} `,s+=`B: ${i(this.blocksRendered)} `,s+=`MEM: ${this.chunkMeshManager.getEstimatedMemoryUsage().total} `;let o=this.chunkMeshManager.getStats();s+=`POOL: ${o.activeCount}/${o.poolSize} `;let a=Er(this.reactiveState.world.instabilityFactors);a&&(s+=`PF: ${a} `),t.updateText(s),this.backendInfoReport=s}},200)}updatePosDataChunk(t){let r=this.sectionObjects[t];if(!r)return;let[i,s,o]=t.split(",").map(c=>Math.floor(+c/16)),v=500-(Math.abs(i-this.cameraSectionPos.x)+Math.abs(s-this.cameraSectionPos.y)+Math.abs(o-this.cameraSectionPos.z)),l=r.mesh??r.shaderMesh??r.children.find(c=>c.name==="mesh"||c.name==="shaderMesh");l&&(l.renderOrder=v)}updateViewerPosition(t){this.viewerChunkPosition=t}cameraSectionPositionUpdate(){for(let t in this.sectionObjects)this.sectionObjects[t]&&this.updatePosDataChunk(t)}getDir(t,r){return t===r?0:t<r?1:-1}finishChunk(t){this.chunkMeshManager.finishChunkDisplay(t)}applyPendingSectionUpdates(){if(this.pendingSectionUpdates.size===0)return;let t=performance.now(),r=this.getSectionHeight(),i=[];for(let s of this.pendingSectionUpdates.keys()){let o=this.pendingSectionBufferStartTimes.get(s)??t;if(t-o<yt.MAX_SECTION_UPDATE_BUFFER_MS){let[v,l,c]=s.split(",").map(Number),u=[`${v-16},${l},${c}`,`${v+16},${l},${c}`,`${v},${l-r},${c}`,`${v},${l+r},${c}`,`${v},${l},${c-16}`,`${v},${l},${c+16}`],h=!1;for(let p of u)if(this.sectionsWaiting.has(p)&&!this.pendingSectionUpdates.has(p)&&this.sectionObjects[p]){h=!0;break}if(h)continue}i.push(s)}if(i.length!==0)for(let s of i){let o=this.pendingSectionUpdates.get(s);this.pendingSectionUpdates.delete(s),this.pendingSectionBufferStartTimes.delete(s);let a=o.key.split(","),v=`${a[0]},${a[2]}`;if(!this.loadedChunks[v]||!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,r){for(let i of[...this.pendingSectionUpdates.keys()])i.startsWith(`${t},`)&&i.endsWith(`,${r}`)&&(this.pendingSectionUpdates.delete(i),this.pendingSectionBufferStartTimes.delete(i))}handleWorkerMessage(t){if(t.type==="geometry"){let r=t.key.split(","),i=`${r[0]},${r[2]}`;if(!this.loadedChunks[i]||!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,r,i,s=!1){let o=Ht(t),a=this.chunkTextures.get(`${o[0]},${o[1]}`);a||(a={},this.chunkTextures.set(`${o[0]},${o[1]}`,a));let v=`${t.x},${t.y},${t.z}`;if(a[v])return a[v];let l=i9(this.version),c=m1(r,i,l);if(!c)return;let u=new Q.Texture(c);return u.magFilter=Q.NearestFilter,u.minFilter=Q.NearestFilter,u.needsUpdate=!0,a[v]=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 G0(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,r,i){let s=this.playerStateReactive.eyeHeight;this.updateCamera(t?.offset(0,s,0)??null,r,i),this.updateCameraSectionPos()}getThirdPersonCamera(t,r,i){t??(t=new Q.Vector3(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),v=this._tpPitchQuat.setFromAxisAngle(this._tpAxisX,i),l=this._tpYawQuat.setFromAxisAngle(this._tpAxisY,r),c=this._tpFinalQuat.multiplyQuaternions(l,v);a.applyQuaternion(c),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)),h=this._tpRaycaster;h.set(u,a),h.far=o;let p=80,g=p*p,y=t.x,A=t.y,b=t.z,w=[];for(let B of Object.values(this.sectionObjects)){if(B.name!=="chunk"||!B.visible||B.worldX===void 0)continue;let H=B.worldX-y,G=B.worldY-A,O=B.worldZ-b;if(H*H+G*G+O*O>g)continue;let j=B.children.find(J=>J.name==="mesh"||J.name==="shaderMesh");j&&w.push(j)}let S=h.intersectObjects(w,!1),C=o;S.length>0&&(C=Math.max(.5,S[0].distance-.2));let M=this.chunkMeshManager.raycastShaderSectionAABBs(t,a,C,p);return M!==void 0&&(C=Math.max(.5,M-.2)),new G0(t.x+a.x*C,t.y+a.y*C,t.z+a.z*C)}debugRaycast(t,r,i){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 Q.Vector3(this.sceneOrigin.toSceneX(t.x),this.sceneOrigin.toSceneY(t.y),this.sceneOrigin.toSceneZ(t.z));this.debugRaycastHelper=new Q.ArrowHelper(r.clone().normalize(),s,i,16711680,i*.1,i*.05),this.realScene.add(this.debugRaycastHelper);let o=new Q.SphereGeometry(.2,8,8),a=new Q.MeshBasicMaterial({color:65280});this.debugHitPoint=new Q.Mesh(o,a),this.debugHitPoint.position.copy(s).add(r.clone().multiplyScalar(i)),this.realScene.add(this.debugHitPoint)}setCinimaticCamera(t,r,i){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(i,r),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,r=this.playerStateReactive.fovMultiplier,i=t*(Number.isFinite(r)?r:1),s=performance.now();if(this.animatedFov===0&&(this.animatedFov=i),Math.abs(this.animatedFov-i)>=.01){let o=s-this.lastFovAnimTime,a=Math.min(o/yt.FOV_TRANSITION_MS,1),v=l=>1-(1-l)**3;this.animatedFov+=(i-this.animatedFov)*v(a),Math.abs(this.animatedFov-i)<.01&&(this.animatedFov=i)}else this.animatedFov=i;this.lastFovAnimTime=s,this.camera.fov!==this.animatedFov&&(this.camera.fov=this.animatedFov,this.camera.updateProjectionMatrix())}updateCamera(t,r,i){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 Oe(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&&r>Math.PI+a?o=-Math.PI*2:r<a&&s.yaw>Math.PI+a&&(o=Math.PI*2),this.currentRotTween?.stop(),this.currentRotTween=new Oe(s).to({pitch:i,yaw:r+o},100).onUpdate(v=>this.cameraShake.setBaseRotation(v.pitch,v.yaw-o)).start()}else{this.currentRotTween?.stop(),this.cameraShake.setBaseRotation(i,r);let{perspective:s}=this.playerStateReactive;if(s==="third_person_back"||s==="third_person_front"){let o=new Q.Vector3(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z),a=this.getThirdPersonCamera(o,r,i),v=o.distanceTo(new Q.Vector3(a.x,a.y,a.z)),l=s==="third_person_back"?v:-v;this.camera.position.set(0,0,l),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:r,chunksRenderDistanceOverride:i,chunksRenderAboveEnabled:s,chunksRenderBelowEnabled:o,chunksRenderDistanceEnabled:a}=this.reactiveDebugParams,v=this.getSectionHeight(),l=this.cameraSectionPos.y*v;if(this.displayOptions.inWorldRenderingConfig.enableDebugOverlay&&t!==void 0||r!==void 0||i!==void 0)for(let[c,u]of Object.entries(this.sectionObjects)){if(u._waitingForChunkDisplay)continue;let[h,p,g]=c.split(",").map(Number),y=s&&t!==void 0?p<=l+t:o&&r!==void 0?p>=l-r:a&&i!==void 0?Math.abs(p-l)<=i:!0;u.visible=y}else this.chunkMeshManager.updateSectionsVisibility()}render(t=!1){if(this.currentRenderedFrames++,this.reactiveDebugParams.stopRendering)return;this.debugChunksVisibilityOverride();let r=performance.now();this.lastRendered=performance.now();let i=this.lastRenderTime>0?Math.min(Math.max((r-this.lastRenderTime)/1e3,0),.1):1/60;this.lastRenderTime=r,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 Q.Vector2);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 Q.Group?this.cameraGroupVr.children.find(u=>u instanceof Q.PerspectiveCamera):this.camera;this.applyPendingSectionUpdates();let v=this.chunkMeshManager.globalBlockBuffer;v&&(v.setCameraOrigin(this.cameraWorldPos.x,this.cameraWorldPos.y,this.cameraWorldPos.z),v.compactStep(),v.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(i);let c=performance.now()-r;this.worldRendererConfig.autoLowerRenderDistance&&this.chunkMeshManager.recordRenderTime(c),this.renderTimeAvgCount++,this.renderTimeAvg=(this.renderTimeAvg*(this.renderTimeAvgCount-1)+c)/this.renderTimeAvgCount,this.renderTimeMax=Math.max(this.renderTimeMax,c),this.performanceMonitor.onFrame({totalMs:c,entitiesMs:o,loadedTextureCount:this.renderer.info.memory.textures,fps:this.lastFps})}renderHead(t,r,i,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 v=JSON.parse(z.from(o,"base64").toString()).textures?.SKIN?.url,{skinTexturesProxy:l}=this.worldRendererConfig;l&&(v=v?.replace("http://textures.minecraft.net/",l).replace("https://textures.minecraft.net/",l));let c=D0(this,v,F0.head),u=new Q.Group;return i&&c.position.set(0,.3125,.3125),c.position.y-=23/16,u.add(c),this.sceneOrigin.track(u),u.position.set(t.x+.5,t.y+.045,t.z+.5),u.rotation.set(0,-Q.MathUtils.degToRad(r*(i?90:45/2)),0),u.scale.set(.8,.8,.8),u}catch{}}renderSign(t,r,i,s,o){let a=this.getSignTexture(t,o,s);if(!a)return;let v=new Q.Mesh(new Q.PlaneGeometry(1,1),new Q.MeshBasicMaterial({map:a,transparent:!0}));v.renderOrder=999;let l=7/16,c=s?1.3:1;v.scale.set(1*c,l*c,1*c);let u=(s?2:1.5)/16,h=.25/16;i&&!s?v.position.set(0,0,-.5+u+h+1e-4):v.position.set(0,0,u/2+1e-4);let p=new Q.Group;p.rotation.set(0,-Q.MathUtils.degToRad(r*(i?90:45/2)),0),p.add(v);let g=(s?10:8)/16,y=(s?0:i?4.333:9.333)/16,A=g/2+y;return this.sceneOrigin.track(p),p.position.set(t.x+.5,t.y+A,t.z+.5),p}lightUpdate(t,r){for(let i=this.worldSizeParams.minY;i<this.worldSizeParams.worldHeight;i+=16)this.setSectionDirty(new G0(t,i,r))}rerenderAllChunks(){for(let t of Object.keys(this.sectionObjects)){let[r,i,s]=t.split(",").map(Number);this.setSectionDirty(new G0(r,i,s))}}updateShowChunksBorder(t){this.chunkMeshManager.updateAllBoxHelpers(t)}resetWorld(){super.resetWorld(),this.pendingSectionUpdates.clear(),this.pendingSectionBufferStartTimes.clear(),this.chunkMeshManager.dispose(),this.chunkMeshManager=new Y5(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,r=!1){let[i,s,o]=Qr(t);return Object.fromEntries(Object.entries(this.sectionObjects).map(([a,v])=>{let[l,c,u]=a.split(",").map(Number),[h,p,g]=Qr({x:l,y:c,z:u});return[r?`${h-i},${p-s},${g-o}`:`${h-i},${g-o}`,v]}))}cleanChunkTextures(t,r){let i=this.chunkTextures.get(`${Math.floor(t/16)},${Math.floor(r/16)}`)??{};for(let s of Object.keys(i))i[s].dispose(),delete i[s];this.chunkMeshManager.cleanSignChunkTextures(t,r)}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 r of t)r.matrixWorldNeedsUpdate=!1,this.disableUpdates(r.children??[])}removeColumn(t,r){super.removeColumn(t,r),this.cleanChunkTextures(t,r),this.clearPendingSectionUpdatesForChunk(t,r);let i=this.getSectionHeight(),s=this.worldMinYRender;for(let o=s;o<this.worldSizeParams.worldHeight;o+=i){let a=`${t},${o},${r}`;this.chunkMeshManager.sectionObjects[a]&&this.chunkMeshManager.releaseSection(a)}this.chunkMeshManager.onChunkRemovedFromGate(`${t},${r}`)}updateViewerPosition(t){super.updateViewerPosition(t),this.chunkMeshManager.pendingNearReveal.size>0&&this.chunkMeshManager.tryRevealPending()}onViewerChunkPositionChanged(){this.chunkMeshManager.tryRevealPending()}setSectionDirty(...t){let[r]=t;this.cleanChunkTextures(r.x,r.z),super.setSectionDirty(...t)}static getRendererInfo(t){try{let r=t.getContext();return`${r.getParameter(r.getExtension("WEBGL_debug_renderer_info").UNMASKED_RENDERER_WEBGL)}`}catch{}}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 i=this.getSectionHeight(),s,o,a,v=this.sceneOrigin.getWorldPosition(t);v?(s=v.x,o=v.y,a=v.z):(s=this.sceneOrigin.toWorldX(t.position.x),o=this.sceneOrigin.toWorldY(t.position.y),a=this.sceneOrigin.toWorldZ(t.position.z));let l=Math.floor(s/16)*16,c=Math.floor(a/16)*16,u=Math.floor(o/i)*i,h=`${l},${c}`,p=`${l},${u},${c}`;return!!this.finishedChunks[h]||!!this.sectionObjects[p]}handleUserClick(t){this.media.handleUserClick(t)}updateSectionOffsets(){let t=performance.now();for(let[r,i]of Object.entries(this.sectionsOffsetsAnimations)){let s=(t-i.time)/1e3;i.time=t,i.currentOffsetX+=i.speedX*s,i.currentOffsetY+=i.speedY*s,i.currentOffsetZ+=i.speedZ*s,i.limitX!==void 0&&(i.speedX>0?i.currentOffsetX=Math.min(i.currentOffsetX,i.limitX):i.currentOffsetX=Math.max(i.currentOffsetX,i.limitX)),i.limitY!==void 0&&(i.speedY>0?i.currentOffsetY=Math.min(i.currentOffsetY,i.limitY):i.currentOffsetY=Math.max(i.currentOffsetY,i.limitY)),i.limitZ!==void 0&&(i.speedZ>0?i.currentOffsetZ=Math.min(i.currentOffsetZ,i.limitZ):i.currentOffsetZ=Math.max(i.currentOffsetZ,i.limitZ));let o=this.sectionObjects[r];o&&(o.position.set(i.currentOffsetX,i.currentOffsetY,i.currentOffsetZ),o.updateMatrix())}}reloadWorld(){this.entities.reloadEntities()}};d(yt,"FOV_TRANSITION_MS",200),d(yt,"MAX_SECTION_UPDATE_BUFFER_MS",500);var _t=yt;E();x();k();R();E();x();k();R();var N0="1.21.4";E();x();k();R();function wt(n,e){n.aspect=e.width/e.height,n.updateProjectionMatrix()}E();x();k();R();function ln(n,e=!1){return n?.mode?n.mode:e?"worldBlocks":b0.mode}E();x();k();R();import*as ve from"three";E();x();k();R();function cn(...n){let e=n.filter(r=>r.length>0).join("/"),t=typeof globalThis.location<"u"&&globalThis.location.href?globalThis.location.href:typeof import.meta<"u"&&import.meta.url?import.meta.url:`/${e}`;try{return new URL(e,t).href}catch{return`/${e}`}}var dn=new Date,Da=dn.getMonth()===11&&dn.getDate()>=24&&dn.getDate()<=26,n9=["panorama_3.webp","panorama_1.webp","panorama_4.webp","panorama_5.webp","panorama_0.webp","panorama_2.webp"],s9=200,Xt=class{constructor(e){this.documentRenderer=e;d(this,"scene");d(this,"camera");d(this,"startTimes",new Map);d(this,"time",0);d(this,"panoramaGroup",null);this.scene=new ve.Scene,this.scene.background=new ve.Color(3294568);let t=new ve.AmbientLight(13421772);this.scene.add(t);let r=new ve.DirectionalLight(16777215,.5);r.position.set(1,1,.5).normalize(),r.castShadow=!0,this.scene.add(r),this.camera=new ve.PerspectiveCamera(85,e.canvas.width/e.canvas.height,.05,1e3),this.camera.position.set(0,0,0),this.camera.rotation.set(0,0,0)}async init(){this.buildCubemap()}update(e,t){t&&wt(this.camera,this.documentRenderer.canvas)}dispose(){this.scene.clear(),this.panoramaGroup=null,this.startTimes.clear()}buildCubemap(){let e=new ve.BoxGeometry(1e3,1e3,1e3),t=[];for(let s of n9)(async()=>{let a=cn("background",Da?"christmas":"",s),v=await st(a),l=I0(v);l.matrixAutoUpdate=!1,l.matrix.set(-1,0,1,0,1,0,0,0,1),l.wrapS=ve.ClampToEdgeWrapping,l.wrapT=ve.ClampToEdgeWrapping,l.minFilter=ve.LinearFilter,l.magFilter=ve.LinearFilter;let c=new ve.MeshBasicMaterial({map:l,transparent:!0,side:ve.DoubleSide,depthWrite:!1,opacity:0});this.startTimes.set(c,Date.now()),t.push(c)})().catch(a=>{});let r=new ve.Mesh(e,t);r.onBeforeRender=()=>{this.time+=.01,r.rotation.y=Math.PI+this.time*.01,r.rotation.z=Math.sin(-this.time*.001)*.001;for(let s of t){let o=this.startTimes.get(s);if(o){let a=Date.now()-o;s.opacity=Math.min(1,a/s9)}}};let i=new ve.Object3D;if(i.add(r),!Da)for(let s=0;s<20;s++){let o=new M0("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(r.rotation.y*3)*Math.PI/4-Math.PI/2},i.add(o)}this.scene.add(i),this.panoramaGroup=i}async debugImageInFrontOfCamera(){let e=await st(cn("background","panorama_0.webp")),t=I0(e),r=new ve.Mesh(new ve.PlaneGeometry(1e3,1e3),new ve.MeshBasicMaterial({map:t}));r.position.set(0,0,-500),this.scene.add(r)}};E();x();k();R();import*as W from"three";var Fa=.1,fn={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"]},za={galaxy:{bg:132114,fog:132114,fogD:.011,blocks:[61695,54527,47359,59647,2280703,43263],emit:[13158,8789,6724],nebula:[4403,1114146,4386],galFn:n=>new W.Color(n*.05,n*.2,n),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:n=>new W.Color(n,n*.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:n=>new W.Color(n*.4,0,n),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:n=>new W.Color(n*.15,n*.85,n*.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:n=>{let e=new W.Color;return n<.4?e.lerpColors(new W.Color(16054527),new W.Color(14215423),n/.4):n<.75?e.lerpColors(new W.Color(14215423),new W.Color(11061488),(n-.4)/.35):e.lerpColors(new W.Color(11061488),new W.Color(9482464),(n-.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]}},o9={cruise:{pos:(n,e,t)=>({x:Math.sin(n*.28)*18+Math.cos(n*.11)*7+e*10,y:Math.sin(n*.19)*6+Math.cos(n*.31)*3+t*6,z:0}),look:(n,e,t)=>({x:Math.sin((n+.18)*.28)*18+e*8,y:Math.sin((n+.18)*.19)*6+t*4,z:-25}),roll:(n,e=0)=>e*.05+Math.sin(n*.22)*.015,spd:.18},barrel:{pos:(n,e,t)=>{let i=n*2.4;return{x:Math.cos(i)*10+e*4,y:Math.sin(i)*10+t*4,z:Math.sin(n*.4)*8}},look:n=>({x:Math.sin(n*.5)*5,y:Math.cos(n*.5)*5,z:-30}),roll:n=>n*2.4+Math.PI*.5,spd:.24},dive:{pos:(n,e,t)=>({x:Math.sin(n*.6)*30+e*8,y:Math.cos(n*.4)*18+t*6,z:Math.sin(n*.3)*12}),look:(n,e,t)=>({x:Math.sin(n*.6+.2)*30+e*6,y:Math.cos(n*.4+.2)*18-8+t*4,z:-35}),roll:(n,e=0)=>e*.08+Math.sin(n*.6)*.12,spd:.3},orbit:{pos:(n,e,t)=>({x:Math.cos(n*.5)*20+e*5,y:Math.sin(n*.25)*10+t*5,z:Math.sin(n*.5)*20}),look:()=>({x:0,y:0,z:-60}),roll:n=>Math.sin(n*.5)*.08,spd:.15},snake:{pos:(n,e,t)=>({x:Math.sin(n*1.1)*22+Math.sin(n*.37)*8+e*10,y:Math.sin(n*.7)*10+e*4+t*8,z:0}),look:(n,e,t)=>{let r=n+.12;return{x:Math.sin(r*1.1)*22+Math.sin(r*.37)*8+e*8,y:Math.sin(r*.7)*10+t*6,z:-22}},roll:(n,e=0)=>e*.1+Math.sin(n*1.1)*.06,spd:.22}},a9={cruise:1,barrel:1.6,dive:2.2,orbit:.7,snake:1.4},v9=250,dr=1e4,ur=3e3,$t=n=>n[Math.floor(Math.random()*n.length)],un=n=>"#"+n.toString(16).padStart(6,"0"),La=n=>{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 r=e.width,i=e.height,s=n.radial?t.createRadialGradient(r/2,i*.32,0,r/2,i*.32,i*.85):t.createLinearGradient(0,0,0,i);s.addColorStop(0,un(n.top)),n.mid!=null&&s.addColorStop(.45,un(n.mid)),s.addColorStop(1,un(n.bottom)),t.fillStyle=s,t.fillRect(0,0,r,i);let o=new W.CanvasTexture(e);return o.needsUpdate=!0,o},At=class{constructor(e,t={},r){this.documentRenderer=e;this.abortSignal=r;d(this,"scene");d(this,"camera");d(this,"ambient");d(this,"dir");d(this,"pt1");d(this,"pt2");d(this,"blocks",[]);d(this,"bGroup",new W.Group);d(this,"galaxy");d(this,"nebula");d(this,"stars");d(this,"galGeo");d(this,"nebGeo");d(this,"bGeo",new W.BoxGeometry(1,1,1));d(this,"eGeo",new W.EdgesGeometry(this.bGeo));d(this,"curScene");d(this,"curCam");d(this,"blockGroup");d(this,"cameraSpeed");d(this,"blockSpeed");d(this,"camT",0);d(this,"mx",0);d(this,"my",0);d(this,"tmx",0);d(this,"tmy",0);d(this,"transitioning",!1);d(this,"useMinecraftTextures",!1);d(this,"resourcesManager");d(this,"atlasTexture",null);d(this,"blockMaterialPool",new Map);d(this,"gradientSky",null);d(this,"gradientSkyTexture",null);d(this,"disposed",!1);d(this,"animTime",0);d(this,"texturesApplied",!1);d(this,"textureLoadInProgress",!1);d(this,"onAssetsTexturesUpdated");let i=b0;this.curScene=t.initialScene??i.v2Scene,this.curCam=t.initialCamera??i.v2Camera,this.blockGroup=t.initialBlockGroup??i.v2BlockGroup,this.cameraSpeed=t.initialCameraSpeed??b5.camera,this.blockSpeed=t.initialBlockSpeed??b5.block,this.useMinecraftTextures=t.useMinecraftTextures??i.minecraftTextures,this.resourcesManager=t.resourcesManager;let s=za[this.curScene];this.scene=new W.Scene,this.scene.fog=new W.FogExp2(s.fog,s.fogD),this.applyScenePalette(s),this.camera=new W.PerspectiveCamera(80,this.documentRenderer.canvas.width/this.documentRenderer.canvas.height,.1,700),this.ambient=new W.AmbientLight(s.ambient,2.5),this.scene.add(this.ambient),this.dir=new W.DirectionalLight(s.dir,4),this.dir.position.set(1,1,0),this.scene.add(this.dir),this.pt1=new W.PointLight(s.pt1,5,100),this.scene.add(this.pt1),this.pt2=new W.PointLight(s.pt2,4,80),this.pt2.position.set(30,20,-30),this.scene.add(this.pt2);for(let h=0;h<v9;h++)this.spawnBlock(s,!0);if(!this.useMinecraftTextures){let h=s.edgeLineColor??62975;for(let p=0;p<40;p++){let g=new W.LineBasicMaterial({color:h,transparent:!0,opacity:.25});$t(this.blocks).mesh.add(new W.LineSegments(this.eGeo,g))}}this.scene.add(this.bGroup);let o=new W.BufferGeometry,a=new Float32Array(5e3*3);for(let h=0;h<5e3*3;h++)a[h]=(Math.random()-.5)*500;o.setAttribute("position",new W.BufferAttribute(a,3)),this.stars=new W.Points(o,new W.PointsMaterial({color:s.starColor??16777215,size:.3,transparent:!0,opacity:s.starOpacity??.7,sizeAttenuation:!0})),this.scene.add(this.stars),this.galGeo=new W.BufferGeometry;let v=new Float32Array(dr*3),l=new Float32Array(dr*3);for(let h=0;h<dr;h++){let p=h%3,g=Math.random(),y=p/3*Math.PI*2+g*Math.PI*5,A=g*90+Math.random()*10,b=(1-g)*18;v[h*3]=Math.cos(y)*A+(Math.random()-.5)*b,v[h*3+1]=(Math.random()-.5)*7,v[h*3+2]=Math.sin(y)*A+(Math.random()-.5)*b-180;let w=.2+g*.8,S=s.galFn(w);l[h*3]=S.r,l[h*3+1]=S.g,l[h*3+2]=S.b}this.galGeo.setAttribute("position",new W.BufferAttribute(v,3)),this.galGeo.setAttribute("color",new W.BufferAttribute(l,3)),this.galaxy=new W.Points(this.galGeo,new W.PointsMaterial({size:.9,vertexColors:!0,transparent:!0,opacity:s.galaxyOpacity??.55,sizeAttenuation:!0})),this.scene.add(this.galaxy),this.nebGeo=new W.BufferGeometry;let c=new Float32Array(ur*3),u=new Float32Array(ur*3);for(let h=0;h<ur;h++){let p=25+Math.random()*110,g=Math.random()*Math.PI*2,y=(Math.random()-.5)*Math.PI*.5;c[h*3]=p*Math.cos(g)*Math.cos(y),c[h*3+1]=p*Math.sin(y)*.6,c[h*3+2]=p*Math.sin(g)*Math.cos(y)-80;let A=new W.Color($t(s.nebula));u[h*3]=A.r,u[h*3+1]=A.g,u[h*3+2]=A.b}this.nebGeo.setAttribute("position",new W.BufferAttribute(c,3)),this.nebGeo.setAttribute("color",new W.BufferAttribute(u,3)),this.nebula=new W.Points(this.nebGeo,new W.PointsMaterial({size:3,vertexColors:!0,transparent:!0,opacity:s.nebulaOpacity??.3,sizeAttenuation:!0})),this.scene.add(this.nebula),this.addBackgroundTextPlane(),this.setupMouseTracking()}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:N0,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 h0;if(!await this.ensureAtlasReady(e)){this.resourcesManager&&this.attachAssetsListener();return}if(this.disposed)return;this.applyMinecraftTexturesFromAtlas(e),this.texturesApplied=!0,this.detachAssetsListener()}catch{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=La(e.gradientBg);s&&(this.gradientSkyTexture.dispose(),this.gradientSkyTexture=s,this.gradientSky.material.map=s,this.gradientSky.material.needsUpdate=!0)}}else{let s=La(e.gradientBg);s?(this.gradientSkyTexture=s,this.gradientSky=new W.Mesh(new W.PlaneGeometry(900,700),new W.MeshBasicMaterial({map:s,depthWrite:!1,side:W.DoubleSide})),this.gradientSky.position.set(0,0,-280),this.gradientSky.renderOrder=-1e3,this.scene.add(this.gradientSky)):this.scene.background=new W.Color(e.bg)}else this.scene.background=new W.Color(e.bg),this.gradientSky&&(this.gradientSky.visible=!1);this.scene.fog instanceof W.FogExp2&&(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 r=this.galaxy?.material;r&&(r.opacity=e.galaxyOpacity??.55);let i=this.nebula?.material;i&&(i.opacity=e.nebulaOpacity??.3)}setupMouseTracking(){let e=r=>{let i=typeof window<"u"?window.innerWidth:this.documentRenderer.canvas.width,s=typeof window<"u"?window.innerHeight:this.documentRenderer.canvas.height;this.tmx=(r.clientX/i-.5)*2,this.tmy=-(r.clientY/s-.5)*2};(typeof document<"u"?document:void 0)?.addEventListener("mousemove",e,{signal:this.abortSignal})}addBackgroundTextPlane(){let r=typeof document<"u"?document.createElement("canvas"):null;if(!r)return;r.width=2048,r.height=768;let i=r.getContext("2d");if(!i)return;i.clearRect(0,0,2048,768),i.save(),i.font="bold 560px Orbitron, sans-serif",i.textAlign="center",i.textBaseline="middle",i.shadowColor="rgba(0,200,255,0.35)",i.shadowBlur=80,i.fillStyle="rgba(255,255,255,0.055)",i.fillText("V2",2048*.28,768*.5),i.restore(),i.save(),i.font="bold 148px Orbitron, sans-serif",i.textAlign="center",i.textBaseline="middle",i.shadowColor="rgba(0,200,255,0.2)",i.shadowBlur=40,i.fillStyle="rgba(255,255,255,0.038)",i.fillText("by ZARDOY",2048*.72,768*.52),i.restore();let s=new W.CanvasTexture(r),o=new W.Mesh(new W.PlaneGeometry(280,105),new W.MeshBasicMaterial({map:s,transparent:!0,opacity:1,depthWrite:!1,side:W.DoubleSide,blending:W.AdditiveBlending}));o.position.set(8,4,-320),this.scene.add(o)}spawnBlock(e,t,r){let i=this.createBlockMaterial(e,r),s=new W.Mesh(this.bGeo,i),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:r};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[r,i]=e.blockOpacity??[.32,.46];return new W.MeshBasicMaterial({color:$t(e.blocks),transparent:!0,opacity:r+Math.random()*(i-r),depthWrite:!1,blending:W.AdditiveBlending})}removeBlockEdgeLines(){for(let e of this.blocks){let t=e.mesh.children.filter(r=>r instanceof W.LineSegments);for(let r of t){e.mesh.remove(r),r.geometry?.dispose();let i=r.material;Array.isArray(i)?i.forEach(s=>s.dispose()):i.dispose()}}}async ensureMcDataLoaded(){let e=globalThis._LOAD_MC_DATA;e&&await e()}resolveBlockAtlasUv(e,t,r){let i=s=>{let o=t[s];return o?{u:o.u,v:o.v,su:o.su??r.suSv,sv:o.sv??r.suSv}:null};if(t[e])return i(e);for(let s of["_top","_side","_front","_0"]){let o=i(`${e}${s}`);if(o)return o}for(let s of Object.keys(t))if(s.startsWith(e))return i(s);return null}applyMinecraftTexturesFromAtlas(e){let t=e.currentResources;if(!t?.blocksAtlasImage||!t.blocksAtlasJson)throw new Error("Block atlas not available");let r=t.blocksAtlasJson,i=r.textures;this.atlasTexture=I0(t.blocksAtlasImage),this.atlasTexture.flipY=!1,this.atlasTexture.needsUpdate=!0;for(let s of fn[this.blockGroup]){let o=this.resolveBlockAtlasUv(s,i,r);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 v=s.includes("glass"),l=new W.MeshBasicMaterial({map:a,side:W.DoubleSide,transparent:v,opacity:v?.85:1,alphaTest:v?.08:0,depthWrite:!0,toneMapped:!1});this.blockMaterialPool.set(s,l)}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=$t([...this.blockMaterialPool.keys()]);s.minecraftBlockName=o,s.mesh.material=this.blockMaterialPool.get(o).clone()}}setScene(e){if(!tt.includes(e)||e===this.curScene||this.transitioning)return;this.transitioning=!0,this.curScene=e;let t=za[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 W.MeshBasicMaterial&&s.mesh.material.color.set($t(t.blocks));let r=this.nebGeo.attributes.color;for(let s=0;s<ur;s++){let o=new W.Color($t(t.nebula));r.setXYZ(s,o.r,o.g,o.b)}r.needsUpdate=!0;let i=this.galGeo.attributes.color;for(let s=0;s<dr;s++){let o=.2+Math.random()*.8,a=t.galFn(o);i.setXYZ(s,a.r,a.g,a.b)}i.needsUpdate=!0,this.transitioning=!1},150)}setCamera(e){rt.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(it.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&&wt(this.camera,this.documentRenderer.canvas);let r=o9[this.curCam],i=this.cameraSpeed,s=this.blockSpeed;this.camT+=e*r.spd*i,this.mx+=(this.tmx-this.mx)*.05,this.my+=(this.tmy-this.my)*.05;let o=this.mx*Fa,a=this.my*Fa,v=r.pos(this.camT,o,a),l=r.look(this.camT,o,a);this.camera.position.set(v.x,v.y,v.z),this.camera.lookAt(l.x,l.y,l.z),this.camera.rotation.z=r.roll(this.camT,o);let c=a9[this.curCam]*s;this.animTime+=e*1e3*s;for(let u of this.blocks){if(u.mesh.position.z+=u.spd*c*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*c,u.mesh.rotation.y+=u.ry*c,u.mesh.rotation.z+=u.rz,!this.useMinecraftTextures&&u.mesh.material instanceof W.MeshBasicMaterial){let h=u.mesh.userData.baseOpacity??.38;u.mesh.userData.baseOpacity==null&&(u.mesh.userData.baseOpacity=h);let p=.88+Math.abs(Math.sin(this.animTime*8e-4+u.mesh.position.x*.3))*.12;u.mesh.material.opacity=h*p}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()}};E();x();k();R();import*as t5 from"three";import{Vec3 as Ga}from"vec3";E();x();k();R();import l9 from"prismarine-world";import c9 from"prismarine-chunk";var Ua=n=>{let e=l9(n),t=c9(n),r=new e(n).sync,i=d9(r);for(let s of i)if(s.startsWith("set")&&s!=="setColumn"){let o=r[s].bind(r);r[s]=(...a)=>{let v=a[0];v.x!==void 0&&!r.getColumnAt(v)&&r.setColumn(Math.floor(v.x/16),Math.floor(v.z/16),new t(void 0)),o(...a)}}return r};function d9(n){let e=new Set,t=n;do for(let r of Object.getOwnPropertyNames(t))typeof n[r]=="function"&&r!=="constructor"&&e.add(r);while(t=Object.getPrototypeOf(t));return[...e]}var e5=class{constructor(e,t,r){this.documentRenderer=e;this.options=t;this.abortSignal=r;d(this,"_scene");d(this,"_camera");d(this,"worldRenderer");d(this,"WorldRendererClass",_t);this._scene=new t5.Scene,this._scene.background=new t5.Color(3294568),this._camera=new t5.PerspectiveCamera(85,e.canvas.width/e.canvas.height,.05,1e3),this.camera.position.set(0,0,0),this.camera.rotation.set(0,0,0)}get scene(){return this._scene}get camera(){return this._camera}async init(){let e=N0,t=new h0;if(t.currentConfig={version:e,noInventoryGui:!0},await t.updateAssetsData?.({}),this.abortSignal.aborted)return;let r=Ua(e),s=Xa("prismarine-block")(e),a=globalThis.mcData.blocksArray.filter(p=>{if(!p.name.includes("stained_glass"))return!1;let g=s.fromStateId(p.defaultState,0);if(g.shapes?.length!==1)return!1;let y=g.shapes[0];return y[0]===0&&y[1]===0&&y[2]===0&&y[3]===1&&y[4]===1&&y[5]===1}),v=-15,l=100,c=100;for(let p=-l;p<l;p++)for(let g=-c;g<c;g++){let y=a[Math.floor(Math.random()*a.length)];r.setBlockStateId(new Ga(p,g,v),y.defaultState)}this._camera.updateProjectionMatrix(),this._camera.position.set(.5,c/2+.5,.5),this._camera.rotation.set(0,0,0);let u=new Ga(...this._camera.position.toArray()),h=new $0(r,2,u);this.abortSignal.aborted||(this.worldRenderer=new this.WorldRendererClass(this.documentRenderer.renderer,this.options,{version:e,worldView:h,inWorldRenderingConfig:c5,playerStateReactive:G2().reactive,rendererState:J0().reactive,nonReactiveState:J0().nonReactive,resourcesManager:t}),this.worldRenderer instanceof _t&&(this._scene=this.worldRenderer.realScene,this._camera=this.worldRenderer.camera),h.init(u),await this.worldRenderer.waitForChunksToRender(),!this.abortSignal.aborted&&this.setupMouseParallax())}update(e,t){t&&wt(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,r=e.position.y,i;document.body.addEventListener("pointermove",s=>{if(s.pointerType!=="mouse")return;let o=.2,a=s.clientX/window.innerWidth-.5,v=-(s.clientY/window.innerHeight-.5);i?.stop(),i=new Oe(e.position).to({x:t+a*o,y:r+v*o},0),i.start(),e.updateProjectionMatrix()},{signal:this.abortSignal})}};E();x();k();R();import*as Na from"three";var r5=class{constructor(e,t,r={},i=!1){this.documentRenderer=e;this.options=t;d(this,"active");d(this,"abortController",new AbortController);d(this,"mode");d(this,"lastFrameTime",0);this.mode=ln(r,i)}get v2(){return this.active instanceof At?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 Na.Color&&this.documentRenderer.renderer.setClearColor(this.active.scene.background),this.lastFrameTime=performance.now(),this.documentRenderer.render=(t=!1)=>{let r=performance.now(),i=Math.min((r-this.lastFrameTime)/1e3,.05);this.lastFrameTime=r;let s=this.active;s&&(s.update(i,t),this.documentRenderer.renderer.render(s.scene,s.camera))}}createImplementation(e){switch(this.mode){case"v2":return new At(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 e5(this.documentRenderer,this.options,this.abortController.signal);default:return new Xt(this.documentRenderer)}}dispose(){this.active?.dispose(),this.active=void 0,this.abortController.abort()}};Q5.ColorManagement.enabled=!1;globalThis.THREE=Q5;var Wa=n=>({updateMap:n.entities.updateMap.bind(n.entities),updateCustomBlock:n.updateCustomBlock.bind(n),getBlockInfo:n.getBlockInfo.bind(n),playEntityAnimation:n.entities.playAnimation.bind(n.entities),damageEntity:n.entities.handleDamageEvent.bind(n.entities),updatePlayerSkin:n.entities.updatePlayerSkin.bind(n.entities),changeHandSwingingState:n.changeHandSwingingState.bind(n),getHighestBlocks:n.getHighestBlocks.bind(n),reloadWorld:n.reloadWorld.bind(n),updateEntityModel:n.entities.updateEntityModel.bind(n.entities),playEntityModelAnimation:n.entities.playEntityModelAnimation.bind(n.entities),addMedia:n.media.addMedia.bind(n.media),destroyMedia:n.media.destroyMedia.bind(n.media),setControlMode:n.media.setControlMode.bind(n.media),setVideoPlaying:n.media.setVideoPlaying.bind(n.media),setVideoSeeking:n.media.setVideoSeeking.bind(n.media),setVideoVolume:n.media.setVideoVolume.bind(n.media),setVideoSpeed:n.media.setVideoSpeed.bind(n.media),handleUserClick:n.media.handleUserClick.bind(n.media),addSectionAnimation(e,t){n.sectionsOffsetsAnimations[e]=t},removeSectionAnimation(e){delete n.sectionsOffsetsAnimations[e]},shakeFromDamage:n.cameraShake.shakeFromDamage.bind(n.cameraShake),onPageInteraction:n.media.onPageInteraction.bind(n.media),downloadMesherLog:n.downloadMesherLog.bind(n),explodeFirework:n.fireworksLegacy.explode.bind(n.fireworksLegacy),explodeFireworkFacingCamera:n.fireworksLegacy.explodeFacingCamera.bind(n.fireworksLegacy),addWaypoint:n.waypoints.addWaypoint.bind(n.waypoints),removeWaypoint:n.waypoints.removeWaypoint.bind(n.waypoints),startCinimaticScript:n.cinimaticScript.startScript.bind(n.cinimaticScript),stopCinimaticScript:n.cinimaticScript.stopScript.bind(n.cinimaticScript),launchFirework:n.fireworks.launchFirework.bind(n.fireworks),setSkyboxImage:n.skyboxRenderer.setSkyboxImage.bind(n.skyboxRenderer),setRain:e=>n.toggleModule("rain",e),spawnBlockBreakParticles(e,t,r,i,s,o){n.getModule("blockBreakParticles")?.spawnBlockBreakParticles(e,t,r,i,s,o)},spawnBlockCrackParticle(e,t,r,i,s,o,a){n.getModule("blockBreakParticles")?.spawnCrackParticle(e,t,r,i,s,o,a)},async loadGeometryExport(e){let{applyWorldGeometryExport:t}=await Promise.resolve().then(()=>(Ji(),ha));return t(n,e)},feedChunkPacket(e){let{kind:t,...r}=e,i={type:t,...r};for(let s of n.workers)s.postMessage(i)},getChunksDebugState(){let e={};for(let t of Object.keys(n.sectionObjects)){let[r,,i]=t.split(",").map(Number);e[`${r},${i}`]=!0}return{loadedSectionsChunks:e,loadedChunks:{...n.loadedChunks},finishedChunks:{...n.finishedChunks}}}}),f9=[],fr=(n,...e)=>{for(let t of Object.values(globalThis.loadedMods??{}))try{t.threeJsBackendModule?.[n]?.(...e)}catch(r){let i=`[mod three.js] Error calling ${n} on ${t.name}: ${r}`;throw new Error(i)}},Va=()=>{let n,e=null,t=null,r=null,i=null,s=(c,u)=>{ae?n=E5(c,f9,globalThis):n=c,e=new h5(n,u?.canvas),globalThis.renderer=e.renderer,globalThis.documentRenderer=e,globalThis.threeJsBackend=l,fr("default",l)},o=async c=>{if(!e)throw new Error("Document renderer not initialized");r&&(r.destroy(),r=null,i=null,globalThis.world=void 0,globalThis.frameTimingCollector=void 0),t&&(t.dispose(),t=null);let u={...n.config.menuBackground,...c};t=new r5(e,{...n},u,!!D.env.SINGLE_FILE_BUILD_MODE),fr("menuBackgroundCreated",t),await t.start(u),fr("menuBackgroundReady",t)},a=async c=>{if(!e)throw new Error("Document renderer not initialized");t&&(t.dispose(),t=null),r&&(r.destroy(),r=null,i=null,globalThis.world=void 0,globalThis.frameTimingCollector=void 0);let h=ae?E5(c,[h0,X0],globalThis):c;e.nonReactiveState=h.nonReactiveState,globalThis.resourcesManager=h.resourcesManager,r=new _t(e.renderer,n,h),await r.worldReadyPromise,i=h.inWorldRenderingConfig.enableDebugOverlay?new h1(h.nonReactiveState):null,globalThis.frameTimingCollector=i;let p=e.render;e.render=function(g){p.call(this,g),i?.markFrameStart(),h.inWorldRenderingConfig.paused||r?.render(g),i?.markFrameEnd(),i?.markFrameDisplay()},e.inWorldRenderingConfig=h.inWorldRenderingConfig,globalThis.world=r,fr("worldReady",r)},v=()=>{t&&(t.dispose(),t=null),e&&e.dispose(),r&&(r.destroy(),r=null)},l={id:"threejs",displayName:`three.js ${Q5.REVISION}`,startMenuBackground:o,startWorld:a,disconnect:v,setRendering(c){e.setPaused(!c),r&&(r.renderingActive=c)},getMenuBackground:()=>t??void 0,getDebugOverlay:()=>({get entitiesString(){return r?.entities.getDebugString()},get left(){return{"Geo Memory":r?.chunkMeshManager.getEstimatedMemoryUsage().total??"-"}}}),updateCamera(c,u,h){i?.markCameraUpdate(!c),r?.setFirstPersonCamera(c,u,h)},get soundSystem(){return r?.soundSystem},get backendMethods(){if(r)return Wa(r)}};return{main:{init:s,backend:l},workerProxy(){return ps({init(c,u){s(c,{canvas:u})},updateSizeExternal(c,u,h){e?.updateSizeExternal(c,u,h)},startMenuBackground:o,startWorld:a,disconnect:v,setRendering:l.setRendering,updateCamera(c,u,h){let p=c?new u9(c.x,c.y,c.z):null;i?.markCameraUpdate(!p),l.updateCamera(p,u,h)},async callBackendMethod(c,...u){if(!r)throw new Error("World renderer not initialized");let p=Wa(r)[c];if(!p)throw new Error(`Backend method ${String(c)} is unavailable`);return p(...u)}})}}};var hr=n=>{let{main:e}=Va();return e.init(n),e.backend};hr.id="threejs";hr.displayName="three.js Blocking";hr.description="Simple, old and stable main thread graphics backend providing balanced performance on top of WebGL2.";E();x();k();R();import*as ja from"three";function h9(n){let e="threeWorker.js",t;if(D.env.SINGLE_FILE_BUILD){let r=document.getElementById("three-worker-code").textContent,i=new Blob([r],{type:"text/javascript"});t=new Worker(window.URL.createObjectURL(i))}else t=new Worker(e);return t.onmessage=({data:r})=>{n(r)},t.on&&t.on("message",r=>{t.onmessage({data:r})}),t}var mr=async n=>{let e=h9(()=>{}),t=gs(e),r=Pr();r.onSizeChanged((a,v)=>{t.updateSizeExternal(a,v,window.devicePixelRatio||1)});let i=A5(n,e);try{t.init(i,r.canvas)}catch(a){throw ot(i),a}let s=new Proxy({},{get(a,v){if(typeof v=="string")return async(...l)=>t.callBackendMethod(v,...l)}});return{id:"threejs",displayName:`three.js ${ja.REVISION}`,async startMenuBackground(a){let v=a?.resourcesManager?.currentResources?.mcData;if(v){let c={...at,items:"itemsArray",entities:"entitiesArray"};await Xr([e],N0,c,v)}let l=A5(a??{},e);try{await t.startMenuBackground(structuredClone(l))}catch(c){throw ot(l),c}},async startWorld(a){let v={...at,items:"itemsArray",entities:"entitiesArray"};await Xr([e],a.version,v,a.resourcesManager.currentResources.mcData),a.inWorldRenderingConfig.__syncToWorker=!0,a.playerStateReactive&&(a.playerStateReactive.__syncToWorker=!0),a.rendererState&&(a.rendererState.__syncFromWorker=!0),a.nonReactiveState&&(a.nonReactiveState.__syncFromWorker=!0),a.nonReactiveState.__syncFromWorkerInterval=200;let l=A5(a,e);try{await t.startWorld(structuredClone(l))}catch(h){throw ot(l),h}t.updateSizeExternal(r.size.width,r.size.height,window.devicePixelRatio||1);let c=lt("fps");setInterval(()=>{let{fps:h,avgRenderTime:p,worstRenderTime:g}=a.nonReactiveState;c.updateText(`FPS: ${h.toFixed(0)} (${p.toFixed(0)}ms/${g.toFixed(0)}ms)`),a.nonReactiveState.fps=0},1e3);let u=lt("downloaded-chunks",100,140,20,{className:vt});setInterval(()=>{let h=(n.config.statsVisible??0)>1;u.setVisibility(h),h&&u.updateText(a.nonReactiveState.world.chunksFullInfo)},200)},disconnect(){r.destroy(),t.disconnect(),e.terminate()},setRendering(a){t.setRendering(a)},updateCamera(a,v,l){t.updateCamera(a?{x:a.x,y:a.y,z:a.z}:null,v,l)},soundSystem:void 0,backendMethods:s}};mr.id="threejs-off-thread";mr.displayName="three.js Multi-thread";mr.description=["Edge-cutting technology that uses a dedicated thread for graphics.","Slightly higher power and RAM usage.","More stable FPS (mid-range devices), but possible inputlag if TPS is low.","On low-end devices it might result in device throttling and stuttering."].join(" ");export{ns as AppViewer,Xt as ClassicMenuBackground,h5 as DocumentRenderer,Ar as HIGH_TEXTURE_COUNT,r1 as LONG_RENDER_TIME_MS,wr as LOW_FPS_THRESHOLD,Bt as LoadedResourcesTransferrable,vt as MC_RENDERER_DEBUG_OVERLAY_CLASS,N0 as MENU_BACKGROUND_MC_VERSION,b5 as MENU_BACKGROUND_MOTION_DEFAULTS,b0 as MENU_BACKGROUND_OPTION_DEFAULTS,fn as MINECRAFT_BLOCK_GROUPS,it as MINECRAFT_BLOCK_GROUP_IDS,g5 as MINECRAFT_BLOCK_GROUP_LABELS,r5 as MenuBackgroundRenderer,l5 as PerformanceMonitor,ss as RENDERER_DEFAULT_OPTIONS,os as RENDERER_OPTIONS_META,as as RENDERER_RENDER_GUI_SECTIONS,h0 as ResourcesManager,At as V2MenuBackground,rt as V2_CAMERA_IDS,p5 as V2_CAMERA_LABELS,tt as V2_SCENE_IDS,m5 as V2_SCENE_LABELS,e5 as WorldBlocksMenuBackground,$0 as WorldView,X0 as WorldViewWorker,Pr as addCanvasForWorker,H6 as applyMenuBackgroundLiveOptions,_f as applyRendererEnableLighting,L6 as applyRendererOptions,bf as applyRendererWorldViewOptions,Mt as chunkPos,mr as createGraphicsBackendOffThread,hr as createGraphicsBackendSingleThread,El as createWorldRendererConfig,L2 as defaultGraphicsBackendConfig,_r as defaultPerformanceInstabilityFactors,c5 as defaultWorldRendererConfig,W2 as delayedIterator,Er as formatPerformanceFactorsDebug,J0 as getDefaultRendererState,ds as getInitialPlayerState,N6 as getInitialPlayerStateRenderer,G6 as getPlayerStateUtils,ae as isWebWorker,gf as menuBackgroundOptionsFromStorage,E0 as menuBackgroundSpeedToMultiplier,x6 as migrateRendererOptions,Or as rendererShaderCubeDebugModeToValue,d6 as sectionPos,yf as subscribeRendererOptions};
|
|
21510
21510
|
/*! Bundled license information:
|
|
21511
21511
|
|
|
21512
21512
|
@jspm/core/nodelibs/browser/chunk-DtuTasat.js:
|