minecraft-renderer 0.1.32 → 0.1.33

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.
@@ -444,7 +444,7 @@ var rs=Object.create;var Be=Object.defineProperty;var ss=Object.getOwnPropertyDe
444
444
  @font-face {
445
445
  font-family: "lil-gui";
446
446
  src: url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff");
447
- }`;function $o(r){let t=document.createElement("style");t.innerHTML=r;let e=document.querySelector("head link[rel=stylesheet], head style");e?document.head.insertBefore(t,e):document.head.appendChild(t)}var Ur=!1,w2=class r{constructor({parent:t,autoPlace:e=t===void 0,container:i,width:n,title:s="Controls",closeFolders:o=!1,injectStyles:a=!0,touchStyles:v=!0}={}){if(this.parent=t,this.root=t?t.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",l=>{(l.code==="Enter"||l.code==="Space")&&(l.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(s),this.parent){this.parent.children.push(this),this.parent.folders.push(this),this.parent.$children.appendChild(this.domElement);return}this.domElement.classList.add("root"),v&&this.domElement.classList.add("allow-touch-styles"),!Ur&&a&&($o(Xo),Ur=!0),i?i.appendChild(this.domElement):e&&(this.domElement.classList.add("autoPlace"),document.body.appendChild(this.domElement)),n&&this.domElement.style.setProperty("--width",n+"px"),this._closeFolders=o}add(t,e,i,n,s){if(Object(i)===i)return new b2(this,t,e,i);switch(typeof t[e]){case"number":return new g2(this,t,e,i,n,s);case"boolean":return new h2(this,t,e);case"string":return new y2(this,t,e);case"function":return new Je(this,t,e)}}addColor(t,e,i=1){return new p2(this,t,e,i)}addFolder(t){let e=new r({parent:this,title:t});return this.root._closeFolders&&e.close(),e}load(t,e=!0){return t.controllers&&this.controllers.forEach(i=>{i instanceof Je||i._name in t.controllers&&i.load(t.controllers[i._name])}),e&&t.folders&&this.folders.forEach(i=>{i._title in t.folders&&i.load(t.folders[i._title])}),this}save(t=!0){let e={controllers:{},folders:{}};return this.controllers.forEach(i=>{if(!(i instanceof Je)){if(i._name in e.controllers)throw new Error(`Cannot save GUI with duplicate property "${i._name}"`);e.controllers[i._name]=i.save()}}),t&&this.folders.forEach(i=>{if(i._title in e.folders)throw new Error(`Cannot save GUI with duplicate folder "${i._title}"`);e.folders[i._title]=i.save()}),e}open(t=!0){return this._setClosed(!t),this.$title.setAttribute("aria-expanded",!this._closed),this.domElement.classList.toggle("closed",this._closed),this}close(){return this.open(!1)}_setClosed(t){this._closed!==t&&(this._closed=t,this._callOnOpenClose(this))}show(t=!0){return this._hidden=!t,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}openAnimated(t=!0){return this._setClosed(!t),this.$title.setAttribute("aria-expanded",!this._closed),requestAnimationFrame(()=>{let e=this.$children.clientHeight;this.$children.style.height=e+"px",this.domElement.classList.add("transition");let i=s=>{s.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",i))};this.$children.addEventListener("transitionend",i);let n=t?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!t),requestAnimationFrame(()=>{this.$children.style.height=n+"px"})}),this}title(t){return this._title=t,this.$title.innerHTML=t,this}reset(t=!0){return(t?this.controllersRecursive():this.controllers).forEach(i=>i.reset()),this}onChange(t){return this._onChange=t,this}_callOnChange(t){this.parent&&this.parent._callOnChange(t),this._onChange!==void 0&&this._onChange.call(this,{object:t.object,property:t.property,value:t.getValue(),controller:t})}onFinishChange(t){return this._onFinishChange=t,this}_callOnFinishChange(t){this.parent&&this.parent._callOnFinishChange(t),this._onFinishChange!==void 0&&this._onFinishChange.call(this,{object:t.object,property:t.property,value:t.getValue(),controller:t})}onOpenClose(t){return this._onOpenClose=t,this}_callOnOpenClose(t){this.parent&&this.parent._callOnOpenClose(t),this._onOpenClose!==void 0&&this._onOpenClose.call(this,t)}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(t=>t.destroy())}controllersRecursive(){let t=Array.from(this.controllers);return this.folders.forEach(e=>{t=t.concat(e.controllersRecursive())}),t}foldersRecursive(){let t=Array.from(this.folders);return this.folders.forEach(e=>{t=t.concat(e.foldersRecursive())}),t}},_2=w2;var yt=class{constructor(t,e,i,n){f(this,"gui",null);f(this,"storageKey","");f(this,"target");f(this,"params",[]);f(this,"paramsMeta",{});f(this,"_visible",!1);f(this,"initialValues",{});f(this,"initialized",!1);if(!w0){this.gui=new _2,this.storageKey=`debug_params_${t}`,this.target=e,this.paramsMeta=n??{},this.params=i??Object.keys(e);for(let s of this.params)this.initialValues[s]=e[s];this.gui.domElement.style.display="none"}}activate(){return w0?this:(!this.initialized&&this.gui&&(this.loadSavedValues(),this.setupControls(),this.initialized=!0),this.show(),this)}get visible(){return w0?!1:this._visible}set visible(t){w0||!this.gui||(this._visible=t,this.gui.domElement.style.display=t?"block":"none",this.saveVisibility())}loadSavedValues(){if(!w0)try{let t=localStorage.getItem(this.storageKey);if(t){let e=JSON.parse(t);for(let i of this.params)if(i in e){let n=e[i];n!==null&&(this.target[i]=n)}}}catch{}}saveValues(t=!1){if(!w0)try{let e={};for(let i of this.params)e[i]=this.target[i];t?localStorage.removeItem(this.storageKey):localStorage.setItem(this.storageKey,JSON.stringify(e))}catch{}}saveVisibility(){if(!w0)try{localStorage.setItem(`${this.storageKey}_visible`,this._visible.toString())}catch{}}setupControls(){if(!(w0||!this.gui)){this.gui.add(this,"visible").name("Show Controls"),this.gui.add({resetAll:()=>{if(this.gui){for(let t of this.params)this.target[t]=this.initialValues[t];this.saveValues(!0),this.gui.destroy(),this.gui=new _2,this.setupControls()}}},"resetAll").name("Reset All Parameters");for(let t of this.params){let e=this.target[t],i=this.paramsMeta[t]??{};if(typeof e=="number"){let n=i.min??e-Math.abs(e*2),s=i.max??e+Math.abs(e*2),o=i.step??Math.abs(e)/100;this.gui.add(this.target,t,n,s,o).onChange(()=>this.saveValues())}else if(typeof e=="boolean")this.gui.add(this.target,t).onChange(()=>this.saveValues());else if(typeof e=="string"&&["x","y","z"].includes(t)){let n=i.min??-10,s=i.max??10,o=i.step??.1;this.gui.add(this.target,t,n,s,o).onChange(()=>this.saveValues())}else Array.isArray(e)&&this.gui.add(this.target,t,e).onChange(()=>this.saveValues())}}}save(){w0||(this.saveValues(),this.saveVisibility())}destroy(){w0||!this.gui||(this.saveVisibility(),this.gui.destroy())}toggle(){this.visible=!this.visible}show(){this.visible=!0}hide(){this.visible=!1}};x();R();T();k();x();R();T();k();var Q5=class{constructor(){f(this,"currentAnimation",null);f(this,"isAnimating",!1);f(this,"cancelRequested",!1);f(this,"completionCallbacks",[]);f(this,"currentCancelCallback",null)}async startAnimation(t,e){return this.isAnimating&&await this.cancelCurrentAnimation(),new Promise(i=>{this.isAnimating=!0,this.cancelRequested=!1,this.currentCancelCallback=e??null,this.currentAnimation=t(),this.completionCallbacks.push(()=>{this.isAnimating=!1,this.currentAnimation=null,i()})})}async cancelCurrentAnimation(){if(this.isAnimating){if(this.currentCancelCallback){let t=this.currentCancelCallback;this.currentCancelCallback=null,t()}return new Promise(t=>{this.cancelRequested=!0,this.completionCallbacks.push(()=>{t()})})}}animationCycleFinish(){this.cancelRequested&&this.forceFinish()}forceFinish(t=!0){if(!this.isAnimating)return;if(this.currentAnimation){for(let i of this.currentAnimation.getAll())i.stop();this.currentAnimation.removeAll(),this.currentAnimation=null}this.isAnimating=!1,this.cancelRequested=!1;let e=[...this.completionCallbacks];if(this.completionCallbacks=[],t)for(let i of e)i()}update(){this.currentAnimation&&this.currentAnimation.update()}get isActive(){return this.isAnimating}get shouldCancel(){return this.cancelRequested}};var ta={x:3e3,y:3e3,z:3e3,rotation:Math.PI,scale:1,default:3e3},Jt=class{constructor(t,e,i){this.getState=t;this.setState=e;f(this,"animationController",new Q5);f(this,"defaultState");f(this,"speeds");f(this,"currentStateName","");f(this,"transitioningToStateName","");this.speeds={...ta},i&&Object.assign(this.speeds,i),this.defaultState=this.getState()}calculateDuration(t){let e=0,i=this.getState();for(let[n,s]of Object.entries(t)){let o=i[n],a=Math.abs(s-o),v=this.getPropertySpeed(n),l=a/v*1e3;e=Math.max(e,l)}return Math.min(Math.max(e,200),2e3)}getPropertySpeed(t){return t in this.speeds?this.speeds[t]:t.toLowerCase().includes("rotation")?this.speeds.rotation:t.toLowerCase().includes("scale")?this.speeds.scale:t.toLowerCase()==="x"||t.toLowerCase()==="y"||t.toLowerCase()==="z"?this.speeds[t]:this.speeds.default}startTransition(t,e,i,n=k0.Linear.None,s){this.isTransitioning&&this.animationController.forceFinish(!1),this.transitioningToStateName=e??"";let o=this.getState(),a=this.calculateDuration(t);this.animationController.startAnimation(()=>{let v=new ve;return new M0(o,v).to(t,a).easing(n).onUpdate(l=>{for(let c of Object.keys(l))this.setState(c,l[c])}).onComplete(()=>{this.animationController.forceFinish(),this.currentStateName=this.transitioningToStateName,this.transitioningToStateName="",i?.()}).start(),v},s)}reset(){this.startTransition(this.defaultState)}update(){this.animationController.update()}forceFinish(){this.animationController.forceFinish()}transitionTo(t,e,i,n){this.startTransition(t,e,i,k0.Linear.None,n)}getCurrentValue(t){return this.getState()[t]}get isTransitioning(){return this.animationController.isActive}};x();R();T();k();import{subscribeKey as ea}from"valtio/utils";function Y5(r,t,e,i,n){let s=0,o,a=async()=>{let v=++s,l=await r(t[e]);v===s?(o&&n?.(o),i(l),o=l):n?.(l)};return a(),ea(t,e,a)}x();R();T();k();var Gr=Math.PI/180;function K5(r){let{walkDist:t,prevWalkDist:e,bob:i,prevBob:n,partialTick:s}=r,o=t-e,a=-(t+o*s),v=n+(i-n)*s,l=Math.sin(a*Math.PI),c=Math.cos(a*Math.PI);return{position:{x:l*v*.5,y:-Math.abs(c*v)},rotation:{x:Math.abs(Math.cos(a*Math.PI-.2)*v)*5*Gr,z:l*v*3*Gr}}}var U0=new A0.Matrix4;function na(r,t){let e=new A0.Matrix4,i=1,n=Math.sqrt(r),s=-.3*Math.sin(n*Math.PI),o=.4*Math.sin(n*2*Math.PI),a=-.4*Math.sin(r*Math.PI);return e.multiply(U0.makeTranslation(i*(s+.64),o-.6+t*-.6,a-.72)),e.multiply(U0.makeRotationY(i*45*Math.PI/180)),e.multiply(U0.makeRotationY(i*Math.sin(n*Math.PI)*70*Math.PI/180)),e.multiply(U0.makeRotationZ(i*Math.sin(r*r*Math.PI)*-20*Math.PI/180)),e.multiply(U0.makeTranslation(i*-1,3.6,3.5)),e.multiply(U0.makeRotationZ(i*120*Math.PI/180)),e.multiply(U0.makeRotationX(200*Math.PI/180)),e.multiply(U0.makeRotationY(i*-135*Math.PI/180)),e.multiply(U0.makeTranslation(i*5.6,0,0)),e.multiply(U0.makeTranslation(i*-5/16,2/16,0)),e}function ra(r,t){let e=new A0.Matrix4,i=1,n=Math.sqrt(r),s=-.4*Math.sin(n*Math.PI),o=.2*Math.sin(n*2*Math.PI),a=-.2*Math.sin(r*Math.PI);e.multiply(U0.makeTranslation(i*s,o,a)),e.multiply(U0.makeTranslation(i*.56,-.52+t*-.6,-.72));let v=Math.sin(r*r*Math.PI),l=Math.sin(n*Math.PI);return e.multiply(U0.makeRotationY(i*(45+v*-20)*Math.PI/180)),e.multiply(U0.makeRotationZ(i*l*-20*Math.PI/180)),e.multiply(U0.makeRotationX(l*-80*Math.PI/180)),e.multiply(U0.makeRotationY(i*-45*Math.PI/180)),e}var Ze=class{constructor(t,e=!1){this.worldRenderer=t;this.offHand=e;f(this,"holdingBlock");f(this,"blockSwapAnimation");f(this,"cameraGroup",new A0.Mesh);f(this,"armTransformGroup",new A0.Group);f(this,"camera",new A0.PerspectiveCamera(70,1,.05,100));f(this,"equipProgress",0);f(this,"stopUpdate",!1);f(this,"lastHeldItem");f(this,"currentDisplayType","hand");f(this,"isSwinging",!1);f(this,"nextIterStopCallbacks");f(this,"idleAnimator");f(this,"ready",!1);f(this,"lastUpdate",0);f(this,"xBob",0);f(this,"yBob",0);f(this,"lastBobUpdateTime",0);f(this,"lastBobWalkDist",0);f(this,"lastBobTickTime",0);f(this,"playerHand");f(this,"offHandDisplay",!1);f(this,"offHandModeLegacy",!1);f(this,"swingAnimator");f(this,"config");f(this,"disposed",!1);f(this,"unsubs",[]);f(this,"lastItemModelName");f(this,"switchRequest",0);this.initCameraGroup(),this.unsubs.push(this.worldRenderer.onReactivePlayerStateUpdated("heldItemMain",()=>{this.offHand||this.updateItem()},!1),this.worldRenderer.onReactivePlayerStateUpdated("heldItemOff",()=>{this.offHand&&this.updateItem()},!1)),this.config=t.displayOptions.inWorldRenderingConfig,this.offHandDisplay=this.offHand,this.offHand||Xe().then(i=>{this.disposed||(this.playerHand=i,this.updateItem())}).then(()=>{if(this.disposed)return;let i=Y5(async()=>Xe(this.worldRenderer.playerStateReactive.playerSkin,this.worldRenderer.playerStateReactive.onlineMode?this.worldRenderer.playerStateReactive.username:void 0),this.worldRenderer.playerStateReactive,"playerSkin",n=>{n&&(this.playerHand=n,this.updateItem())},n=>{x0(n,!0)});this.unsubs.push(i)})}dispose(){this.disposed=!0,this.unsubs.forEach(t=>t()),this.unsubs=[],this.idleAnimator?.destroy(),this.idleAnimator=void 0,this.swingAnimator?.stopSwing(),this.swingAnimator=void 0,this.blockSwapAnimation?.switcher.forceFinish(),this.blockSwapAnimation=void 0,x0(this.cameraGroup,!0),this.holdingBlock&&this.holdingBlock!==this.playerHand&&x0(this.holdingBlock,!0),this.holdingBlock=void 0,this.playerHand&&(x0(this.playerHand,!0),this.playerHand=void 0),this.ready=!1}updateItem(){if(!this.ready)return;let t=this.offHand?this.worldRenderer.playerStateReactive.heldItemOff:this.worldRenderer.playerStateReactive.heldItemMain;t?this.setNewItem(t):this.offHand?this.setNewItem():this.setNewItem({type:"hand"})}initCameraGroup(){this.cameraGroup=new A0.Mesh,this.armTransformGroup=new A0.Group,this.armTransformGroup.matrixAutoUpdate=!1,this.cameraGroup.add(this.armTransformGroup)}startSwing(){this.swingAnimator?.startSwing()}stopSwing(){this.swingAnimator?.stopSwing()}render(t,e,i,n){if(!this.lastHeldItem)return;let s=performance.now();this.lastUpdate&&s-this.lastUpdate>50&&this.replaceItemModel(this.lastHeldItem),(this.swingAnimator?.isCurrentlySwinging()||this.swingAnimator?.debugParams.animationStage)&&this.swingAnimator?.update(),this.blockSwapAnimation?.switcher.update();let o=new A0.Scene;o.add(this.cameraGroup);let a=e.getSize(new A0.Vector2),v=a.height>a.width;v?this.camera.aspect!==1&&(this.camera.aspect=1,this.camera.updateProjectionMatrix()):this.camera.aspect!==t.aspect&&(this.camera.aspect=t.aspect,this.camera.updateProjectionMatrix()),this.updateCameraGroup(),o.add(i.clone()),o.add(n.clone());let{offHandDisplay:l}=this;if(l&&(this.cameraGroup.scale.x=-1),e.autoClear=!1,e.clearDepth(),v){let c=Math.min(a.width,a.height);l?e.setViewport(0,0,c,c):e.setViewport(a.width-c,0,c,c)}e.render(o,this.camera),v&&e.setViewport(0,0,a.width,a.height),l&&(this.cameraGroup.scale.x=1)}async playBlockSwapAnimation(t){this.blockSwapAnimation??(this.blockSwapAnimation={switcher:new Jt(()=>({progress:this.equipProgress}),(n,s)=>{n==="progress"&&(this.equipProgress=s)},{progress:4})});let e=t==="disappeared"?1:0,i=!1;return new Promise(n=>{this.blockSwapAnimation.switcher.transitionTo({progress:e},t,()=>{i||n(!0)},()=>{i=!0,n(!1)})})}isDifferentItem(t){let e=ia(this.worldRenderer.version);return!this.lastHeldItem||this.lastHeldItem.name!==t?.name||!e.equal(this.lastHeldItem.fullItem,t?.fullItem??{})||JSON.stringify(this.lastHeldItem.fullItem.components)!==JSON.stringify(t?.fullItem?.components)}updateCameraGroup(){if(this.stopUpdate)return;let{camera:t}=this,e=performance.now(),i=this.worldRenderer.cameraShake.getBaseRotation(),n=i.pitch,s=i.yaw;if(this.lastBobUpdateTime===0)this.xBob=n,this.yBob=s,this.lastBobUpdateTime=e;else{let m=Math.min((e-this.lastBobUpdateTime)/1e3,.1);this.lastBobUpdateTime=e;let p=1-Math.pow(.5,m*20);this.xBob+=(n-this.xBob)*p,this.yBob+=(s-this.yBob)*p}let o=(n-this.xBob)*-.1,a=(s-this.yBob)*-.1;if(this.cameraGroup.position.copy(t.position),this.cameraGroup.rotation.copy(t.rotation),this.worldRenderer.displayOptions.inWorldRenderingConfig.viewBobbing){let m=this.worldRenderer.playerStateReactive;m.walkDist!==this.lastBobWalkDist&&(this.lastBobTickTime=e,this.lastBobWalkDist=m.walkDist);let p=Math.min((e-this.lastBobTickTime)/50,1),g=K5({walkDist:m.walkDist,prevWalkDist:m.prevWalkDist,bob:m.bob,prevBob:m.prevBob,partialTick:p});this.cameraGroup.position.x+=g.position.x,this.cameraGroup.position.y+=g.position.y,this.cameraGroup.rotation.z+=g.rotation.z,this.cameraGroup.rotation.x+=g.rotation.x}this.cameraGroup.rotation.x+=o,this.cameraGroup.rotation.y+=a;let l=this.currentDisplayType,c=this.swingAnimator?.getSwingProgress()??0,d;l==="hand"?d=na(c,this.equipProgress):d=ra(c,this.equipProgress),this.armTransformGroup.matrix.copy(d),this.armTransformGroup.matrixWorldNeedsUpdate=!0}async createItemModel(t){if(this.lastUpdate=performance.now(),!t||t.type==="hand"&&!this.playerHand)return;let e;if(t.type==="item"||t.type==="block"){let i=this.worldRenderer.entities.getItemMesh({...t.fullItem,itemId:t.id},{"minecraft:display_context":"firstperson","minecraft:use_duration":this.worldRenderer.playerStateReactive.itemUsageTicks,"minecraft:using_item":!!this.worldRenderer.playerStateReactive.itemUsageTicks},!1,this.lastItemModelName);if(i){let{mesh:n,isBlock:s,modelName:o}=i;s?(e=n,t.type="block"):(e=n,t.type="item"),this.lastItemModelName=o}}else e=this.playerHand;if(e){if(t.type==="item"||t.type==="block"){let i=new A0.Group;i.name="displayTransform",t.type==="item"?(i.position.set(1.13/16,3.2/16,1.13/16),i.rotation.set(0,A0.MathUtils.degToRad(-90),A0.MathUtils.degToRad(25),"XYZ"),i.scale.set(.68,.68,.68)):(i.rotation.set(0,A0.MathUtils.degToRad(45),0,"XYZ"),i.scale.set(.4,.4,.4)),i.add(e),e=i}return e.name="holdingBlock",{model:e,type:t.type}}}async replaceItemModel(t){if(this.blockSwapAnimation?.switcher.isTransitioning)return;if(!t){this.holdingBlock?.removeFromParent(),this.holdingBlock=void 0,this.currentDisplayType="hand",this.swingAnimator?.stopSwing(),this.swingAnimator=void 0,this.idleAnimator=void 0;return}let e=await this.createItemModel(t);e&&(this.holdingBlock?.removeFromParent(),this.holdingBlock=e.model,this.currentDisplayType=e.type,this.armTransformGroup.add(e.model))}testUnknownBlockSwitch(){this.setNewItem({type:"item",name:"minecraft:some-unknown-block",id:0,fullItem:{}})}async setNewItem(t){if(!this.isDifferentItem(t))return;this.lastItemModelName=void 0;let e=++this.switchRequest;this.lastHeldItem=t;let i=!1;if(this.holdingBlock){if(i=!0,!await this.playBlockSwapAnimation("disappeared"))return;this.holdingBlock.removeFromParent(),this.holdingBlock!==this.playerHand&&x0(this.holdingBlock,!1),this.holdingBlock=void 0}if(!t){this.currentDisplayType="hand",this.swingAnimator=void 0,this.idleAnimator=void 0,this.blockSwapAnimation=void 0;return}if(e!==this.switchRequest)return;let n=await this.createItemModel(t);!n||e!==this.switchRequest||(this.holdingBlock=n.model,this.currentDisplayType=n.type,this.armTransformGroup.add(this.holdingBlock),i&&await this.playBlockSwapAnimation("appeared"),this.swingAnimator=new A2,this.swingAnimator.type=n.type,this.idleAnimator=void 0)}};var A2=class{constructor(){f(this,"animationTimer",0);f(this,"lastTime",0);f(this,"isAnimating",!1);f(this,"stopRequested",!1);f(this,"swingProgress",0);f(this,"type","hand");f(this,"debugParams",{animationTime:250,animationStage:0});f(this,"debugGui");this.debugGui=new yt("hand_animator",this.debugParams,void 0,{animationStage:{min:0,max:1,step:.01}})}update(){if(!this.isAnimating&&!this.debugParams.animationStage){this.swingProgress=0;return}let t=performance.now(),e=(t-this.lastTime)/1e3;this.lastTime=t,this.animationTimer+=e*1e3;let i=this.debugParams.animationStage||Math.min(this.animationTimer/this.debugParams.animationTime,1);if(i>=1){if(this.stopRequested){this.isAnimating=!1,this.stopRequested=!1,this.animationTimer=0,this.swingProgress=0;return}this.animationTimer=0,this.swingProgress=0;return}this.swingProgress=i}getSwingProgress(){return this.swingProgress}startSwing(){this.stopRequested=!1,!this.isAnimating&&(this.isAnimating=!0,this.animationTimer=0,this.lastTime=performance.now())}stopSwing(){this.isAnimating&&(this.stopRequested=!0)}isCurrentlySwinging(){return this.isAnimating}},Wr=(r,t,e,i,n)=>{let s=i.transformModel(t,{name:e,properties:{}});return t2(r,[[s]],void 0,"plains",n)};x();R();T();k();import*as o0 from"three";function sa(r,t){let{depth:e,pixelSize:i}=t;if(r.width<=0||r.height<=0)throw new Error(`Invalid canvas dimensions: ${r.width}x${r.height}`);let s=r.getContext("2d").getImageData(0,0,r.width,r.height),{data:o}=s,a=r.width,v=r.height,l=e/2,c=i??1/Math.max(a,v),d=(B,I)=>{if(B<0||I<0||B>=a||I>=v)return!1;let W=(I*a+B)*4;return o[W+3]>128},m=[],p=[],g=[],y=[],_=0,w=(B,I,W,z,j,J,t0,V)=>(m.push(B,I,W),g.push(z,j),y.push(J,t0,V),_++),A=(B,I,W,z)=>{p.push(B,I,W,B,W,z)},C=(B,I)=>{let W=(B/a-.5)*c*a,z=-(I/v-.5)*c*v;return{x:W,y:z}},S=Array.from({length:v+1},()=>Array.from({length:a+1},()=>null)),M=Array.from({length:v+1},()=>Array.from({length:a+1},()=>null));for(let B=0;B<=v;B++)for(let I=0;I<=a;I++){let{x:W,y:z}=C(I-.5,B-.5),j=I/a,J=B/v,t0=!1,V=[[I-1,B-1],[I,B-1],[I-1,B],[I,B]];for(let[Z,K]of V)if(d(Z,K)){t0=!0;break}t0&&(S[B][I]=w(W,z,l,j,J,0,0,1),M[B][I]=w(W,z,-l,j,J,0,0,-1))}for(let B=0;B<v;B++)for(let I=0;I<a;I++){if(!d(I,B))continue;let W=S[B][I],z=S[B][I+1],j=S[B+1][I+1],J=S[B+1][I],t0=M[B][I],V=M[B][I+1],Z=M[B+1][I+1],K=M[B+1][I];W!==null&&z!==null&&j!==null&&J!==null&&A(W,z,j,J),t0!==null&&V!==null&&Z!==null&&K!==null&&A(V,t0,K,Z)}for(let B=0;B<v;B++)for(let I=0;I<a;I++){if(!d(I,B))continue;let W=(I+.5)/a,z=(B+.5)/v;if(!d(I-1,B)){let j=S[B][I],J=S[B+1][I],t0=M[B][I],V=M[B+1][I];if(j!==null&&J!==null&&t0!==null&&V!==null){let Z=w(m[j*3],m[j*3+1],m[j*3+2],W,z,-1,0,0),K=w(m[J*3],m[J*3+1],m[J*3+2],W,z,-1,0,0),i0=w(m[V*3],m[V*3+1],m[V*3+2],W,z,-1,0,0),r0=w(m[t0*3],m[t0*3+1],m[t0*3+2],W,z,-1,0,0);A(Z,K,i0,r0)}}if(!d(I+1,B)){let j=S[B+1][I+1],J=S[B][I+1],t0=M[B+1][I+1],V=M[B][I+1];if(j!==null&&J!==null&&t0!==null&&V!==null){let Z=w(m[j*3],m[j*3+1],m[j*3+2],W,z,1,0,0),K=w(m[J*3],m[J*3+1],m[J*3+2],W,z,1,0,0),i0=w(m[V*3],m[V*3+1],m[V*3+2],W,z,1,0,0),r0=w(m[t0*3],m[t0*3+1],m[t0*3+2],W,z,1,0,0);A(Z,K,i0,r0)}}if(!d(I,B-1)){let j=S[B][I],J=S[B][I+1],t0=M[B][I],V=M[B][I+1];if(j!==null&&J!==null&&t0!==null&&V!==null){let Z=w(m[j*3],m[j*3+1],m[j*3+2],W,z,0,-1,0),K=w(m[J*3],m[J*3+1],m[J*3+2],W,z,0,-1,0),i0=w(m[V*3],m[V*3+1],m[V*3+2],W,z,0,-1,0),r0=w(m[t0*3],m[t0*3+1],m[t0*3+2],W,z,0,-1,0);A(Z,K,i0,r0)}}if(!d(I,B+1)){let j=S[B+1][I+1],J=S[B+1][I],t0=M[B+1][I+1],V=M[B+1][I];if(j!==null&&J!==null&&t0!==null&&V!==null){let Z=w(m[j*3],m[j*3+1],m[j*3+2],W,z,0,1,0),K=w(m[J*3],m[J*3+1],m[J*3+2],W,z,0,1,0),i0=w(m[V*3],m[V*3+1],m[V*3+2],W,z,0,1,0),r0=w(m[t0*3],m[t0*3+1],m[t0*3+2],W,z,0,1,0);A(Z,K,i0,r0)}}}let H=new o0.BufferGeometry;return H.setAttribute("position",new o0.Float32BufferAttribute(m,3)),H.setAttribute("uv",new o0.Float32BufferAttribute(g,2)),H.setAttribute("normal",new o0.Float32BufferAttribute(y,3)),H.setIndex(p),H.computeVertexNormals(),{geometry:H,totalVertices:_,totalTriangles:p.length/3}}function oa(r,t){let{u:e,v:i,sizeX:n,sizeY:s}=t,o=Math.max(1,Math.floor(n*r.image.width)),a=Math.max(1,Math.floor(s*r.image.height)),v=document.createElement("canvas");v.width=o,v.height=a;let l=v.getContext("2d");return l.imageSmoothingEnabled=!1,l.drawImage(r.image,e*r.image.width,i*r.image.height,n*r.image.width,s*r.image.height,0,0,v.width,v.height),v}function Nr(r,t,e={}){let{faceCamera:i=!1,use3D:n=!0,depth:s=.04}=e,{u:o,v:a,sizeX:v,sizeY:l}=t;if(i){let y=r.clone();y.flipY=!0,y.offset.set(o,1-a-l),y.repeat.set(v,l),y.needsUpdate=!0,y.magFilter=o0.NearestFilter,y.minFilter=o0.NearestFilter;let _=new o0.SpriteMaterial({map:y,transparent:!0,alphaTest:.1});return{mesh:new o0.Sprite(_),itemsTexture:y,cleanup(){y.dispose()}}}if(n)try{let y=oa(r,t),{geometry:_}=sa(y,{depth:s}),w=new o0.CanvasTexture(y);w.magFilter=o0.NearestFilter,w.minFilter=o0.NearestFilter,w.wrapS=w.wrapT=o0.ClampToEdgeWrapping,w.flipY=!1,w.needsUpdate=!0;let A=new o0.MeshStandardMaterial({map:w,side:o0.DoubleSide,transparent:!0,alphaTest:.1});return{mesh:new o0.Mesh(_,A),itemsTexture:w,cleanup(){w.dispose(),_.dispose(),A.map&&A.map.dispose(),A.dispose()}}}catch{}let c=r.clone();c.flipY=!0,c.offset.set(o,1-a-l),c.repeat.set(v,l),c.needsUpdate=!0,c.magFilter=o0.NearestFilter,c.minFilter=o0.NearestFilter;let d=c.clone();d.repeat.x*=-1,d.needsUpdate=!0,d.offset.set(o+v,1-a-l);let m=new o0.MeshStandardMaterial({map:c,transparent:!0,alphaTest:.1}),p=new o0.MeshStandardMaterial({map:d,transparent:!0,alphaTest:.1});return{mesh:new o0.Mesh(new o0.BoxGeometry(1,1,0),[new o0.MeshBasicMaterial({color:0}),new o0.MeshBasicMaterial({color:0}),new o0.MeshBasicMaterial({color:0}),new o0.MeshBasicMaterial({color:0}),m,p]),itemsTexture:c,itemsTextureFlipped:d,cleanup(){c.dispose(),d.dispose(),m.dispose(),p.dispose()}}}x();R();T();k();import*as q from"three";x();R();T();k();x();R();T();k();import{REVISION as aa}from"three";var Vr=parseInt(aa.replace(/\D+/g,""));x();R();T();k();import{Loader as va,FileLoader as la,Group as ca,BufferGeometry as jr,Float32BufferAttribute as pe,LineBasicMaterial as E2,Material as Qr,PointsMaterial as J5,MeshPhongMaterial as da,LineSegments as Yr,Points as x2,Mesh as Kr,Vector3 as $e}from"three";var ua=/^[og]\s*(.+)?/,fa=/^mtllib /,ha=/^usemtl /,ma=/^usemap /,Jr=new $e,R2=new $e,qr=new $e,Zr=new $e,rt=new $e;function pa(){let r={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(t,e){if(this.object&&this.object.fromDeclaration===!1){this.object.name=t,this.object.fromDeclaration=e!==!1;return}let i=this.object&&typeof this.object.currentMaterial=="function"?this.object.currentMaterial():void 0;if(this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0),this.object={name:t||"",fromDeclaration:e!==!1,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(n,s){let o=this._finalize(!1);o&&(o.inherited||o.groupCount<=0)&&this.materials.splice(o.index,1);let a={index:this.materials.length,name:n||"",mtllib:Array.isArray(s)&&s.length>0?s[s.length-1]:"",smooth:o!==void 0?o.smooth:this.smooth,groupStart:o!==void 0?o.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(v){let l={index:typeof v=="number"?v:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return l.clone=this.clone.bind(l),l}};return this.materials.push(a),a},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(n){let s=this.currentMaterial();if(s&&s.groupEnd===-1&&(s.groupEnd=this.geometry.vertices.length/3,s.groupCount=s.groupEnd-s.groupStart,s.inherited=!1),n&&this.materials.length>1)for(let o=this.materials.length-1;o>=0;o--)this.materials[o].groupCount<=0&&this.materials.splice(o,1);return n&&this.materials.length===0&&this.materials.push({name:"",smooth:this.smooth}),s}},i&&i.name&&typeof i.clone=="function"){let n=i.clone(0);n.inherited=!0,this.object.materials.push(n)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0)},parseVertexIndex:function(t,e){let i=parseInt(t,10);return(i>=0?i-1:i+e/3)*3},parseNormalIndex:function(t,e){let i=parseInt(t,10);return(i>=0?i-1:i+e/3)*3},parseUVIndex:function(t,e){let i=parseInt(t,10);return(i>=0?i-1:i+e/2)*2},addVertex:function(t,e,i){let n=this.vertices,s=this.object.geometry.vertices;s.push(n[t+0],n[t+1],n[t+2]),s.push(n[e+0],n[e+1],n[e+2]),s.push(n[i+0],n[i+1],n[i+2])},addVertexPoint:function(t){let e=this.vertices;this.object.geometry.vertices.push(e[t+0],e[t+1],e[t+2])},addVertexLine:function(t){let e=this.vertices;this.object.geometry.vertices.push(e[t+0],e[t+1],e[t+2])},addNormal:function(t,e,i){let n=this.normals,s=this.object.geometry.normals;s.push(n[t+0],n[t+1],n[t+2]),s.push(n[e+0],n[e+1],n[e+2]),s.push(n[i+0],n[i+1],n[i+2])},addFaceNormal:function(t,e,i){let n=this.vertices,s=this.object.geometry.normals;Jr.fromArray(n,t),R2.fromArray(n,e),qr.fromArray(n,i),rt.subVectors(qr,R2),Zr.subVectors(Jr,R2),rt.cross(Zr),rt.normalize(),s.push(rt.x,rt.y,rt.z),s.push(rt.x,rt.y,rt.z),s.push(rt.x,rt.y,rt.z)},addColor:function(t,e,i){let n=this.colors,s=this.object.geometry.colors;n[t]!==void 0&&s.push(n[t+0],n[t+1],n[t+2]),n[e]!==void 0&&s.push(n[e+0],n[e+1],n[e+2]),n[i]!==void 0&&s.push(n[i+0],n[i+1],n[i+2])},addUV:function(t,e,i){let n=this.uvs,s=this.object.geometry.uvs;s.push(n[t+0],n[t+1]),s.push(n[e+0],n[e+1]),s.push(n[i+0],n[i+1])},addDefaultUV:function(){let t=this.object.geometry.uvs;t.push(0,0),t.push(0,0),t.push(0,0)},addUVLine:function(t){let e=this.uvs;this.object.geometry.uvs.push(e[t+0],e[t+1])},addFace:function(t,e,i,n,s,o,a,v,l){let c=this.vertices.length,d=this.parseVertexIndex(t,c),m=this.parseVertexIndex(e,c),p=this.parseVertexIndex(i,c);if(this.addVertex(d,m,p),this.addColor(d,m,p),a!==void 0&&a!==""){let g=this.normals.length;d=this.parseNormalIndex(a,g),m=this.parseNormalIndex(v,g),p=this.parseNormalIndex(l,g),this.addNormal(d,m,p)}else this.addFaceNormal(d,m,p);if(n!==void 0&&n!==""){let g=this.uvs.length;d=this.parseUVIndex(n,g),m=this.parseUVIndex(s,g),p=this.parseUVIndex(o,g),this.addUV(d,m,p),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(t){this.object.geometry.type="Points";let e=this.vertices.length;for(let i=0,n=t.length;i<n;i++){let s=this.parseVertexIndex(t[i],e);this.addVertexPoint(s),this.addColor(s)}},addLineGeometry:function(t,e){this.object.geometry.type="Line";let i=this.vertices.length,n=this.uvs.length;for(let s=0,o=t.length;s<o;s++)this.addVertexLine(this.parseVertexIndex(t[s],i));for(let s=0,o=e.length;s<o;s++)this.addUVLine(this.parseUVIndex(e[s],n))}};return r.startObject("",!1),r}var ge=class extends va{constructor(t){super(t),this.materials=null}load(t,e,i,n){let s=this,o=new la(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(a){try{e(s.parse(a))}catch(v){n&&n(v),s.manager.itemError(t)}},i,n)}setMaterials(t){return this.materials=t,this}parse(t){let e=new pa;t.indexOf(`\r
447
+ }`;function $o(r){let t=document.createElement("style");t.innerHTML=r;let e=document.querySelector("head link[rel=stylesheet], head style");e?document.head.insertBefore(t,e):document.head.appendChild(t)}var Ur=!1,w2=class r{constructor({parent:t,autoPlace:e=t===void 0,container:i,width:n,title:s="Controls",closeFolders:o=!1,injectStyles:a=!0,touchStyles:v=!0}={}){if(this.parent=t,this.root=t?t.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",l=>{(l.code==="Enter"||l.code==="Space")&&(l.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(s),this.parent){this.parent.children.push(this),this.parent.folders.push(this),this.parent.$children.appendChild(this.domElement);return}this.domElement.classList.add("root"),v&&this.domElement.classList.add("allow-touch-styles"),!Ur&&a&&($o(Xo),Ur=!0),i?i.appendChild(this.domElement):e&&(this.domElement.classList.add("autoPlace"),document.body.appendChild(this.domElement)),n&&this.domElement.style.setProperty("--width",n+"px"),this._closeFolders=o}add(t,e,i,n,s){if(Object(i)===i)return new b2(this,t,e,i);switch(typeof t[e]){case"number":return new g2(this,t,e,i,n,s);case"boolean":return new h2(this,t,e);case"string":return new y2(this,t,e);case"function":return new Je(this,t,e)}}addColor(t,e,i=1){return new p2(this,t,e,i)}addFolder(t){let e=new r({parent:this,title:t});return this.root._closeFolders&&e.close(),e}load(t,e=!0){return t.controllers&&this.controllers.forEach(i=>{i instanceof Je||i._name in t.controllers&&i.load(t.controllers[i._name])}),e&&t.folders&&this.folders.forEach(i=>{i._title in t.folders&&i.load(t.folders[i._title])}),this}save(t=!0){let e={controllers:{},folders:{}};return this.controllers.forEach(i=>{if(!(i instanceof Je)){if(i._name in e.controllers)throw new Error(`Cannot save GUI with duplicate property "${i._name}"`);e.controllers[i._name]=i.save()}}),t&&this.folders.forEach(i=>{if(i._title in e.folders)throw new Error(`Cannot save GUI with duplicate folder "${i._title}"`);e.folders[i._title]=i.save()}),e}open(t=!0){return this._setClosed(!t),this.$title.setAttribute("aria-expanded",!this._closed),this.domElement.classList.toggle("closed",this._closed),this}close(){return this.open(!1)}_setClosed(t){this._closed!==t&&(this._closed=t,this._callOnOpenClose(this))}show(t=!0){return this._hidden=!t,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}openAnimated(t=!0){return this._setClosed(!t),this.$title.setAttribute("aria-expanded",!this._closed),requestAnimationFrame(()=>{let e=this.$children.clientHeight;this.$children.style.height=e+"px",this.domElement.classList.add("transition");let i=s=>{s.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",i))};this.$children.addEventListener("transitionend",i);let n=t?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!t),requestAnimationFrame(()=>{this.$children.style.height=n+"px"})}),this}title(t){return this._title=t,this.$title.innerHTML=t,this}reset(t=!0){return(t?this.controllersRecursive():this.controllers).forEach(i=>i.reset()),this}onChange(t){return this._onChange=t,this}_callOnChange(t){this.parent&&this.parent._callOnChange(t),this._onChange!==void 0&&this._onChange.call(this,{object:t.object,property:t.property,value:t.getValue(),controller:t})}onFinishChange(t){return this._onFinishChange=t,this}_callOnFinishChange(t){this.parent&&this.parent._callOnFinishChange(t),this._onFinishChange!==void 0&&this._onFinishChange.call(this,{object:t.object,property:t.property,value:t.getValue(),controller:t})}onOpenClose(t){return this._onOpenClose=t,this}_callOnOpenClose(t){this.parent&&this.parent._callOnOpenClose(t),this._onOpenClose!==void 0&&this._onOpenClose.call(this,t)}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(t=>t.destroy())}controllersRecursive(){let t=Array.from(this.controllers);return this.folders.forEach(e=>{t=t.concat(e.controllersRecursive())}),t}foldersRecursive(){let t=Array.from(this.folders);return this.folders.forEach(e=>{t=t.concat(e.foldersRecursive())}),t}},_2=w2;var yt=class{constructor(t,e,i,n){f(this,"gui",null);f(this,"storageKey","");f(this,"target");f(this,"params",[]);f(this,"paramsMeta",{});f(this,"_visible",!1);f(this,"initialValues",{});f(this,"initialized",!1);if(!w0){this.gui=new _2,this.storageKey=`debug_params_${t}`,this.target=e,this.paramsMeta=n??{},this.params=i??Object.keys(e);for(let s of this.params)this.initialValues[s]=e[s];this.gui.domElement.style.display="none"}}activate(){return w0?this:(!this.initialized&&this.gui&&(this.loadSavedValues(),this.setupControls(),this.initialized=!0),this.show(),this)}get visible(){return w0?!1:this._visible}set visible(t){w0||!this.gui||(this._visible=t,this.gui.domElement.style.display=t?"block":"none",this.saveVisibility())}loadSavedValues(){if(!w0)try{let t=localStorage.getItem(this.storageKey);if(t){let e=JSON.parse(t);for(let i of this.params)if(i in e){let n=e[i];n!==null&&(this.target[i]=n)}}}catch{}}saveValues(t=!1){if(!w0)try{let e={};for(let i of this.params)e[i]=this.target[i];t?localStorage.removeItem(this.storageKey):localStorage.setItem(this.storageKey,JSON.stringify(e))}catch{}}saveVisibility(){if(!w0)try{localStorage.setItem(`${this.storageKey}_visible`,this._visible.toString())}catch{}}setupControls(){if(!(w0||!this.gui)){this.gui.add(this,"visible").name("Show Controls"),this.gui.add({resetAll:()=>{if(this.gui){for(let t of this.params)this.target[t]=this.initialValues[t];this.saveValues(!0),this.gui.destroy(),this.gui=new _2,this.setupControls()}}},"resetAll").name("Reset All Parameters");for(let t of this.params){let e=this.target[t],i=this.paramsMeta[t]??{};if(typeof e=="number"){let n=i.min??e-Math.abs(e*2),s=i.max??e+Math.abs(e*2),o=i.step??Math.abs(e)/100;this.gui.add(this.target,t,n,s,o).onChange(()=>this.saveValues())}else if(typeof e=="boolean")this.gui.add(this.target,t).onChange(()=>this.saveValues());else if(typeof e=="string"&&["x","y","z"].includes(t)){let n=i.min??-10,s=i.max??10,o=i.step??.1;this.gui.add(this.target,t,n,s,o).onChange(()=>this.saveValues())}else Array.isArray(e)&&this.gui.add(this.target,t,e).onChange(()=>this.saveValues())}}}save(){w0||(this.saveValues(),this.saveVisibility())}destroy(){w0||!this.gui||(this.saveVisibility(),this.gui.destroy())}toggle(){this.visible=!this.visible}show(){this.visible=!0}hide(){this.visible=!1}};x();R();T();k();x();R();T();k();var Q5=class{constructor(){f(this,"currentAnimation",null);f(this,"isAnimating",!1);f(this,"cancelRequested",!1);f(this,"completionCallbacks",[]);f(this,"currentCancelCallback",null)}async startAnimation(t,e){return this.isAnimating&&await this.cancelCurrentAnimation(),new Promise(i=>{this.isAnimating=!0,this.cancelRequested=!1,this.currentCancelCallback=e??null,this.currentAnimation=t(),this.completionCallbacks.push(()=>{this.isAnimating=!1,this.currentAnimation=null,i()})})}async cancelCurrentAnimation(){if(this.isAnimating){if(this.currentCancelCallback){let t=this.currentCancelCallback;this.currentCancelCallback=null,t()}return new Promise(t=>{this.cancelRequested=!0,this.completionCallbacks.push(()=>{t()})})}}animationCycleFinish(){this.cancelRequested&&this.forceFinish()}forceFinish(t=!0){if(!this.isAnimating)return;if(this.currentAnimation){for(let i of this.currentAnimation.getAll())i.stop();this.currentAnimation.removeAll(),this.currentAnimation=null}this.isAnimating=!1,this.cancelRequested=!1;let e=[...this.completionCallbacks];if(this.completionCallbacks=[],t)for(let i of e)i()}update(){this.currentAnimation&&this.currentAnimation.update()}get isActive(){return this.isAnimating}get shouldCancel(){return this.cancelRequested}};var ta={x:3e3,y:3e3,z:3e3,rotation:Math.PI,scale:1,default:3e3},Jt=class{constructor(t,e,i){this.getState=t;this.setState=e;f(this,"animationController",new Q5);f(this,"defaultState");f(this,"speeds");f(this,"currentStateName","");f(this,"transitioningToStateName","");this.speeds={...ta},i&&Object.assign(this.speeds,i),this.defaultState=this.getState()}calculateDuration(t){let e=0,i=this.getState();for(let[n,s]of Object.entries(t)){let o=i[n],a=Math.abs(s-o),v=this.getPropertySpeed(n),l=a/v*1e3;e=Math.max(e,l)}return Math.min(Math.max(e,200),2e3)}getPropertySpeed(t){return t in this.speeds?this.speeds[t]:t.toLowerCase().includes("rotation")?this.speeds.rotation:t.toLowerCase().includes("scale")?this.speeds.scale:t.toLowerCase()==="x"||t.toLowerCase()==="y"||t.toLowerCase()==="z"?this.speeds[t]:this.speeds.default}startTransition(t,e,i,n=k0.Linear.None,s){this.isTransitioning&&this.animationController.forceFinish(!1),this.transitioningToStateName=e??"";let o=this.getState(),a=this.calculateDuration(t);this.animationController.startAnimation(()=>{let v=new ve;return new M0(o,v).to(t,a).easing(n).onUpdate(l=>{for(let c of Object.keys(l))this.setState(c,l[c])}).onComplete(()=>{this.animationController.forceFinish(),this.currentStateName=this.transitioningToStateName,this.transitioningToStateName="",i?.()}).start(),v},s)}reset(){this.startTransition(this.defaultState)}update(){this.animationController.update()}forceFinish(){this.animationController.forceFinish()}transitionTo(t,e,i,n){this.startTransition(t,e,i,k0.Linear.None,n)}getCurrentValue(t){return this.getState()[t]}get isTransitioning(){return this.animationController.isActive}};x();R();T();k();import{subscribeKey as ea}from"valtio/utils";function Y5(r,t,e,i,n){let s=0,o,a=async()=>{let v=++s,l=await r(t[e]);v===s?(o&&n?.(o),i(l),o=l):n?.(l)};return a(),ea(t,e,a)}x();R();T();k();var Gr=Math.PI/180;function K5(r){let{walkDist:t,prevWalkDist:e,bob:i,prevBob:n,partialTick:s}=r,o=t-e,a=-(t+o*s),v=n+(i-n)*s,l=Math.sin(a*Math.PI),c=Math.cos(a*Math.PI);return{position:{x:l*v*.5,y:-Math.abs(c*v)},rotation:{x:Math.abs(Math.cos(a*Math.PI-.2)*v)*5*Gr,z:l*v*3*Gr}}}var U0=new A0.Matrix4;function na(r,t){let e=new A0.Matrix4,i=1,n=Math.sqrt(r),s=-.3*Math.sin(n*Math.PI),o=.4*Math.sin(n*2*Math.PI),a=-.4*Math.sin(r*Math.PI);return e.multiply(U0.makeTranslation(i*(s+.64),o-.6+t*-.6,a-.72)),e.multiply(U0.makeRotationY(i*45*Math.PI/180)),e.multiply(U0.makeRotationY(i*Math.sin(n*Math.PI)*70*Math.PI/180)),e.multiply(U0.makeRotationZ(i*Math.sin(r*r*Math.PI)*-20*Math.PI/180)),e.multiply(U0.makeTranslation(i*-1,3.6,3.5)),e.multiply(U0.makeRotationZ(i*120*Math.PI/180)),e.multiply(U0.makeRotationX(200*Math.PI/180)),e.multiply(U0.makeRotationY(i*-135*Math.PI/180)),e.multiply(U0.makeTranslation(i*5.6,0,0)),e.multiply(U0.makeTranslation(i*-5/16,2/16,0)),e}function ra(r,t){let e=new A0.Matrix4,i=1,n=Math.sqrt(r),s=-.4*Math.sin(n*Math.PI),o=.2*Math.sin(n*2*Math.PI),a=-.2*Math.sin(r*Math.PI);e.multiply(U0.makeTranslation(i*s,o,a)),e.multiply(U0.makeTranslation(i*.56,-.52+t*-.6,-.72));let v=Math.sin(r*r*Math.PI),l=Math.sin(n*Math.PI);return e.multiply(U0.makeRotationY(i*(45+v*-20)*Math.PI/180)),e.multiply(U0.makeRotationZ(i*l*-20*Math.PI/180)),e.multiply(U0.makeRotationX(l*-80*Math.PI/180)),e.multiply(U0.makeRotationY(i*-45*Math.PI/180)),e}var Ze=class{constructor(t,e=!1){this.worldRenderer=t;this.offHand=e;f(this,"holdingBlock");f(this,"blockSwapAnimation");f(this,"cameraGroup",new A0.Mesh);f(this,"armTransformGroup",new A0.Group);f(this,"camera",new A0.PerspectiveCamera(70,1,.05,100));f(this,"equipProgress",0);f(this,"stopUpdate",!1);f(this,"lastHeldItem");f(this,"currentDisplayType","hand");f(this,"isSwinging",!1);f(this,"nextIterStopCallbacks");f(this,"idleAnimator");f(this,"ready",!1);f(this,"lastUpdate",0);f(this,"xBob",0);f(this,"yBob",0);f(this,"lastBobUpdateTime",0);f(this,"lastBobWalkDist",0);f(this,"lastBobTickTime",0);f(this,"playerHand");f(this,"offHandDisplay",!1);f(this,"offHandModeLegacy",!1);f(this,"swingAnimator");f(this,"config");f(this,"disposed",!1);f(this,"unsubs",[]);f(this,"lastItemModelName");f(this,"switchRequest",0);this.initCameraGroup(),this.unsubs.push(this.worldRenderer.onReactivePlayerStateUpdated("heldItemMain",()=>{this.offHand||this.updateItem()},!1),this.worldRenderer.onReactivePlayerStateUpdated("heldItemOff",()=>{this.offHand&&this.updateItem()},!1)),this.config=t.displayOptions.inWorldRenderingConfig,this.offHandDisplay=this.offHand,this.offHand||Xe().then(i=>{this.disposed||(this.playerHand=i,this.updateItem())}).then(()=>{if(this.disposed)return;let i=Y5(async()=>Xe(this.worldRenderer.playerStateReactive.playerSkin,this.worldRenderer.playerStateReactive.onlineMode?this.worldRenderer.playerStateReactive.username:void 0),this.worldRenderer.playerStateReactive,"playerSkin",n=>{n&&(this.playerHand=n,this.updateItem())},n=>{x0(n,!0)});this.unsubs.push(i)})}dispose(){this.disposed=!0,this.unsubs.forEach(t=>t()),this.unsubs=[],this.idleAnimator?.destroy(),this.idleAnimator=void 0,this.swingAnimator?.stopSwing(),this.swingAnimator=void 0,this.blockSwapAnimation?.switcher.forceFinish(),this.blockSwapAnimation=void 0,x0(this.cameraGroup,!0),this.holdingBlock&&this.holdingBlock!==this.playerHand&&x0(this.holdingBlock,!0),this.holdingBlock=void 0,this.playerHand&&(x0(this.playerHand,!0),this.playerHand=void 0),this.ready=!1}updateItem(){if(!this.ready)return;let t=this.offHand?this.worldRenderer.playerStateReactive.heldItemOff:this.worldRenderer.playerStateReactive.heldItemMain;t?this.setNewItem(t):this.offHand?this.setNewItem():this.setNewItem({type:"hand"})}initCameraGroup(){this.cameraGroup=new A0.Mesh,this.armTransformGroup=new A0.Group,this.armTransformGroup.matrixAutoUpdate=!1,this.cameraGroup.add(this.armTransformGroup)}startSwing(){this.swingAnimator?.startSwing()}stopSwing(){this.swingAnimator?.stopSwing()}render(t,e,i,n){if(!this.lastHeldItem)return;let s=performance.now();this.lastUpdate&&s-this.lastUpdate>50&&this.replaceItemModel(this.lastHeldItem),(this.swingAnimator?.isCurrentlySwinging()||this.swingAnimator?.debugParams.animationStage)&&this.swingAnimator?.update(),this.blockSwapAnimation?.switcher.update();let o=new A0.Scene;o.add(this.cameraGroup);let a=e.getSize(new A0.Vector2),v=a.height>a.width;v?this.camera.aspect!==1&&(this.camera.aspect=1,this.camera.updateProjectionMatrix()):this.camera.aspect!==t.aspect&&(this.camera.aspect=t.aspect,this.camera.updateProjectionMatrix()),this.updateCameraGroup(),o.add(i.clone()),o.add(n.clone());let{offHandDisplay:l}=this;if(l&&(this.cameraGroup.scale.x=-1),e.autoClear=!1,e.clearDepth(),v){let c=Math.min(a.width,a.height);l?e.setViewport(0,0,c,c):e.setViewport(a.width-c,0,c,c)}e.render(o,this.camera),v&&e.setViewport(0,0,a.width,a.height),l&&(this.cameraGroup.scale.x=1)}async playBlockSwapAnimation(t){this.blockSwapAnimation??(this.blockSwapAnimation={switcher:new Jt(()=>({progress:this.equipProgress}),(n,s)=>{n==="progress"&&(this.equipProgress=s)},{progress:4})});let e=t==="disappeared"?1:0,i=!1;return new Promise(n=>{this.blockSwapAnimation.switcher.transitionTo({progress:e},t,()=>{i||n(!0)},()=>{i=!0,n(!1)})})}isDifferentItem(t){let e=ia(this.worldRenderer.version);return!this.lastHeldItem||this.lastHeldItem.name!==t?.name||!e.equal(this.lastHeldItem.fullItem,t?.fullItem??{})||JSON.stringify(this.lastHeldItem.fullItem.components)!==JSON.stringify(t?.fullItem?.components)}updateCameraGroup(){if(this.stopUpdate)return;let{camera:t}=this,e=performance.now(),i=this.worldRenderer.cameraShake.getBaseRotation(),n=i.pitch,s=i.yaw;if(this.lastBobUpdateTime===0)this.xBob=n,this.yBob=s,this.lastBobUpdateTime=e;else{let m=Math.min((e-this.lastBobUpdateTime)/1e3,.1);this.lastBobUpdateTime=e;let p=1-Math.pow(.5,m*20);this.xBob+=(n-this.xBob)*p,this.yBob+=(s-this.yBob)*p}let o=(n-this.xBob)*-.1,a=(s-this.yBob)*-.1;if(this.cameraGroup.position.copy(t.position),this.cameraGroup.rotation.copy(t.rotation),this.worldRenderer.displayOptions.inWorldRenderingConfig.viewBobbing){let m=this.worldRenderer.playerStateReactive;m.walkDist!==this.lastBobWalkDist&&(this.lastBobTickTime=e,this.lastBobWalkDist=m.walkDist);let p=Math.min((e-this.lastBobTickTime)/50,1),g=1.8,y=K5({walkDist:m.walkDist*g,prevWalkDist:m.prevWalkDist*g,bob:m.bob,prevBob:m.prevBob,partialTick:p});this.cameraGroup.position.x+=y.position.x,this.cameraGroup.position.y+=y.position.y,this.cameraGroup.rotation.z+=y.rotation.z,this.cameraGroup.rotation.x+=y.rotation.x}this.cameraGroup.rotation.x+=o,this.cameraGroup.rotation.y+=a;let l=this.currentDisplayType,c=this.swingAnimator?.getSwingProgress()??0,d;l==="hand"?d=na(c,this.equipProgress):d=ra(c,this.equipProgress),this.armTransformGroup.matrix.copy(d),this.armTransformGroup.matrixWorldNeedsUpdate=!0}async createItemModel(t){if(this.lastUpdate=performance.now(),!t||t.type==="hand"&&!this.playerHand)return;let e;if(t.type==="item"||t.type==="block"){let i=this.worldRenderer.entities.getItemMesh({...t.fullItem,itemId:t.id},{"minecraft:display_context":"firstperson","minecraft:use_duration":this.worldRenderer.playerStateReactive.itemUsageTicks,"minecraft:using_item":!!this.worldRenderer.playerStateReactive.itemUsageTicks},!1,this.lastItemModelName);if(i){let{mesh:n,isBlock:s,modelName:o}=i;s?(e=n,t.type="block"):(e=n,t.type="item"),this.lastItemModelName=o}}else e=this.playerHand;if(e){if(t.type==="item"||t.type==="block"){let i=new A0.Group;i.name="displayTransform",t.type==="item"?(i.position.set(1.13/16,3.2/16,1.13/16),i.rotation.set(0,A0.MathUtils.degToRad(-90),A0.MathUtils.degToRad(25),"XYZ"),i.scale.set(.68,.68,.68)):(i.rotation.set(0,A0.MathUtils.degToRad(45),0,"XYZ"),i.scale.set(.4,.4,.4)),i.add(e),e=i}return e.name="holdingBlock",{model:e,type:t.type}}}async replaceItemModel(t){if(this.blockSwapAnimation?.switcher.isTransitioning)return;if(!t){this.holdingBlock?.removeFromParent(),this.holdingBlock=void 0,this.currentDisplayType="hand",this.swingAnimator?.stopSwing(),this.swingAnimator=void 0,this.idleAnimator=void 0;return}let e=await this.createItemModel(t);e&&(this.holdingBlock?.removeFromParent(),this.holdingBlock=e.model,this.currentDisplayType=e.type,this.armTransformGroup.add(e.model))}testUnknownBlockSwitch(){this.setNewItem({type:"item",name:"minecraft:some-unknown-block",id:0,fullItem:{}})}async setNewItem(t){if(!this.isDifferentItem(t))return;this.lastItemModelName=void 0;let e=++this.switchRequest;this.lastHeldItem=t;let i=!1;if(this.holdingBlock){if(i=!0,!await this.playBlockSwapAnimation("disappeared"))return;this.holdingBlock.removeFromParent(),this.holdingBlock!==this.playerHand&&x0(this.holdingBlock,!1),this.holdingBlock=void 0}if(!t){this.currentDisplayType="hand",this.swingAnimator=void 0,this.idleAnimator=void 0,this.blockSwapAnimation=void 0;return}if(e!==this.switchRequest)return;let n=await this.createItemModel(t);!n||e!==this.switchRequest||(this.holdingBlock=n.model,this.currentDisplayType=n.type,this.armTransformGroup.add(this.holdingBlock),i&&await this.playBlockSwapAnimation("appeared"),this.swingAnimator=new A2,this.swingAnimator.type=n.type,this.idleAnimator=void 0)}};var A2=class{constructor(){f(this,"animationTimer",0);f(this,"lastTime",0);f(this,"isAnimating",!1);f(this,"stopRequested",!1);f(this,"swingProgress",0);f(this,"type","hand");f(this,"debugParams",{animationTime:250,animationStage:0});f(this,"debugGui");this.debugGui=new yt("hand_animator",this.debugParams,void 0,{animationStage:{min:0,max:1,step:.01}})}update(){if(!this.isAnimating&&!this.debugParams.animationStage){this.swingProgress=0;return}let t=performance.now(),e=(t-this.lastTime)/1e3;this.lastTime=t,this.animationTimer+=e*1e3;let i=this.debugParams.animationStage||Math.min(this.animationTimer/this.debugParams.animationTime,1);if(i>=1){if(this.stopRequested){this.isAnimating=!1,this.stopRequested=!1,this.animationTimer=0,this.swingProgress=0;return}this.animationTimer=0,this.swingProgress=0;return}this.swingProgress=i}getSwingProgress(){return this.swingProgress}startSwing(){this.stopRequested=!1,!this.isAnimating&&(this.isAnimating=!0,this.animationTimer=0,this.lastTime=performance.now())}stopSwing(){this.isAnimating&&(this.stopRequested=!0)}isCurrentlySwinging(){return this.isAnimating}},Wr=(r,t,e,i,n)=>{let s=i.transformModel(t,{name:e,properties:{}});return t2(r,[[s]],void 0,"plains",n)};x();R();T();k();import*as o0 from"three";function sa(r,t){let{depth:e,pixelSize:i}=t;if(r.width<=0||r.height<=0)throw new Error(`Invalid canvas dimensions: ${r.width}x${r.height}`);let s=r.getContext("2d").getImageData(0,0,r.width,r.height),{data:o}=s,a=r.width,v=r.height,l=e/2,c=i??1/Math.max(a,v),d=(B,I)=>{if(B<0||I<0||B>=a||I>=v)return!1;let W=(I*a+B)*4;return o[W+3]>128},m=[],p=[],g=[],y=[],_=0,w=(B,I,W,z,j,J,t0,V)=>(m.push(B,I,W),g.push(z,j),y.push(J,t0,V),_++),A=(B,I,W,z)=>{p.push(B,I,W,B,W,z)},C=(B,I)=>{let W=(B/a-.5)*c*a,z=-(I/v-.5)*c*v;return{x:W,y:z}},S=Array.from({length:v+1},()=>Array.from({length:a+1},()=>null)),M=Array.from({length:v+1},()=>Array.from({length:a+1},()=>null));for(let B=0;B<=v;B++)for(let I=0;I<=a;I++){let{x:W,y:z}=C(I-.5,B-.5),j=I/a,J=B/v,t0=!1,V=[[I-1,B-1],[I,B-1],[I-1,B],[I,B]];for(let[Z,K]of V)if(d(Z,K)){t0=!0;break}t0&&(S[B][I]=w(W,z,l,j,J,0,0,1),M[B][I]=w(W,z,-l,j,J,0,0,-1))}for(let B=0;B<v;B++)for(let I=0;I<a;I++){if(!d(I,B))continue;let W=S[B][I],z=S[B][I+1],j=S[B+1][I+1],J=S[B+1][I],t0=M[B][I],V=M[B][I+1],Z=M[B+1][I+1],K=M[B+1][I];W!==null&&z!==null&&j!==null&&J!==null&&A(W,z,j,J),t0!==null&&V!==null&&Z!==null&&K!==null&&A(V,t0,K,Z)}for(let B=0;B<v;B++)for(let I=0;I<a;I++){if(!d(I,B))continue;let W=(I+.5)/a,z=(B+.5)/v;if(!d(I-1,B)){let j=S[B][I],J=S[B+1][I],t0=M[B][I],V=M[B+1][I];if(j!==null&&J!==null&&t0!==null&&V!==null){let Z=w(m[j*3],m[j*3+1],m[j*3+2],W,z,-1,0,0),K=w(m[J*3],m[J*3+1],m[J*3+2],W,z,-1,0,0),i0=w(m[V*3],m[V*3+1],m[V*3+2],W,z,-1,0,0),r0=w(m[t0*3],m[t0*3+1],m[t0*3+2],W,z,-1,0,0);A(Z,K,i0,r0)}}if(!d(I+1,B)){let j=S[B+1][I+1],J=S[B][I+1],t0=M[B+1][I+1],V=M[B][I+1];if(j!==null&&J!==null&&t0!==null&&V!==null){let Z=w(m[j*3],m[j*3+1],m[j*3+2],W,z,1,0,0),K=w(m[J*3],m[J*3+1],m[J*3+2],W,z,1,0,0),i0=w(m[V*3],m[V*3+1],m[V*3+2],W,z,1,0,0),r0=w(m[t0*3],m[t0*3+1],m[t0*3+2],W,z,1,0,0);A(Z,K,i0,r0)}}if(!d(I,B-1)){let j=S[B][I],J=S[B][I+1],t0=M[B][I],V=M[B][I+1];if(j!==null&&J!==null&&t0!==null&&V!==null){let Z=w(m[j*3],m[j*3+1],m[j*3+2],W,z,0,-1,0),K=w(m[J*3],m[J*3+1],m[J*3+2],W,z,0,-1,0),i0=w(m[V*3],m[V*3+1],m[V*3+2],W,z,0,-1,0),r0=w(m[t0*3],m[t0*3+1],m[t0*3+2],W,z,0,-1,0);A(Z,K,i0,r0)}}if(!d(I,B+1)){let j=S[B+1][I+1],J=S[B+1][I],t0=M[B+1][I+1],V=M[B+1][I];if(j!==null&&J!==null&&t0!==null&&V!==null){let Z=w(m[j*3],m[j*3+1],m[j*3+2],W,z,0,1,0),K=w(m[J*3],m[J*3+1],m[J*3+2],W,z,0,1,0),i0=w(m[V*3],m[V*3+1],m[V*3+2],W,z,0,1,0),r0=w(m[t0*3],m[t0*3+1],m[t0*3+2],W,z,0,1,0);A(Z,K,i0,r0)}}}let H=new o0.BufferGeometry;return H.setAttribute("position",new o0.Float32BufferAttribute(m,3)),H.setAttribute("uv",new o0.Float32BufferAttribute(g,2)),H.setAttribute("normal",new o0.Float32BufferAttribute(y,3)),H.setIndex(p),H.computeVertexNormals(),{geometry:H,totalVertices:_,totalTriangles:p.length/3}}function oa(r,t){let{u:e,v:i,sizeX:n,sizeY:s}=t,o=Math.max(1,Math.floor(n*r.image.width)),a=Math.max(1,Math.floor(s*r.image.height)),v=document.createElement("canvas");v.width=o,v.height=a;let l=v.getContext("2d");return l.imageSmoothingEnabled=!1,l.drawImage(r.image,e*r.image.width,i*r.image.height,n*r.image.width,s*r.image.height,0,0,v.width,v.height),v}function Nr(r,t,e={}){let{faceCamera:i=!1,use3D:n=!0,depth:s=.04}=e,{u:o,v:a,sizeX:v,sizeY:l}=t;if(i){let y=r.clone();y.flipY=!0,y.offset.set(o,1-a-l),y.repeat.set(v,l),y.needsUpdate=!0,y.magFilter=o0.NearestFilter,y.minFilter=o0.NearestFilter;let _=new o0.SpriteMaterial({map:y,transparent:!0,alphaTest:.1});return{mesh:new o0.Sprite(_),itemsTexture:y,cleanup(){y.dispose()}}}if(n)try{let y=oa(r,t),{geometry:_}=sa(y,{depth:s}),w=new o0.CanvasTexture(y);w.magFilter=o0.NearestFilter,w.minFilter=o0.NearestFilter,w.wrapS=w.wrapT=o0.ClampToEdgeWrapping,w.flipY=!1,w.needsUpdate=!0;let A=new o0.MeshStandardMaterial({map:w,side:o0.DoubleSide,transparent:!0,alphaTest:.1});return{mesh:new o0.Mesh(_,A),itemsTexture:w,cleanup(){w.dispose(),_.dispose(),A.map&&A.map.dispose(),A.dispose()}}}catch{}let c=r.clone();c.flipY=!0,c.offset.set(o,1-a-l),c.repeat.set(v,l),c.needsUpdate=!0,c.magFilter=o0.NearestFilter,c.minFilter=o0.NearestFilter;let d=c.clone();d.repeat.x*=-1,d.needsUpdate=!0,d.offset.set(o+v,1-a-l);let m=new o0.MeshStandardMaterial({map:c,transparent:!0,alphaTest:.1}),p=new o0.MeshStandardMaterial({map:d,transparent:!0,alphaTest:.1});return{mesh:new o0.Mesh(new o0.BoxGeometry(1,1,0),[new o0.MeshBasicMaterial({color:0}),new o0.MeshBasicMaterial({color:0}),new o0.MeshBasicMaterial({color:0}),new o0.MeshBasicMaterial({color:0}),m,p]),itemsTexture:c,itemsTextureFlipped:d,cleanup(){c.dispose(),d.dispose(),m.dispose(),p.dispose()}}}x();R();T();k();import*as q from"three";x();R();T();k();x();R();T();k();import{REVISION as aa}from"three";var Vr=parseInt(aa.replace(/\D+/g,""));x();R();T();k();import{Loader as va,FileLoader as la,Group as ca,BufferGeometry as jr,Float32BufferAttribute as pe,LineBasicMaterial as E2,Material as Qr,PointsMaterial as J5,MeshPhongMaterial as da,LineSegments as Yr,Points as x2,Mesh as Kr,Vector3 as $e}from"three";var ua=/^[og]\s*(.+)?/,fa=/^mtllib /,ha=/^usemtl /,ma=/^usemap /,Jr=new $e,R2=new $e,qr=new $e,Zr=new $e,rt=new $e;function pa(){let r={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(t,e){if(this.object&&this.object.fromDeclaration===!1){this.object.name=t,this.object.fromDeclaration=e!==!1;return}let i=this.object&&typeof this.object.currentMaterial=="function"?this.object.currentMaterial():void 0;if(this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0),this.object={name:t||"",fromDeclaration:e!==!1,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(n,s){let o=this._finalize(!1);o&&(o.inherited||o.groupCount<=0)&&this.materials.splice(o.index,1);let a={index:this.materials.length,name:n||"",mtllib:Array.isArray(s)&&s.length>0?s[s.length-1]:"",smooth:o!==void 0?o.smooth:this.smooth,groupStart:o!==void 0?o.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(v){let l={index:typeof v=="number"?v:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return l.clone=this.clone.bind(l),l}};return this.materials.push(a),a},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(n){let s=this.currentMaterial();if(s&&s.groupEnd===-1&&(s.groupEnd=this.geometry.vertices.length/3,s.groupCount=s.groupEnd-s.groupStart,s.inherited=!1),n&&this.materials.length>1)for(let o=this.materials.length-1;o>=0;o--)this.materials[o].groupCount<=0&&this.materials.splice(o,1);return n&&this.materials.length===0&&this.materials.push({name:"",smooth:this.smooth}),s}},i&&i.name&&typeof i.clone=="function"){let n=i.clone(0);n.inherited=!0,this.object.materials.push(n)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0)},parseVertexIndex:function(t,e){let i=parseInt(t,10);return(i>=0?i-1:i+e/3)*3},parseNormalIndex:function(t,e){let i=parseInt(t,10);return(i>=0?i-1:i+e/3)*3},parseUVIndex:function(t,e){let i=parseInt(t,10);return(i>=0?i-1:i+e/2)*2},addVertex:function(t,e,i){let n=this.vertices,s=this.object.geometry.vertices;s.push(n[t+0],n[t+1],n[t+2]),s.push(n[e+0],n[e+1],n[e+2]),s.push(n[i+0],n[i+1],n[i+2])},addVertexPoint:function(t){let e=this.vertices;this.object.geometry.vertices.push(e[t+0],e[t+1],e[t+2])},addVertexLine:function(t){let e=this.vertices;this.object.geometry.vertices.push(e[t+0],e[t+1],e[t+2])},addNormal:function(t,e,i){let n=this.normals,s=this.object.geometry.normals;s.push(n[t+0],n[t+1],n[t+2]),s.push(n[e+0],n[e+1],n[e+2]),s.push(n[i+0],n[i+1],n[i+2])},addFaceNormal:function(t,e,i){let n=this.vertices,s=this.object.geometry.normals;Jr.fromArray(n,t),R2.fromArray(n,e),qr.fromArray(n,i),rt.subVectors(qr,R2),Zr.subVectors(Jr,R2),rt.cross(Zr),rt.normalize(),s.push(rt.x,rt.y,rt.z),s.push(rt.x,rt.y,rt.z),s.push(rt.x,rt.y,rt.z)},addColor:function(t,e,i){let n=this.colors,s=this.object.geometry.colors;n[t]!==void 0&&s.push(n[t+0],n[t+1],n[t+2]),n[e]!==void 0&&s.push(n[e+0],n[e+1],n[e+2]),n[i]!==void 0&&s.push(n[i+0],n[i+1],n[i+2])},addUV:function(t,e,i){let n=this.uvs,s=this.object.geometry.uvs;s.push(n[t+0],n[t+1]),s.push(n[e+0],n[e+1]),s.push(n[i+0],n[i+1])},addDefaultUV:function(){let t=this.object.geometry.uvs;t.push(0,0),t.push(0,0),t.push(0,0)},addUVLine:function(t){let e=this.uvs;this.object.geometry.uvs.push(e[t+0],e[t+1])},addFace:function(t,e,i,n,s,o,a,v,l){let c=this.vertices.length,d=this.parseVertexIndex(t,c),m=this.parseVertexIndex(e,c),p=this.parseVertexIndex(i,c);if(this.addVertex(d,m,p),this.addColor(d,m,p),a!==void 0&&a!==""){let g=this.normals.length;d=this.parseNormalIndex(a,g),m=this.parseNormalIndex(v,g),p=this.parseNormalIndex(l,g),this.addNormal(d,m,p)}else this.addFaceNormal(d,m,p);if(n!==void 0&&n!==""){let g=this.uvs.length;d=this.parseUVIndex(n,g),m=this.parseUVIndex(s,g),p=this.parseUVIndex(o,g),this.addUV(d,m,p),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(t){this.object.geometry.type="Points";let e=this.vertices.length;for(let i=0,n=t.length;i<n;i++){let s=this.parseVertexIndex(t[i],e);this.addVertexPoint(s),this.addColor(s)}},addLineGeometry:function(t,e){this.object.geometry.type="Line";let i=this.vertices.length,n=this.uvs.length;for(let s=0,o=t.length;s<o;s++)this.addVertexLine(this.parseVertexIndex(t[s],i));for(let s=0,o=e.length;s<o;s++)this.addUVLine(this.parseUVIndex(e[s],n))}};return r.startObject("",!1),r}var ge=class extends va{constructor(t){super(t),this.materials=null}load(t,e,i,n){let s=this,o=new la(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(a){try{e(s.parse(a))}catch(v){n&&n(v),s.manager.itemError(t)}},i,n)}setMaterials(t){return this.materials=t,this}parse(t){let e=new pa;t.indexOf(`\r
448
448
  `)!==-1&&(t=t.replace(/\r\n/g,`
449
449
  `)),t.indexOf(`\\
450
450
  `)!==-1&&(t=t.replace(/\\\n/g,""));let i=t.split(`