From d75c504a56ad1534d789eb465ab78a2fef4c825f Mon Sep 17 00:00:00 2001 From: Felix Seidel Date: Mon, 19 Feb 2024 08:57:54 +0000 Subject: [PATCH] Change controller to interval based --- assets/{controller--GQI-MwT.js => controller-BMocEXDy.js} | 4 ++-- assets/{main-PIDGtTiA.js => main-tP-COfH4.js} | 2 +- controller.html | 2 +- index.html | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) rename assets/{controller--GQI-MwT.js => controller-BMocEXDy.js} (77%) rename assets/{main-PIDGtTiA.js => main-tP-COfH4.js} (99%) diff --git a/assets/controller--GQI-MwT.js b/assets/controller-BMocEXDy.js similarity index 77% rename from assets/controller--GQI-MwT.js rename to assets/controller-BMocEXDy.js index ab81832..31a35eb 100644 --- a/assets/controller--GQI-MwT.js +++ b/assets/controller-BMocEXDy.js @@ -2,6 +2,6 @@ var Ge=Object.defineProperty;var Fe=(S,o,u)=>o in S?Ge(S,o,{enumerable:!0,config * http://hammerjs.github.io/ * * Copyright (c) 2016 Jorik Tangelder; - * Licensed under the MIT license */(function(S){(function(o,u,I,l){var R=["","webkit","Moz","MS","ms","o"],ft=u.createElement("div"),ne="function",X=Math.round,L=Math.abs,vt=Date.now;function pt(t,e,i){return setTimeout(dt(t,i),e)}function G(t,e,i){return Array.isArray(t)?(A(t,i[e],i),!0):!1}function A(t,e,i){var n;if(t)if(t.forEach)t.forEach(e,i);else if(t.length!==l)for(n=0;n\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",a=o.console&&(o.console.warn||o.console.log);return a&&a.call(o.console,n,s),t.apply(this,arguments)}}var C;typeof Object.assign!="function"?C=function(e){if(e===l||e===null)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(e),n=1;n-1}function $(t){return t.trim().split(/\s+/g)}function F(t,e,i){if(t.indexOf&&!i)return t.indexOf(e);for(var n=0;np[e]}):n=n.sort()),n}function et(t,e){for(var i,n,r=e[0].toUpperCase()+e.slice(1),s=0;s1&&!i.firstMultiple?i.firstMultiple=qt(e):r===1&&(i.firstMultiple=!1);var s=i.firstInput,a=i.firstMultiple,c=a?a.center:s.center,f=e.center=Yt(n);e.timeStamp=vt(),e.deltaTime=e.timeStamp-s.timeStamp,e.angle=gt(c,f),e.distance=rt(c,f),me(i,e),e.offsetDirection=Gt(e.deltaX,e.deltaY);var p=Xt(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=p.x,e.overallVelocityY=p.y,e.overallVelocity=L(p.x)>L(p.y)?p.x:p.y,e.scale=a?Ee(a.pointers,n):1,e.rotation=a?ge(a.pointers,n):0,e.maxPointers=i.prevInput?e.pointers.length>i.prevInput.maxPointers?e.pointers.length:i.prevInput.maxPointers:e.pointers.length,Te(i,e);var O=t.element;Ut(e.srcEvent.target,O)&&(O=e.srcEvent.target),e.target=O}function me(t,e){var i=e.center,n=t.offsetDelta||{},r=t.prevDelta||{},s=t.prevInput||{};(e.eventType===v||s.eventType===h)&&(r=t.prevDelta={x:s.deltaX||0,y:s.deltaY||0},n=t.offsetDelta={x:i.x,y:i.y}),e.deltaX=r.x+(i.x-n.x),e.deltaY=r.y+(i.y-n.y)}function Te(t,e){var i=t.lastInterval||e,n=e.timeStamp-i.timeStamp,r,s,a,c;if(e.eventType!=m&&(n>fe||i.velocity===l)){var f=e.deltaX-i.deltaX,p=e.deltaY-i.deltaY,O=Xt(n,f,p);s=O.x,a=O.y,r=L(O.x)>L(O.y)?O.x:O.y,c=Gt(f,p),t.lastInterval=e}else r=i.velocity,s=i.velocityX,a=i.velocityY,c=i.direction;e.velocity=r,e.velocityX=s,e.velocityY=a,e.direction=c}function qt(t){for(var e=[],i=0;i=L(e)?t<0?W:k:e<0?B:z}function rt(t,e,i){i||(i=xt);var n=e[i[0]]-t[i[0]],r=e[i[1]]-t[i[1]];return Math.sqrt(n*n+r*r)}function gt(t,e,i){i||(i=xt);var n=e[i[0]]-t[i[0]],r=e[i[1]]-t[i[1]];return Math.atan2(r,n)*180/Math.PI}function ge(t,e){return gt(e[1],e[0],nt)+gt(t[1],t[0],nt)}function Ee(t,e){return rt(e[0],e[1],nt)/rt(t[0],t[1],nt)}var Ie={mousedown:v,mousemove:x,mouseup:h},ye="mousedown",_e="mousemove mouseup";function st(){this.evEl=ye,this.evWin=_e,this.pressed=!1,g.apply(this,arguments)}T(st,g,{handler:function(e){var i=Ie[e.type];i&v&&e.button===0&&(this.pressed=!0),i&x&&e.which!==1&&(i=h),this.pressed&&(i&h&&(this.pressed=!1),this.callback(this.manager,i,{pointers:[e],changedPointers:[e],pointerType:Tt,srcEvent:e}))}});var Ce={pointerdown:v,pointermove:x,pointerup:h,pointercancel:m,pointerout:m},Pe={2:V,3:ce,4:Tt,5:ue},Ft="pointerdown",Ht="pointermove pointerup pointercancel";o.MSPointerEvent&&!o.PointerEvent&&(Ft="MSPointerDown",Ht="MSPointerMove MSPointerUp MSPointerCancel");function Et(){this.evEl=Ft,this.evWin=Ht,g.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}T(Et,g,{handler:function(e){var i=this.store,n=!1,r=e.type.toLowerCase().replace("ms",""),s=Ce[r],a=Pe[e.pointerType]||e.pointerType,c=a==V,f=F(i,e.pointerId,"pointerId");s&v&&(e.button===0||c)?f<0&&(i.push(e),f=i.length-1):s&(h|m)&&(n=!0),!(f<0)&&(i[f]=e,this.callback(this.manager,s,{pointers:i,changedPointers:[e],pointerType:a,srcEvent:e}),n&&i.splice(f,1))}});var Ne={touchstart:v,touchmove:x,touchend:h,touchcancel:m},Oe="touchstart",Se="touchstart touchmove touchend touchcancel";function Vt(){this.evTarget=Oe,this.evWin=Se,this.started=!1,g.apply(this,arguments)}T(Vt,g,{handler:function(e){var i=Ne[e.type];if(i===v&&(this.started=!0),!!this.started){var n=Ae.call(this,e,i);i&(h|m)&&n[0].length-n[1].length===0&&(this.started=!1),this.callback(this.manager,i,{pointers:n[0],changedPointers:n[1],pointerType:V,srcEvent:e})}}});function Ae(t,e){var i=tt(t.touches),n=tt(t.changedTouches);return e&(h|m)&&(i=Rt(i.concat(n),"identifier",!0)),[i,n]}var De={touchstart:v,touchmove:x,touchend:h,touchcancel:m},Me="touchstart touchmove touchend touchcancel";function ot(){this.evTarget=Me,this.targetIds={},g.apply(this,arguments)}T(ot,g,{handler:function(e){var i=De[e.type],n=Ue.call(this,e,i);n&&this.callback(this.manager,i,{pointers:n[0],changedPointers:n[1],pointerType:V,srcEvent:e})}});function Ue(t,e){var i=tt(t.touches),n=this.targetIds;if(e&(v|x)&&i.length===1)return n[i[0].identifier]=!0,[i,i];var r,s,a=tt(t.changedTouches),c=[],f=this.target;if(s=i.filter(function(p){return Ut(p.target,f)}),e===v)for(r=0;r-1&&n.splice(s,1)};setTimeout(r,Re)}}function Le(t){for(var e=t.srcEvent.clientX,i=t.srcEvent.clientY,n=0;n-1&&this.requireFail.splice(e,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(t){return!!this.simultaneous[t.id]},emit:function(t){var e=this,i=this.state;function n(r){e.manager.emit(r,t)}i=b&&n(e.options.event+Zt(i))},tryEmit:function(t){if(this.canEmit())return this.emit(t);this.state=N},canEmit:function(){for(var t=0;te.threshold&&r&e.direction},attrTest:function(t){return y.prototype.attrTest.call(this,t)&&(this.state&E||!(this.state&E)&&this.directionTest(t))},emit:function(t){this.pX=t.deltaX,this.pY=t.deltaY;var e=Qt(t.direction);e&&(t.additionalEvent=this.options.event+e),this._super.emit.call(this,t)}});function Ct(){y.apply(this,arguments)}T(Ct,y,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[Y]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.scale-1)>this.options.threshold||this.state&E)},emit:function(t){if(t.scale!==1){var e=t.scale<1?"in":"out";t.additionalEvent=this.options.event+e}this._super.emit.call(this,t)}});function Pt(){M.apply(this,arguments),this._timer=null,this._input=null}T(Pt,M,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[Jt]},process:function(t){var e=this.options,i=t.pointers.length===e.pointers,n=t.distancee.time;if(this._input=t,!n||!i||t.eventType&(h|m)&&!r)this.reset();else if(t.eventType&v)this.reset(),this._timer=pt(function(){this.state=D,this.tryEmit()},e.time,this);else if(t.eventType&h)return D;return N},reset:function(){clearTimeout(this._timer)},emit:function(t){this.state===D&&(t&&t.eventType&h?this.manager.emit(this.options.event+"up",t):(this._input.timeStamp=vt(),this.manager.emit(this.options.event,this._input)))}});function Nt(){y.apply(this,arguments)}T(Nt,y,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[Y]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.rotation)>this.options.threshold||this.state&E)}});function Ot(){y.apply(this,arguments)}T(Ot,y,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:P|q,pointers:1},getTouchAction:function(){return ct.prototype.getTouchAction.call(this)},attrTest:function(t){var e=this.options.direction,i;return e&(P|q)?i=t.overallVelocity:e&P?i=t.overallVelocityX:e&q&&(i=t.overallVelocityY),this._super.attrTest.call(this,t)&&e&t.offsetDirection&&t.distance>this.options.threshold&&t.maxPointers==this.options.pointers&&L(i)>this.options.velocity&&t.eventType&h},emit:function(t){var e=Qt(t.offsetDirection);e&&this.manager.emit(this.options.event+e,t),this.manager.emit(this.options.event,t)}});function ut(){M.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}T(ut,M,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[yt]},process:function(t){var e=this.options,i=t.pointers.length===e.pointers,n=t.distancethis.swipeLeft()),R.on("swiperight",()=>this.swipeRight()),R.on("swipeup",()=>this.swipeUp()),R.on("swipedown",()=>this.swipeDown())}this.dropButton=document.getElementById("drop"),(o=this.dropButton)==null||o.addEventListener("click",()=>this.activatePayload()),(u=this.gameController)==null||u.remove(),(I=this.joinGameButton)==null||I.addEventListener("click",()=>this.checkPermissions()),(l=this.startGameButton)==null||l.addEventListener("click",()=>this.mqtt.publishClientSpecific(_.Start,ee,""))}setError(o){}clearError(){}swipeLeft(){this.mqtt.publishClientSpecific(_.RoatetPayload,this.clientId,"-1")}swipeRight(){this.mqtt.publishClientSpecific(_.RoatetPayload,this.clientId,"+1")}swipeUp(){this.mqtt.publishClientSpecific(_.Scale,this.clientId,"+0.1")}swipeDown(){this.mqtt.publishClientSpecific(_.Scale,this.clientId,"-0.1")}update(){let o=new Date().getTime();o-this.lastCalled>Je&&(this.prevY=this.sendIfChanged(_.XMovement,this.y,this.prevY),this.prevX=this.sendIfChanged(_.ZMovement,this.x,this.prevX),this.lastCalled=o)}setColor(o){document.body.style.backgroundColor=o}registerController(){this.mqtt.publishClientSpecific(_.Init,this.clientId,""),this.mqtt.on("message",(o,u)=>{const I=u.toString(),[l]=this.mqtt.parseTopic(o);switch(l){case _.ColorResponse:this.setColor(I);break;case _.Start:this.startGame()}})}sendIfChanged(o,u,I){return this.mqtt.publishClientSpecific(o,this.clientId,Math.floor(u*Ze).toString()),u}initEventListener(){window.addEventListener("devicemotion",o=>{o.accelerationIncludingGravity!==null&&o.accelerationIncludingGravity.x!==null&&o.accelerationIncludingGravity.y!==null&&(this.x=o.accelerationIncludingGravity.x,this.y=o.accelerationIncludingGravity.y,this.update())},!0)}activatePayload(){this.mqtt.publishClientSpecific(_.Drop,this.clientId,"")}disableJoin(){this.joinGameButton!==null&&(this.joinGameButton.classList.add("joined"),this.joinGameButton.innerText="")}joinGame(){this.isJoined=!0,this.disableJoin(),this.initEventListener(),this.clearError(),this.registerController(),this.isStarted&&this.toggleUi()}toggleUi(){var o;(o=this.preGameController)==null||o.remove(),this.gameController!==null&&document.body.append(this.gameController)}startGame(){this.isStarted=!0,this.isJoined&&this.toggleUi()}checkPermissions(){if(!this.isJoined)if(typeof DeviceMotionEvent<"u"){const o=DeviceOrientationEvent.requestPermission;typeof o=="function"?o().then(I=>{I==="granted"?this.joinGame():this.setError("You need to allow the usage of acceleration data!")}).catch(I=>{this.setError(I)}):this.joinGame()}else this.joinGame()}}new Qe; +`;return function(){var r=new Error("get-stack-trace"),s=r&&r.stack?r.stack.replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",a=o.console&&(o.console.warn||o.console.log);return a&&a.call(o.console,n,s),t.apply(this,arguments)}}var C;typeof Object.assign!="function"?C=function(e){if(e===l||e===null)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(e),n=1;n-1}function $(t){return t.trim().split(/\s+/g)}function F(t,e,i){if(t.indexOf&&!i)return t.indexOf(e);for(var n=0;np[e]}):n=n.sort()),n}function et(t,e){for(var i,n,r=e[0].toUpperCase()+e.slice(1),s=0;s1&&!i.firstMultiple?i.firstMultiple=qt(e):r===1&&(i.firstMultiple=!1);var s=i.firstInput,a=i.firstMultiple,c=a?a.center:s.center,f=e.center=Yt(n);e.timeStamp=vt(),e.deltaTime=e.timeStamp-s.timeStamp,e.angle=gt(c,f),e.distance=rt(c,f),de(i,e),e.offsetDirection=Gt(e.deltaX,e.deltaY);var p=Xt(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=p.x,e.overallVelocityY=p.y,e.overallVelocity=L(p.x)>L(p.y)?p.x:p.y,e.scale=a?Ee(a.pointers,n):1,e.rotation=a?ge(a.pointers,n):0,e.maxPointers=i.prevInput?e.pointers.length>i.prevInput.maxPointers?e.pointers.length:i.prevInput.maxPointers:e.pointers.length,Te(i,e);var O=t.element;Ut(e.srcEvent.target,O)&&(O=e.srcEvent.target),e.target=O}function de(t,e){var i=e.center,n=t.offsetDelta||{},r=t.prevDelta||{},s=t.prevInput||{};(e.eventType===v||s.eventType===h)&&(r=t.prevDelta={x:s.deltaX||0,y:s.deltaY||0},n=t.offsetDelta={x:i.x,y:i.y}),e.deltaX=r.x+(i.x-n.x),e.deltaY=r.y+(i.y-n.y)}function Te(t,e){var i=t.lastInterval||e,n=e.timeStamp-i.timeStamp,r,s,a,c;if(e.eventType!=m&&(n>fe||i.velocity===l)){var f=e.deltaX-i.deltaX,p=e.deltaY-i.deltaY,O=Xt(n,f,p);s=O.x,a=O.y,r=L(O.x)>L(O.y)?O.x:O.y,c=Gt(f,p),t.lastInterval=e}else r=i.velocity,s=i.velocityX,a=i.velocityY,c=i.direction;e.velocity=r,e.velocityX=s,e.velocityY=a,e.direction=c}function qt(t){for(var e=[],i=0;i=L(e)?t<0?W:k:e<0?B:z}function rt(t,e,i){i||(i=wt);var n=e[i[0]]-t[i[0]],r=e[i[1]]-t[i[1]];return Math.sqrt(n*n+r*r)}function gt(t,e,i){i||(i=wt);var n=e[i[0]]-t[i[0]],r=e[i[1]]-t[i[1]];return Math.atan2(r,n)*180/Math.PI}function ge(t,e){return gt(e[1],e[0],nt)+gt(t[1],t[0],nt)}function Ee(t,e){return rt(e[0],e[1],nt)/rt(t[0],t[1],nt)}var Ie={mousedown:v,mousemove:w,mouseup:h},ye="mousedown",_e="mousemove mouseup";function st(){this.evEl=ye,this.evWin=_e,this.pressed=!1,g.apply(this,arguments)}T(st,g,{handler:function(e){var i=Ie[e.type];i&v&&e.button===0&&(this.pressed=!0),i&w&&e.which!==1&&(i=h),this.pressed&&(i&h&&(this.pressed=!1),this.callback(this.manager,i,{pointers:[e],changedPointers:[e],pointerType:Tt,srcEvent:e}))}});var Ce={pointerdown:v,pointermove:w,pointerup:h,pointercancel:m,pointerout:m},Pe={2:V,3:ce,4:Tt,5:ue},Ft="pointerdown",Ht="pointermove pointerup pointercancel";o.MSPointerEvent&&!o.PointerEvent&&(Ft="MSPointerDown",Ht="MSPointerMove MSPointerUp MSPointerCancel");function Et(){this.evEl=Ft,this.evWin=Ht,g.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}T(Et,g,{handler:function(e){var i=this.store,n=!1,r=e.type.toLowerCase().replace("ms",""),s=Ce[r],a=Pe[e.pointerType]||e.pointerType,c=a==V,f=F(i,e.pointerId,"pointerId");s&v&&(e.button===0||c)?f<0&&(i.push(e),f=i.length-1):s&(h|m)&&(n=!0),!(f<0)&&(i[f]=e,this.callback(this.manager,s,{pointers:i,changedPointers:[e],pointerType:a,srcEvent:e}),n&&i.splice(f,1))}});var Ne={touchstart:v,touchmove:w,touchend:h,touchcancel:m},Oe="touchstart",Se="touchstart touchmove touchend touchcancel";function Vt(){this.evTarget=Oe,this.evWin=Se,this.started=!1,g.apply(this,arguments)}T(Vt,g,{handler:function(e){var i=Ne[e.type];if(i===v&&(this.started=!0),!!this.started){var n=Ae.call(this,e,i);i&(h|m)&&n[0].length-n[1].length===0&&(this.started=!1),this.callback(this.manager,i,{pointers:n[0],changedPointers:n[1],pointerType:V,srcEvent:e})}}});function Ae(t,e){var i=tt(t.touches),n=tt(t.changedTouches);return e&(h|m)&&(i=Rt(i.concat(n),"identifier",!0)),[i,n]}var De={touchstart:v,touchmove:w,touchend:h,touchcancel:m},Me="touchstart touchmove touchend touchcancel";function ot(){this.evTarget=Me,this.targetIds={},g.apply(this,arguments)}T(ot,g,{handler:function(e){var i=De[e.type],n=Ue.call(this,e,i);n&&this.callback(this.manager,i,{pointers:n[0],changedPointers:n[1],pointerType:V,srcEvent:e})}});function Ue(t,e){var i=tt(t.touches),n=this.targetIds;if(e&(v|w)&&i.length===1)return n[i[0].identifier]=!0,[i,i];var r,s,a=tt(t.changedTouches),c=[],f=this.target;if(s=i.filter(function(p){return Ut(p.target,f)}),e===v)for(r=0;r-1&&n.splice(s,1)};setTimeout(r,Re)}}function Le(t){for(var e=t.srcEvent.clientX,i=t.srcEvent.clientY,n=0;n-1&&this.requireFail.splice(e,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(t){return!!this.simultaneous[t.id]},emit:function(t){var e=this,i=this.state;function n(r){e.manager.emit(r,t)}i=b&&n(e.options.event+Zt(i))},tryEmit:function(t){if(this.canEmit())return this.emit(t);this.state=N},canEmit:function(){for(var t=0;te.threshold&&r&e.direction},attrTest:function(t){return y.prototype.attrTest.call(this,t)&&(this.state&E||!(this.state&E)&&this.directionTest(t))},emit:function(t){this.pX=t.deltaX,this.pY=t.deltaY;var e=Qt(t.direction);e&&(t.additionalEvent=this.options.event+e),this._super.emit.call(this,t)}});function Ct(){y.apply(this,arguments)}T(Ct,y,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[Y]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.scale-1)>this.options.threshold||this.state&E)},emit:function(t){if(t.scale!==1){var e=t.scale<1?"in":"out";t.additionalEvent=this.options.event+e}this._super.emit.call(this,t)}});function Pt(){M.apply(this,arguments),this._timer=null,this._input=null}T(Pt,M,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[Jt]},process:function(t){var e=this.options,i=t.pointers.length===e.pointers,n=t.distancee.time;if(this._input=t,!n||!i||t.eventType&(h|m)&&!r)this.reset();else if(t.eventType&v)this.reset(),this._timer=pt(function(){this.state=D,this.tryEmit()},e.time,this);else if(t.eventType&h)return D;return N},reset:function(){clearTimeout(this._timer)},emit:function(t){this.state===D&&(t&&t.eventType&h?this.manager.emit(this.options.event+"up",t):(this._input.timeStamp=vt(),this.manager.emit(this.options.event,this._input)))}});function Nt(){y.apply(this,arguments)}T(Nt,y,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[Y]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.rotation)>this.options.threshold||this.state&E)}});function Ot(){y.apply(this,arguments)}T(Ot,y,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:P|q,pointers:1},getTouchAction:function(){return ct.prototype.getTouchAction.call(this)},attrTest:function(t){var e=this.options.direction,i;return e&(P|q)?i=t.overallVelocity:e&P?i=t.overallVelocityX:e&q&&(i=t.overallVelocityY),this._super.attrTest.call(this,t)&&e&t.offsetDirection&&t.distance>this.options.threshold&&t.maxPointers==this.options.pointers&&L(i)>this.options.velocity&&t.eventType&h},emit:function(t){var e=Qt(t.offsetDirection);e&&this.manager.emit(this.options.event+e,t),this.manager.emit(this.options.event,t)}});function ut(){M.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}T(ut,M,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[yt]},process:function(t){var e=this.options,i=t.pointers.length===e.pointers,n=t.distancethis.swipeLeft()),R.on("swiperight",()=>this.swipeRight()),R.on("swipeup",()=>this.swipeUp()),R.on("swipedown",()=>this.swipeDown())}this.dropButton=document.getElementById("drop"),(o=this.dropButton)==null||o.addEventListener("click",()=>this.activatePayload()),(u=this.gameController)==null||u.remove(),(I=this.joinGameButton)==null||I.addEventListener("click",()=>this.checkPermissions()),(l=this.startGameButton)==null||l.addEventListener("click",()=>this.mqtt.publishClientSpecific(_.Start,ee,""))}setError(o){}clearError(){}swipeLeft(){this.mqtt.publishClientSpecific(_.RoatetPayload,this.clientId,"-1")}swipeRight(){this.mqtt.publishClientSpecific(_.RoatetPayload,this.clientId,"+1")}swipeUp(){this.mqtt.publishClientSpecific(_.Scale,this.clientId,"+0.1")}swipeDown(){this.mqtt.publishClientSpecific(_.Scale,this.clientId,"-0.1")}update(){this.prevY=this.sendIfChanged(_.XMovement,this.y,this.prevY),this.prevX=this.sendIfChanged(_.ZMovement,this.x,this.prevX)}setColor(o){document.body.style.backgroundColor=o}registerController(){this.mqtt.publishClientSpecific(_.Init,this.clientId,""),this.mqtt.on("message",(o,u)=>{const I=u.toString(),[l]=this.mqtt.parseTopic(o);switch(l){case _.ColorResponse:this.setColor(I);break;case _.Start:this.startGame()}})}sendIfChanged(o,u,I){return this.mqtt.publishClientSpecific(o,this.clientId,u.toString()),u}initEventListener(){window.addEventListener("devicemotion",o=>{o.accelerationIncludingGravity!==null&&o.accelerationIncludingGravity.x!==null&&o.accelerationIncludingGravity.y!==null&&(this.x=o.accelerationIncludingGravity.x,this.y=o.accelerationIncludingGravity.y)},!0),setInterval(()=>this.update(),Je)}activatePayload(){this.mqtt.publishClientSpecific(_.Drop,this.clientId,"")}disableJoin(){this.joinGameButton!==null&&(this.joinGameButton.classList.add("joined"),this.joinGameButton.innerText="")}joinGame(){this.isJoined=!0,this.disableJoin(),this.initEventListener(),this.clearError(),this.registerController(),this.isStarted&&this.toggleUi()}toggleUi(){var o;(o=this.preGameController)==null||o.remove(),this.gameController!==null&&document.body.append(this.gameController)}startGame(){this.isStarted=!0,this.isJoined&&this.toggleUi()}checkPermissions(){if(!this.isJoined)if(typeof DeviceMotionEvent<"u"){const o=DeviceOrientationEvent.requestPermission;typeof o=="function"?o().then(I=>{I==="granted"?this.joinGame():this.setError("You need to allow the usage of acceleration data!")}).catch(I=>{this.setError(I)}):this.joinGame()}else this.joinGame()}}new Ze; diff --git a/assets/main-PIDGtTiA.js b/assets/main-tP-COfH4.js similarity index 99% rename from assets/main-PIDGtTiA.js rename to assets/main-tP-COfH4.js index 3d2ea07..b15ad93 100644 --- a/assets/main-PIDGtTiA.js +++ b/assets/main-tP-COfH4.js @@ -3551,4 +3551,4 @@ void main() { squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); -}`;function S82(F,g,S){let D=new P6;const j=new _e,U=new _e,Y=new Gn,X=new g82({depthPacking:au2}),$=new k82,t2={},n2=S.maxTextureSize,s2={[P1]:Oi,[Oi]:P1,[Xr]:Xr},m=new ls({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new _e},radius:{value:4}},vertexShader:v82,fragmentShader:B82}),f2=m.clone();f2.defines.HORIZONTAL_PASS=1;const a2=new xr;a2.setAttribute("position",new yo(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const A2=new yi(a2,m),p2=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=VW;let o2=this.type;this.render=function(b2,F2,j2){if(p2.enabled===!1||p2.autoUpdate===!1&&p2.needsUpdate===!1||b2.length===0)return;const J2=F.getRenderTarget(),B2=F.getActiveCubeFace(),T2=F.getActiveMipmapLevel(),ht=F.state;ht.setBlending(T1),ht.buffers.color.setClear(1,1,1,1),ht.buffers.depth.setTest(!0),ht.setScissorTest(!1);const St=o2!==qo&&this.type===qo,q2=o2===qo&&this.type!==qo;for(let tt=0,it=b2.length;ttn2||j.y>n2)&&(j.x>n2&&(U.x=Math.floor(n2/mt.x),j.x=U.x*mt.x,_t.mapSize.x=U.x),j.y>n2&&(U.y=Math.floor(n2/mt.y),j.y=U.y*mt.y,_t.mapSize.y=U.y)),_t.map===null||St===!0||q2===!0){const Bt=this.type!==qo?{minFilter:gn,magFilter:gn}:{};_t.map!==null&&_t.map.dispose(),_t.map=new us(j.x,j.y,Bt),_t.map.texture.name=Ct.name+".shadowMap",_t.camera.updateProjectionMatrix()}F.setRenderTarget(_t.map),F.clear();const vt=_t.getViewportCount();for(let Bt=0;Bt0||F2.map&&F2.alphaTest>0){const ht=B2.uuid,St=F2.uuid;let q2=t2[ht];q2===void 0&&(q2={},t2[ht]=q2);let tt=q2[St];tt===void 0&&(tt=B2.clone(),q2[St]=tt),B2=tt}if(B2.visible=F2.visible,B2.wireframe=F2.wireframe,J2===qo?B2.side=F2.shadowSide!==null?F2.shadowSide:F2.side:B2.side=F2.shadowSide!==null?F2.shadowSide:s2[F2.side],B2.alphaMap=F2.alphaMap,B2.alphaTest=F2.alphaTest,B2.map=F2.map,B2.clipShadows=F2.clipShadows,B2.clippingPlanes=F2.clippingPlanes,B2.clipIntersection=F2.clipIntersection,B2.displacementMap=F2.displacementMap,B2.displacementScale=F2.displacementScale,B2.displacementBias=F2.displacementBias,B2.wireframeLinewidth=F2.wireframeLinewidth,B2.linewidth=F2.linewidth,j2.isPointLight===!0&&B2.isMeshDistanceMaterial===!0){const ht=F.properties.get(B2);ht.light=j2}return B2}function P2(b2,F2,j2,J2,B2){if(b2.visible===!1)return;if(b2.layers.test(F2.layers)&&(b2.isMesh||b2.isLine||b2.isPoints)&&(b2.castShadow||b2.receiveShadow&&B2===qo)&&(!b2.frustumCulled||D.intersectsObject(b2))){b2.modelViewMatrix.multiplyMatrices(j2.matrixWorldInverse,b2.matrixWorld);const St=g.update(b2),q2=b2.material;if(Array.isArray(q2)){const tt=St.groups;for(let it=0,Ct=tt.length;it=1):mt.indexOf("OpenGL ES")!==-1&&(_t=parseFloat(/^OpenGL ES (\d)/.exec(mt)[1]),Ct=_t>=2);let vt=null,Bt={};const X2=F.getParameter(F.SCISSOR_BOX),ct=F.getParameter(F.VIEWPORT),zt=new Gn().fromArray(X2),Qt=new Gn().fromArray(ct);function Kt(G2,Ht,$2,Lt){const Yt=new Uint8Array(4),o0=F.createTexture();F.bindTexture(G2,o0),F.texParameteri(G2,F.TEXTURE_MIN_FILTER,F.NEAREST),F.texParameteri(G2,F.TEXTURE_MAG_FILTER,F.NEAREST);for(let I0=0;I0<$2;I0++)D&&(G2===F.TEXTURE_3D||G2===F.TEXTURE_2D_ARRAY)?F.texImage3D(Ht,0,F.RGBA,1,1,Lt,0,F.RGBA,F.UNSIGNED_BYTE,Yt):F.texImage2D(Ht+I0,0,F.RGBA,1,1,0,F.RGBA,F.UNSIGNED_BYTE,Yt);return o0}const de={};de[F.TEXTURE_2D]=Kt(F.TEXTURE_2D,F.TEXTURE_2D,1),de[F.TEXTURE_CUBE_MAP]=Kt(F.TEXTURE_CUBE_MAP,F.TEXTURE_CUBE_MAP_POSITIVE_X,6),D&&(de[F.TEXTURE_2D_ARRAY]=Kt(F.TEXTURE_2D_ARRAY,F.TEXTURE_2D_ARRAY,1,1),de[F.TEXTURE_3D]=Kt(F.TEXTURE_3D,F.TEXTURE_3D,1,1)),X.setClear(0,0,0,1),$.setClear(1),t2.setClear(0),Be(F.DEPTH_TEST),$.setFunc(k6),Me(!1),p0(iN),Be(F.CULL_FACE),Ce(T1);function Be(G2){m[G2]!==!0&&(F.enable(G2),m[G2]=!0)}function me(G2){m[G2]!==!1&&(F.disable(G2),m[G2]=!1)}function h0(G2,Ht){return f2[G2]!==Ht?(F.bindFramebuffer(G2,Ht),f2[G2]=Ht,D&&(G2===F.DRAW_FRAMEBUFFER&&(f2[F.FRAMEBUFFER]=Ht),G2===F.FRAMEBUFFER&&(f2[F.DRAW_FRAMEBUFFER]=Ht)),!0):!1}function Dn(G2,Ht){let $2=A2,Lt=!1;if(G2)if($2=a2.get(Ht),$2===void 0&&($2=[],a2.set(Ht,$2)),G2.isWebGLMultipleRenderTargets){const Yt=G2.texture;if($2.length!==Yt.length||$2[0]!==F.COLOR_ATTACHMENT0){for(let o0=0,I0=Yt.length;o0"u"?!1:/OculusBrowser/g.test(navigator.userAgent),a2=new WeakMap;let A2;const p2=new WeakMap;let o2=!1;try{o2=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x2(M2,g2){return o2?new OffscreenCanvas(M2,g2):Gu("canvas")}function d2(M2,g2,Z2,Dt){let xt=1;if((M2.width>Dt||M2.height>Dt)&&(xt=Dt/Math.max(M2.width,M2.height)),xt<1||g2===!0)if(typeof HTMLImageElement<"u"&&M2 instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&M2 instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&M2 instanceof ImageBitmap){const It=g2?w6:Math.floor,le=It(xt*M2.width),Pt=It(xt*M2.height);A2===void 0&&(A2=x2(le,Pt));const et=Z2?x2(le,Pt):A2;return et.width=le,et.height=Pt,et.getContext("2d").drawImage(M2,0,0,le,Pt),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+M2.width+"x"+M2.height+") to ("+le+"x"+Pt+")."),et}else return"data"in M2&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+M2.width+"x"+M2.height+")."),M2;return M2}function P2(M2){return FN(M2.width)&&FN(M2.height)}function b2(M2){return X?!1:M2.wrapS!==qr||M2.wrapT!==qr||M2.minFilter!==gn&&M2.minFilter!==wr}function F2(M2,g2){return M2.generateMipmaps&&g2&&M2.minFilter!==gn&&M2.minFilter!==wr}function j2(M2){F.generateMipmap(M2)}function J2(M2,g2,Z2,Dt,xt=!1){if(X===!1)return g2;if(M2!==null){if(F[M2]!==void 0)return F[M2];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+M2+"'")}let It=g2;return g2===F.RED&&(Z2===F.FLOAT&&(It=F.R32F),Z2===F.HALF_FLOAT&&(It=F.R16F),Z2===F.UNSIGNED_BYTE&&(It=F.R8)),g2===F.RED_INTEGER&&(Z2===F.UNSIGNED_BYTE&&(It=F.R8UI),Z2===F.UNSIGNED_SHORT&&(It=F.R16UI),Z2===F.UNSIGNED_INT&&(It=F.R32UI),Z2===F.BYTE&&(It=F.R8I),Z2===F.SHORT&&(It=F.R16I),Z2===F.INT&&(It=F.R32I)),g2===F.RG&&(Z2===F.FLOAT&&(It=F.RG32F),Z2===F.HALF_FLOAT&&(It=F.RG16F),Z2===F.UNSIGNED_BYTE&&(It=F.RG8)),g2===F.RGBA&&(Z2===F.FLOAT&&(It=F.RGBA32F),Z2===F.HALF_FLOAT&&(It=F.RGBA16F),Z2===F.UNSIGNED_BYTE&&(It=Dt===qe&&xt===!1?F.SRGB8_ALPHA8:F.RGBA8),Z2===F.UNSIGNED_SHORT_4_4_4_4&&(It=F.RGBA4),Z2===F.UNSIGNED_SHORT_5_5_5_1&&(It=F.RGB5_A1)),(It===F.R16F||It===F.R32F||It===F.RG16F||It===F.RG32F||It===F.RGBA16F||It===F.RGBA32F)&&g.get("EXT_color_buffer_float"),It}function B2(M2,g2,Z2){return F2(M2,Z2)===!0||M2.isFramebufferTexture&&M2.minFilter!==gn&&M2.minFilter!==wr?Math.log2(Math.max(g2.width,g2.height))+1:M2.mipmaps!==void 0&&M2.mipmaps.length>0?M2.mipmaps.length:M2.isCompressedTexture&&Array.isArray(M2.image)?g2.mipmaps.length:1}function T2(M2){return M2===gn||M2===fN||M2===F8?F.NEAREST:F.LINEAR}function ht(M2){const g2=M2.target;g2.removeEventListener("dispose",ht),q2(g2),g2.isVideoTexture&&a2.delete(g2)}function St(M2){const g2=M2.target;g2.removeEventListener("dispose",St),it(g2)}function q2(M2){const g2=D.get(M2);if(g2.__webglInit===void 0)return;const Z2=M2.source,Dt=p2.get(Z2);if(Dt){const xt=Dt[g2.__cacheKey];xt.usedTimes--,xt.usedTimes===0&&tt(M2),Object.keys(Dt).length===0&&p2.delete(Z2)}D.remove(M2)}function tt(M2){const g2=D.get(M2);F.deleteTexture(g2.__webglTexture);const Z2=M2.source,Dt=p2.get(Z2);delete Dt[g2.__cacheKey],Y.memory.textures--}function it(M2){const g2=M2.texture,Z2=D.get(M2),Dt=D.get(g2);if(Dt.__webglTexture!==void 0&&(F.deleteTexture(Dt.__webglTexture),Y.memory.textures--),M2.depthTexture&&M2.depthTexture.dispose(),M2.isWebGLCubeRenderTarget)for(let xt=0;xt<6;xt++){if(Array.isArray(Z2.__webglFramebuffer[xt]))for(let It=0;It=$&&console.warn("THREE.WebGLTextures: Trying to use "+M2+" texture units while this GPU supports only "+$),Ct+=1,M2}function vt(M2){const g2=[];return g2.push(M2.wrapS),g2.push(M2.wrapT),g2.push(M2.wrapR||0),g2.push(M2.magFilter),g2.push(M2.minFilter),g2.push(M2.anisotropy),g2.push(M2.internalFormat),g2.push(M2.format),g2.push(M2.type),g2.push(M2.generateMipmaps),g2.push(M2.premultiplyAlpha),g2.push(M2.flipY),g2.push(M2.unpackAlignment),g2.push(M2.colorSpace),g2.join()}function Bt(M2,g2){const Z2=D.get(M2);if(M2.isVideoTexture&&pn(M2),M2.isRenderTargetTexture===!1&&M2.version>0&&Z2.__version!==M2.version){const Dt=M2.image;if(Dt===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Dt.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{h0(Z2,M2,g2);return}}S.bindTexture(F.TEXTURE_2D,Z2.__webglTexture,F.TEXTURE0+g2)}function X2(M2,g2){const Z2=D.get(M2);if(M2.version>0&&Z2.__version!==M2.version){h0(Z2,M2,g2);return}S.bindTexture(F.TEXTURE_2D_ARRAY,Z2.__webglTexture,F.TEXTURE0+g2)}function ct(M2,g2){const Z2=D.get(M2);if(M2.version>0&&Z2.__version!==M2.version){h0(Z2,M2,g2);return}S.bindTexture(F.TEXTURE_3D,Z2.__webglTexture,F.TEXTURE0+g2)}function zt(M2,g2){const Z2=D.get(M2);if(M2.version>0&&Z2.__version!==M2.version){Dn(Z2,M2,g2);return}S.bindTexture(F.TEXTURE_CUBE_MAP,Z2.__webglTexture,F.TEXTURE0+g2)}const Qt={[Qr]:F.REPEAT,[qr]:F.CLAMP_TO_EDGE,[S6]:F.MIRRORED_REPEAT},Kt={[gn]:F.NEAREST,[fN]:F.NEAREST_MIPMAP_NEAREST,[F8]:F.NEAREST_MIPMAP_LINEAR,[wr]:F.LINEAR,[ru2]:F.LINEAR_MIPMAP_NEAREST,[ju]:F.LINEAR_MIPMAP_LINEAR},de={[yu2]:F.NEVER,[wu2]:F.ALWAYS,[gu2]:F.LESS,[vu2]:F.LEQUAL,[ku2]:F.EQUAL,[Cu2]:F.GEQUAL,[Bu2]:F.GREATER,[Su2]:F.NOTEQUAL};function Be(M2,g2,Z2){if(Z2?(F.texParameteri(M2,F.TEXTURE_WRAP_S,Qt[g2.wrapS]),F.texParameteri(M2,F.TEXTURE_WRAP_T,Qt[g2.wrapT]),(M2===F.TEXTURE_3D||M2===F.TEXTURE_2D_ARRAY)&&F.texParameteri(M2,F.TEXTURE_WRAP_R,Qt[g2.wrapR]),F.texParameteri(M2,F.TEXTURE_MAG_FILTER,Kt[g2.magFilter]),F.texParameteri(M2,F.TEXTURE_MIN_FILTER,Kt[g2.minFilter])):(F.texParameteri(M2,F.TEXTURE_WRAP_S,F.CLAMP_TO_EDGE),F.texParameteri(M2,F.TEXTURE_WRAP_T,F.CLAMP_TO_EDGE),(M2===F.TEXTURE_3D||M2===F.TEXTURE_2D_ARRAY)&&F.texParameteri(M2,F.TEXTURE_WRAP_R,F.CLAMP_TO_EDGE),(g2.wrapS!==qr||g2.wrapT!==qr)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),F.texParameteri(M2,F.TEXTURE_MAG_FILTER,T2(g2.magFilter)),F.texParameteri(M2,F.TEXTURE_MIN_FILTER,T2(g2.minFilter)),g2.minFilter!==gn&&g2.minFilter!==wr&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),g2.compareFunction&&(F.texParameteri(M2,F.TEXTURE_COMPARE_MODE,F.COMPARE_REF_TO_TEXTURE),F.texParameteri(M2,F.TEXTURE_COMPARE_FUNC,de[g2.compareFunction])),g.has("EXT_texture_filter_anisotropic")===!0){const Dt=g.get("EXT_texture_filter_anisotropic");if(g2.magFilter===gn||g2.minFilter!==F8&&g2.minFilter!==ju||g2.type===E1&&g.has("OES_texture_float_linear")===!1||X===!1&&g2.type===Ou&&g.has("OES_texture_half_float_linear")===!1)return;(g2.anisotropy>1||D.get(g2).__currentAnisotropy)&&(F.texParameterf(M2,Dt.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(g2.anisotropy,j.getMaxAnisotropy())),D.get(g2).__currentAnisotropy=g2.anisotropy)}}function me(M2,g2){let Z2=!1;M2.__webglInit===void 0&&(M2.__webglInit=!0,g2.addEventListener("dispose",ht));const Dt=g2.source;let xt=p2.get(Dt);xt===void 0&&(xt={},p2.set(Dt,xt));const It=vt(g2);if(It!==M2.__cacheKey){xt[It]===void 0&&(xt[It]={texture:F.createTexture(),usedTimes:0},Y.memory.textures++,Z2=!0),xt[It].usedTimes++;const le=xt[M2.__cacheKey];le!==void 0&&(xt[M2.__cacheKey].usedTimes--,le.usedTimes===0&&tt(g2)),M2.__cacheKey=It,M2.__webglTexture=xt[It].texture}return Z2}function h0(M2,g2,Z2){let Dt=F.TEXTURE_2D;(g2.isDataArrayTexture||g2.isCompressedArrayTexture)&&(Dt=F.TEXTURE_2D_ARRAY),g2.isData3DTexture&&(Dt=F.TEXTURE_3D);const xt=me(M2,g2),It=g2.source;S.bindTexture(Dt,M2.__webglTexture,F.TEXTURE0+Z2);const le=D.get(It);if(It.version!==le.__version||xt===!0){S.activeTexture(F.TEXTURE0+Z2),F.pixelStorei(F.UNPACK_FLIP_Y_WEBGL,g2.flipY),F.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL,g2.premultiplyAlpha),F.pixelStorei(F.UNPACK_ALIGNMENT,g2.unpackAlignment),F.pixelStorei(F.UNPACK_COLORSPACE_CONVERSION_WEBGL,F.NONE);const Pt=b2(g2)&&P2(g2.image)===!1;let et=d2(g2.image,Pt,!1,n2);et=In(g2,et);const ge=P2(et)||X,fe=U.convert(g2.format,g2.colorSpace);let ye=U.convert(g2.type),oe=J2(g2.internalFormat,fe,ye,g2.colorSpace);Be(Dt,g2,ge);let se;const ze=g2.mipmaps,C0=X&&g2.isVideoTexture!==!0,G2=le.__version===void 0||xt===!0,Ht=B2(g2,et,ge);if(g2.isDepthTexture)oe=F.DEPTH_COMPONENT,X?g2.type===E1?oe=F.DEPTH_COMPONENT32F:g2.type===M1?oe=F.DEPTH_COMPONENT24:g2.type===is?oe=F.DEPTH24_STENCIL8:oe=F.DEPTH_COMPONENT16:g2.type===E1&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),g2.format===rs&&oe===F.DEPTH_COMPONENT&&g2.type!==R6&&g2.type!==M1&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),g2.type=M1,ye=U.convert(g2.type)),g2.format===a4&&oe===F.DEPTH_COMPONENT&&(oe=F.DEPTH_STENCIL,g2.type!==is&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),g2.type=is,ye=U.convert(g2.type))),G2&&(C0?S.texStorage2D(F.TEXTURE_2D,1,oe,et.width,et.height):S.texImage2D(F.TEXTURE_2D,0,oe,et.width,et.height,0,fe,ye,null));else if(g2.isDataTexture)if(ze.length>0&&ge){C0&&G2&&S.texStorage2D(F.TEXTURE_2D,Ht,oe,ze[0].width,ze[0].height);for(let $2=0,Lt=ze.length;$2>=1,Lt>>=1}}else if(ze.length>0&&ge){C0&&G2&&S.texStorage2D(F.TEXTURE_2D,Ht,oe,ze[0].width,ze[0].height);for(let $2=0,Lt=ze.length;$20&&G2++,S.texStorage2D(F.TEXTURE_CUBE_MAP,G2,se,et[0].width,et[0].height));for(let $2=0;$2<6;$2++)if(Pt){ze?S.texSubImage2D(F.TEXTURE_CUBE_MAP_POSITIVE_X+$2,0,0,0,et[$2].width,et[$2].height,ye,oe,et[$2].data):S.texImage2D(F.TEXTURE_CUBE_MAP_POSITIVE_X+$2,0,se,et[$2].width,et[$2].height,0,ye,oe,et[$2].data);for(let Lt=0;Lt>It),ye=Math.max(1,g2.height>>It);xt===F.TEXTURE_3D||xt===F.TEXTURE_2D_ARRAY?S.texImage3D(xt,It,et,fe,ye,g2.depth,0,le,Pt,null):S.texImage2D(xt,It,et,fe,ye,0,le,Pt,null)}S.bindFramebuffer(F.FRAMEBUFFER,M2),v0(g2)?m.framebufferTexture2DMultisampleEXT(F.FRAMEBUFFER,Dt,xt,D.get(Z2).__webglTexture,0,be(g2)):(xt===F.TEXTURE_2D||xt>=F.TEXTURE_CUBE_MAP_POSITIVE_X&&xt<=F.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&F.framebufferTexture2D(F.FRAMEBUFFER,Dt,xt,D.get(Z2).__webglTexture,It),S.bindFramebuffer(F.FRAMEBUFFER,null)}function Y2(M2,g2,Z2){if(F.bindRenderbuffer(F.RENDERBUFFER,M2),g2.depthBuffer&&!g2.stencilBuffer){let Dt=F.DEPTH_COMPONENT16;if(Z2||v0(g2)){const xt=g2.depthTexture;xt&&xt.isDepthTexture&&(xt.type===E1?Dt=F.DEPTH_COMPONENT32F:xt.type===M1&&(Dt=F.DEPTH_COMPONENT24));const It=be(g2);v0(g2)?m.renderbufferStorageMultisampleEXT(F.RENDERBUFFER,It,Dt,g2.width,g2.height):F.renderbufferStorageMultisample(F.RENDERBUFFER,It,Dt,g2.width,g2.height)}else F.renderbufferStorage(F.RENDERBUFFER,Dt,g2.width,g2.height);F.framebufferRenderbuffer(F.FRAMEBUFFER,F.DEPTH_ATTACHMENT,F.RENDERBUFFER,M2)}else if(g2.depthBuffer&&g2.stencilBuffer){const Dt=be(g2);Z2&&v0(g2)===!1?F.renderbufferStorageMultisample(F.RENDERBUFFER,Dt,F.DEPTH24_STENCIL8,g2.width,g2.height):v0(g2)?m.renderbufferStorageMultisampleEXT(F.RENDERBUFFER,Dt,F.DEPTH24_STENCIL8,g2.width,g2.height):F.renderbufferStorage(F.RENDERBUFFER,F.DEPTH_STENCIL,g2.width,g2.height),F.framebufferRenderbuffer(F.FRAMEBUFFER,F.DEPTH_STENCIL_ATTACHMENT,F.RENDERBUFFER,M2)}else{const Dt=g2.isWebGLMultipleRenderTargets===!0?g2.texture:[g2.texture];for(let xt=0;xt0){Z2.__webglFramebuffer[Pt]=[];for(let et=0;et0){Z2.__webglFramebuffer=[];for(let Pt=0;Pt0&&v0(M2)===!1){const Pt=It?g2:[g2];Z2.__webglMultisampledFramebuffer=F.createFramebuffer(),Z2.__webglColorRenderbuffer=[],S.bindFramebuffer(F.FRAMEBUFFER,Z2.__webglMultisampledFramebuffer);for(let et=0;et0)for(let et=0;et0)for(let et=0;et0&&v0(M2)===!1){const g2=M2.isWebGLMultipleRenderTargets?M2.texture:[M2.texture],Z2=M2.width,Dt=M2.height;let xt=F.COLOR_BUFFER_BIT;const It=[],le=M2.stencilBuffer?F.DEPTH_STENCIL_ATTACHMENT:F.DEPTH_ATTACHMENT,Pt=D.get(M2),et=M2.isWebGLMultipleRenderTargets===!0;if(et)for(let ge=0;ge0&&g.has("WEBGL_multisampled_render_to_texture")===!0&&g2.__useRenderToTexture!==!1}function pn(M2){const g2=Y.render.frame;a2.get(M2)!==g2&&(a2.set(M2,g2),M2.update())}function In(M2,g2){const Z2=M2.colorSpace,Dt=M2.format,xt=M2.type;return M2.isCompressedTexture===!0||M2.format===C6||Z2!==go&&Z2!==ss&&(Z2===qe?X===!1?g.has("EXT_sRGB")===!0&&Dt===Zr?(M2.format=C6,M2.minFilter=wr,M2.generateMipmaps=!1):g2=rH.sRGBToLinear(g2):(Dt!==Zr||xt!==D1)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",Z2)),g2}this.allocateTextureUnit=mt,this.resetTextureUnits=_t,this.setTexture2D=Bt,this.setTexture2DArray=X2,this.setTexture3D=ct,this.setTextureCube=zt,this.rebindTextures=Re,this.setupRenderTarget=Me,this.updateRenderTargetMipmap=p0,this.updateMultisampleRenderTarget=He,this.setupDepthRenderbuffer=Ce,this.setupFrameBufferTexture=We,this.useMultisampledRTT=v0}function x82(F,g,S){const D=S.isWebGL2;function j(U,Y=ss){let X;if(U===D1)return F.UNSIGNED_BYTE;if(U===ZW)return F.UNSIGNED_SHORT_4_4_4_4;if(U===JW)return F.UNSIGNED_SHORT_5_5_5_1;if(U===ou2)return F.BYTE;if(U===su2)return F.SHORT;if(U===R6)return F.UNSIGNED_SHORT;if(U===qW)return F.INT;if(U===M1)return F.UNSIGNED_INT;if(U===E1)return F.FLOAT;if(U===Ou)return D?F.HALF_FLOAT:(X=g.get("OES_texture_half_float"),X!==null?X.HALF_FLOAT_OES:null);if(U===uu2)return F.ALPHA;if(U===Zr)return F.RGBA;if(U===lu2)return F.LUMINANCE;if(U===fu2)return F.LUMINANCE_ALPHA;if(U===rs)return F.DEPTH_COMPONENT;if(U===a4)return F.DEPTH_STENCIL;if(U===C6)return X=g.get("EXT_sRGB"),X!==null?X.SRGB_ALPHA_EXT:null;if(U===pu2)return F.RED;if(U===KW)return F.RED_INTEGER;if(U===_u2)return F.RG;if(U===$W)return F.RG_INTEGER;if(U===tH)return F.RGBA_INTEGER;if(U===L8||U===j8||U===O8||U===G8)if(Y===qe)if(X=g.get("WEBGL_compressed_texture_s3tc_srgb"),X!==null){if(U===L8)return X.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(U===j8)return X.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(U===O8)return X.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(U===G8)return X.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(X=g.get("WEBGL_compressed_texture_s3tc"),X!==null){if(U===L8)return X.COMPRESSED_RGB_S3TC_DXT1_EXT;if(U===j8)return X.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(U===O8)return X.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(U===G8)return X.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(U===pN||U===_N||U===cN||U===hN)if(X=g.get("WEBGL_compressed_texture_pvrtc"),X!==null){if(U===pN)return X.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(U===_N)return X.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(U===cN)return X.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(U===hN)return X.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(U===cu2)return X=g.get("WEBGL_compressed_texture_etc1"),X!==null?X.COMPRESSED_RGB_ETC1_WEBGL:null;if(U===mN||U===aN)if(X=g.get("WEBGL_compressed_texture_etc"),X!==null){if(U===mN)return Y===qe?X.COMPRESSED_SRGB8_ETC2:X.COMPRESSED_RGB8_ETC2;if(U===aN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:X.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(U===AN||U===dN||U===yN||U===gN||U===kN||U===vN||U===BN||U===SN||U===CN||U===wN||U===xN||U===MN||U===EN||U===TN)if(X=g.get("WEBGL_compressed_texture_astc"),X!==null){if(U===AN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:X.COMPRESSED_RGBA_ASTC_4x4_KHR;if(U===dN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:X.COMPRESSED_RGBA_ASTC_5x4_KHR;if(U===yN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:X.COMPRESSED_RGBA_ASTC_5x5_KHR;if(U===gN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:X.COMPRESSED_RGBA_ASTC_6x5_KHR;if(U===kN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:X.COMPRESSED_RGBA_ASTC_6x6_KHR;if(U===vN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:X.COMPRESSED_RGBA_ASTC_8x5_KHR;if(U===BN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:X.COMPRESSED_RGBA_ASTC_8x6_KHR;if(U===SN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:X.COMPRESSED_RGBA_ASTC_8x8_KHR;if(U===CN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:X.COMPRESSED_RGBA_ASTC_10x5_KHR;if(U===wN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:X.COMPRESSED_RGBA_ASTC_10x6_KHR;if(U===xN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:X.COMPRESSED_RGBA_ASTC_10x8_KHR;if(U===MN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:X.COMPRESSED_RGBA_ASTC_10x10_KHR;if(U===EN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:X.COMPRESSED_RGBA_ASTC_12x10_KHR;if(U===TN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:X.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(U===U8)if(X=g.get("EXT_texture_compression_bptc"),X!==null){if(U===U8)return Y===qe?X.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:X.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(U===hu2||U===RN||U===DN||U===PN)if(X=g.get("EXT_texture_compression_rgtc"),X!==null){if(U===U8)return X.COMPRESSED_RED_RGTC1_EXT;if(U===RN)return X.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(U===DN)return X.COMPRESSED_RED_GREEN_RGTC2_EXT;if(U===PN)return X.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return U===is?D?F.UNSIGNED_INT_24_8:(X=g.get("WEBGL_depth_texture"),X!==null?X.UNSIGNED_INT_24_8_WEBGL:null):F[U]!==void 0?F[U]:null}return{convert:j}}class M82 extends rr{constructor(g=[]){super(),this.isArrayCamera=!0,this.cameras=g}}class np extends Zn{constructor(){super(),this.isGroup=!0,this.type="Group"}}const E82={type:"move"};class p6{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new np,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new np,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new L2,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new L2),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new np,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new L2,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new L2),this._grip}dispatchEvent(g){return this._targetRay!==null&&this._targetRay.dispatchEvent(g),this._grip!==null&&this._grip.dispatchEvent(g),this._hand!==null&&this._hand.dispatchEvent(g),this}connect(g){if(g&&g.hand){const S=this._hand;if(S)for(const D of g.hand.values())this._getHandJoint(S,D)}return this.dispatchEvent({type:"connected",data:g}),this}disconnect(g){return this.dispatchEvent({type:"disconnected",data:g}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(g,S,D){let j=null,U=null,Y=null;const X=this._targetRay,$=this._grip,t2=this._hand;if(g&&S.session.visibilityState!=="visible-blurred"){if(t2&&g.hand){Y=!0;for(const A2 of g.hand.values()){const p2=S.getJointPose(A2,D),o2=this._getHandJoint(t2,A2);p2!==null&&(o2.matrix.fromArray(p2.transform.matrix),o2.matrix.decompose(o2.position,o2.rotation,o2.scale),o2.matrixWorldNeedsUpdate=!0,o2.jointRadius=p2.radius),o2.visible=p2!==null}const n2=t2.joints["index-finger-tip"],s2=t2.joints["thumb-tip"],m=n2.position.distanceTo(s2.position),f2=.02,a2=.005;t2.inputState.pinching&&m>f2+a2?(t2.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:g.handedness,target:this})):!t2.inputState.pinching&&m<=f2-a2&&(t2.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:g.handedness,target:this}))}else $!==null&&g.gripSpace&&(U=S.getPose(g.gripSpace,D),U!==null&&($.matrix.fromArray(U.transform.matrix),$.matrix.decompose($.position,$.rotation,$.scale),$.matrixWorldNeedsUpdate=!0,U.linearVelocity?($.hasLinearVelocity=!0,$.linearVelocity.copy(U.linearVelocity)):$.hasLinearVelocity=!1,U.angularVelocity?($.hasAngularVelocity=!0,$.angularVelocity.copy(U.angularVelocity)):$.hasAngularVelocity=!1));X!==null&&(j=S.getPose(g.targetRaySpace,D),j===null&&U!==null&&(j=U),j!==null&&(X.matrix.fromArray(j.transform.matrix),X.matrix.decompose(X.position,X.rotation,X.scale),X.matrixWorldNeedsUpdate=!0,j.linearVelocity?(X.hasLinearVelocity=!0,X.linearVelocity.copy(j.linearVelocity)):X.hasLinearVelocity=!1,j.angularVelocity?(X.hasAngularVelocity=!0,X.angularVelocity.copy(j.angularVelocity)):X.hasAngularVelocity=!1,this.dispatchEvent(E82)))}return X!==null&&(X.visible=j!==null),$!==null&&($.visible=U!==null),t2!==null&&(t2.visible=Y!==null),this}_getHandJoint(g,S){if(g.joints[S.jointName]===void 0){const D=new np;D.matrixAutoUpdate=!1,D.visible=!1,g.joints[S.jointName]=D,g.add(D)}return g.joints[S.jointName]}}class T82 extends gi{constructor(g,S,D,j,U,Y,X,$,t2,n2){if(n2=n2!==void 0?n2:rs,n2!==rs&&n2!==a4)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");D===void 0&&n2===rs&&(D=M1),D===void 0&&n2===a4&&(D=is),super(null,j,U,Y,X,$,n2,D,t2),this.isDepthTexture=!0,this.image={width:g,height:S},this.magFilter=X!==void 0?X:gn,this.minFilter=$!==void 0?$:gn,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(g){return super.copy(g),this.compareFunction=g.compareFunction,this}toJSON(g){const S=super.toJSON(g);return this.compareFunction!==null&&(S.compareFunction=this.compareFunction),S}}class R82 extends d4{constructor(g,S){super();const D=this;let j=null,U=1,Y=null,X="local-floor",$=1,t2=null,n2=null,s2=null,m=null,f2=null,a2=null;const A2=S.getContextAttributes();let p2=null,o2=null;const x2=[],d2=[],P2=new rr;P2.layers.enable(1),P2.viewport=new Gn;const b2=new rr;b2.layers.enable(2),b2.viewport=new Gn;const F2=[P2,b2],j2=new M82;j2.layers.enable(1),j2.layers.enable(2);let J2=null,B2=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(X2){let ct=x2[X2];return ct===void 0&&(ct=new p6,x2[X2]=ct),ct.getTargetRaySpace()},this.getControllerGrip=function(X2){let ct=x2[X2];return ct===void 0&&(ct=new p6,x2[X2]=ct),ct.getGripSpace()},this.getHand=function(X2){let ct=x2[X2];return ct===void 0&&(ct=new p6,x2[X2]=ct),ct.getHandSpace()};function T2(X2){const ct=d2.indexOf(X2.inputSource);if(ct===-1)return;const zt=x2[ct];zt!==void 0&&(zt.update(X2.inputSource,X2.frame,t2||Y),zt.dispatchEvent({type:X2.type,data:X2.inputSource}))}function ht(){j.removeEventListener("select",T2),j.removeEventListener("selectstart",T2),j.removeEventListener("selectend",T2),j.removeEventListener("squeeze",T2),j.removeEventListener("squeezestart",T2),j.removeEventListener("squeezeend",T2),j.removeEventListener("end",ht),j.removeEventListener("inputsourceschange",St);for(let X2=0;X2=0&&(d2[Qt]=null,x2[Qt].disconnect(zt))}for(let ct=0;ct=d2.length){d2.push(zt),Qt=de;break}else if(d2[de]===null){d2[de]=zt,Qt=de;break}if(Qt===-1)break}const Kt=x2[Qt];Kt&&Kt.connect(zt)}}const q2=new L2,tt=new L2;function it(X2,ct,zt){q2.setFromMatrixPosition(ct.matrixWorld),tt.setFromMatrixPosition(zt.matrixWorld);const Qt=q2.distanceTo(tt),Kt=ct.projectionMatrix.elements,de=zt.projectionMatrix.elements,Be=Kt[14]/(Kt[10]-1),me=Kt[14]/(Kt[10]+1),h0=(Kt[9]+1)/Kt[5],Dn=(Kt[9]-1)/Kt[5],We=(Kt[8]-1)/Kt[0],Y2=(de[8]+1)/de[0],Pn=Be*We,Ce=Be*Y2,Re=Qt/(-We+Y2),Me=Re*-We;ct.matrixWorld.decompose(X2.position,X2.quaternion,X2.scale),X2.translateX(Me),X2.translateZ(Re),X2.matrixWorld.compose(X2.position,X2.quaternion,X2.scale),X2.matrixWorldInverse.copy(X2.matrixWorld).invert();const p0=Be+Re,He=me+Re,be=Pn-Me,v0=Ce+(Qt-Me),pn=h0*me/He*p0,In=Dn*me/He*p0;X2.projectionMatrix.makePerspective(be,v0,pn,In,p0,He),X2.projectionMatrixInverse.copy(X2.projectionMatrix).invert()}function Ct(X2,ct){ct===null?X2.matrixWorld.copy(X2.matrix):X2.matrixWorld.multiplyMatrices(ct.matrixWorld,X2.matrix),X2.matrixWorldInverse.copy(X2.matrixWorld).invert()}this.updateCamera=function(X2){if(j===null)return;j2.near=b2.near=P2.near=X2.near,j2.far=b2.far=P2.far=X2.far,(J2!==j2.near||B2!==j2.far)&&(j.updateRenderState({depthNear:j2.near,depthFar:j2.far}),J2=j2.near,B2=j2.far);const ct=X2.parent,zt=j2.cameras;Ct(j2,ct);for(let Qt=0;Qt0&&(p2.alphaTest.value=o2.alphaTest);const x2=g.get(o2).envMap;if(x2&&(p2.envMap.value=x2,p2.flipEnvMap.value=x2.isCubeTexture&&x2.isRenderTargetTexture===!1?-1:1,p2.reflectivity.value=o2.reflectivity,p2.ior.value=o2.ior,p2.refractionRatio.value=o2.refractionRatio),o2.lightMap){p2.lightMap.value=o2.lightMap;const d2=F._useLegacyLights===!0?Math.PI:1;p2.lightMapIntensity.value=o2.lightMapIntensity*d2,S(o2.lightMap,p2.lightMapTransform)}o2.aoMap&&(p2.aoMap.value=o2.aoMap,p2.aoMapIntensity.value=o2.aoMapIntensity,S(o2.aoMap,p2.aoMapTransform))}function Y(p2,o2){p2.diffuse.value.copy(o2.color),p2.opacity.value=o2.opacity,o2.map&&(p2.map.value=o2.map,S(o2.map,p2.mapTransform))}function X(p2,o2){p2.dashSize.value=o2.dashSize,p2.totalSize.value=o2.dashSize+o2.gapSize,p2.scale.value=o2.scale}function $(p2,o2,x2,d2){p2.diffuse.value.copy(o2.color),p2.opacity.value=o2.opacity,p2.size.value=o2.size*x2,p2.scale.value=d2*.5,o2.map&&(p2.map.value=o2.map,S(o2.map,p2.uvTransform)),o2.alphaMap&&(p2.alphaMap.value=o2.alphaMap,S(o2.alphaMap,p2.alphaMapTransform)),o2.alphaTest>0&&(p2.alphaTest.value=o2.alphaTest)}function t2(p2,o2){p2.diffuse.value.copy(o2.color),p2.opacity.value=o2.opacity,p2.rotation.value=o2.rotation,o2.map&&(p2.map.value=o2.map,S(o2.map,p2.mapTransform)),o2.alphaMap&&(p2.alphaMap.value=o2.alphaMap,S(o2.alphaMap,p2.alphaMapTransform)),o2.alphaTest>0&&(p2.alphaTest.value=o2.alphaTest)}function n2(p2,o2){p2.specular.value.copy(o2.specular),p2.shininess.value=Math.max(o2.shininess,1e-4)}function s2(p2,o2){o2.gradientMap&&(p2.gradientMap.value=o2.gradientMap)}function m(p2,o2){p2.metalness.value=o2.metalness,o2.metalnessMap&&(p2.metalnessMap.value=o2.metalnessMap,S(o2.metalnessMap,p2.metalnessMapTransform)),p2.roughness.value=o2.roughness,o2.roughnessMap&&(p2.roughnessMap.value=o2.roughnessMap,S(o2.roughnessMap,p2.roughnessMapTransform)),g.get(o2).envMap&&(p2.envMapIntensity.value=o2.envMapIntensity)}function f2(p2,o2,x2){p2.ior.value=o2.ior,o2.sheen>0&&(p2.sheenColor.value.copy(o2.sheenColor).multiplyScalar(o2.sheen),p2.sheenRoughness.value=o2.sheenRoughness,o2.sheenColorMap&&(p2.sheenColorMap.value=o2.sheenColorMap,S(o2.sheenColorMap,p2.sheenColorMapTransform)),o2.sheenRoughnessMap&&(p2.sheenRoughnessMap.value=o2.sheenRoughnessMap,S(o2.sheenRoughnessMap,p2.sheenRoughnessMapTransform))),o2.clearcoat>0&&(p2.clearcoat.value=o2.clearcoat,p2.clearcoatRoughness.value=o2.clearcoatRoughness,o2.clearcoatMap&&(p2.clearcoatMap.value=o2.clearcoatMap,S(o2.clearcoatMap,p2.clearcoatMapTransform)),o2.clearcoatRoughnessMap&&(p2.clearcoatRoughnessMap.value=o2.clearcoatRoughnessMap,S(o2.clearcoatRoughnessMap,p2.clearcoatRoughnessMapTransform)),o2.clearcoatNormalMap&&(p2.clearcoatNormalMap.value=o2.clearcoatNormalMap,S(o2.clearcoatNormalMap,p2.clearcoatNormalMapTransform),p2.clearcoatNormalScale.value.copy(o2.clearcoatNormalScale),o2.side===Oi&&p2.clearcoatNormalScale.value.negate())),o2.iridescence>0&&(p2.iridescence.value=o2.iridescence,p2.iridescenceIOR.value=o2.iridescenceIOR,p2.iridescenceThicknessMinimum.value=o2.iridescenceThicknessRange[0],p2.iridescenceThicknessMaximum.value=o2.iridescenceThicknessRange[1],o2.iridescenceMap&&(p2.iridescenceMap.value=o2.iridescenceMap,S(o2.iridescenceMap,p2.iridescenceMapTransform)),o2.iridescenceThicknessMap&&(p2.iridescenceThicknessMap.value=o2.iridescenceThicknessMap,S(o2.iridescenceThicknessMap,p2.iridescenceThicknessMapTransform))),o2.transmission>0&&(p2.transmission.value=o2.transmission,p2.transmissionSamplerMap.value=x2.texture,p2.transmissionSamplerSize.value.set(x2.width,x2.height),o2.transmissionMap&&(p2.transmissionMap.value=o2.transmissionMap,S(o2.transmissionMap,p2.transmissionMapTransform)),p2.thickness.value=o2.thickness,o2.thicknessMap&&(p2.thicknessMap.value=o2.thicknessMap,S(o2.thicknessMap,p2.thicknessMapTransform)),p2.attenuationDistance.value=o2.attenuationDistance,p2.attenuationColor.value.copy(o2.attenuationColor)),o2.anisotropy>0&&(p2.anisotropyVector.value.set(o2.anisotropy*Math.cos(o2.anisotropyRotation),o2.anisotropy*Math.sin(o2.anisotropyRotation)),o2.anisotropyMap&&(p2.anisotropyMap.value=o2.anisotropyMap,S(o2.anisotropyMap,p2.anisotropyMapTransform))),p2.specularIntensity.value=o2.specularIntensity,p2.specularColor.value.copy(o2.specularColor),o2.specularColorMap&&(p2.specularColorMap.value=o2.specularColorMap,S(o2.specularColorMap,p2.specularColorMapTransform)),o2.specularIntensityMap&&(p2.specularIntensityMap.value=o2.specularIntensityMap,S(o2.specularIntensityMap,p2.specularIntensityMapTransform))}function a2(p2,o2){o2.matcap&&(p2.matcap.value=o2.matcap)}function A2(p2,o2){const x2=g.get(o2).light;p2.referencePosition.value.setFromMatrixPosition(x2.matrixWorld),p2.nearDistance.value=x2.shadow.camera.near,p2.farDistance.value=x2.shadow.camera.far}return{refreshFogUniforms:D,refreshMaterialUniforms:j}}function P82(F,g,S,D){let j={},U={},Y=[];const X=S.isWebGL2?F.getParameter(F.MAX_UNIFORM_BUFFER_BINDINGS):0;function $(x2,d2){const P2=d2.program;D.uniformBlockBinding(x2,P2)}function t2(x2,d2){let P2=j[x2.id];P2===void 0&&(a2(x2),P2=n2(x2),j[x2.id]=P2,x2.addEventListener("dispose",p2));const b2=d2.program;D.updateUBOMapping(x2,b2);const F2=g.render.frame;U[x2.id]!==F2&&(m(x2),U[x2.id]=F2)}function n2(x2){const d2=s2();x2.__bindingPointIndex=d2;const P2=F.createBuffer(),b2=x2.__size,F2=x2.usage;return F.bindBuffer(F.UNIFORM_BUFFER,P2),F.bufferData(F.UNIFORM_BUFFER,b2,F2),F.bindBuffer(F.UNIFORM_BUFFER,null),F.bindBufferBase(F.UNIFORM_BUFFER,d2,P2),P2}function s2(){for(let x2=0;x20){F2=P2%b2;const St=b2-F2;F2!==0&&St-T2.boundary<0&&(P2+=b2-F2,B2.__offset=P2)}P2+=T2.storage}return F2=P2%b2,F2>0&&(P2+=b2-F2),x2.__size=P2,x2.__cache={},this}function A2(x2){const d2={boundary:0,storage:0};return typeof x2=="number"?(d2.boundary=4,d2.storage=4):x2.isVector2?(d2.boundary=8,d2.storage=8):x2.isVector3||x2.isColor?(d2.boundary=16,d2.storage=12):x2.isVector4?(d2.boundary=16,d2.storage=16):x2.isMatrix3?(d2.boundary=48,d2.storage=48):x2.isMatrix4?(d2.boundary=64,d2.storage=64):x2.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x2),d2}function p2(x2){const d2=x2.target;d2.removeEventListener("dispose",p2);const P2=Y.indexOf(d2.__bindingPointIndex);Y.splice(P2,1),F.deleteBuffer(j[d2.id]),delete j[d2.id],delete U[d2.id]}function o2(){for(const x2 in j)F.deleteBuffer(j[x2]);Y=[],j={},U={}}return{bind:$,update:t2,dispose:o2}}function I82(){const F=Gu("canvas");return F.style.display="block",F}class vH{constructor(g={}){const{canvas:S=I82(),context:D=null,depth:j=!0,stencil:U=!0,alpha:Y=!1,antialias:X=!1,premultipliedAlpha:$=!0,preserveDrawingBuffer:t2=!1,powerPreference:n2="default",failIfMajorPerformanceCaveat:s2=!1}=g;this.isWebGLRenderer=!0;let m;D!==null?m=D.getContextAttributes().alpha:m=Y;const f2=new Uint32Array(4),a2=new Int32Array(4);let A2=null,p2=null;const o2=[],x2=[];this.domElement=S,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputColorSpace=qe,this._useLegacyLights=!1,this.toneMapping=R1,this.toneMappingExposure=1;const d2=this;let P2=!1,b2=0,F2=0,j2=null,J2=-1,B2=null;const T2=new Gn,ht=new Gn;let St=null;const q2=new f0(0);let tt=0,it=S.width,Ct=S.height,_t=1,mt=null,vt=null;const Bt=new Gn(0,0,it,Ct),X2=new Gn(0,0,it,Ct);let ct=!1;const zt=new P6;let Qt=!1,Kt=!1,de=null;const Be=new fn,me=new _e,h0=new L2,Dn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function We(){return j2===null?_t:1}let Y2=D;function Pn(C2,Q2){for(let ot=0;ot0?p2=x2[x2.length-1]:p2=null,o2.pop(),o2.length>0?A2=o2[o2.length-1]:A2=null};function B4(C2,Q2,ot,z2){if(C2.visible===!1)return;if(C2.layers.test(Q2.layers)){if(C2.isGroup)ot=C2.renderOrder;else if(C2.isLOD)C2.autoUpdate===!0&&C2.update(Q2);else if(C2.isLight)p2.pushLight(C2),C2.castShadow&&p2.pushShadow(C2);else if(C2.isSprite){if(!C2.frustumCulled||zt.intersectsSprite(C2)){z2&&h0.setFromMatrixPosition(C2.matrixWorld).applyMatrix4(Be);const ke=g2.update(C2),De=C2.material;De.visible&&A2.push(C2,ke,De,ot,h0.z,null)}}else if((C2.isMesh||C2.isLine||C2.isPoints)&&(!C2.frustumCulled||zt.intersectsObject(C2))){const ke=g2.update(C2),De=C2.material;if(z2&&(C2.boundingSphere!==void 0?(C2.boundingSphere===null&&C2.computeBoundingSphere(),h0.copy(C2.boundingSphere.center)):(ke.boundingSphere===null&&ke.computeBoundingSphere(),h0.copy(ke.boundingSphere.center)),h0.applyMatrix4(C2.matrixWorld).applyMatrix4(Be)),Array.isArray(De)){const Pe=ke.groups;for(let Ve=0,Ee=Pe.length;Ve0&&Qu(rt,te,Q2,ot),z2&&Me.viewport(T2.copy(z2)),rt.length>0&&I1(rt,Q2,ot),te.length>0&&I1(te,Q2,ot),ke.length>0&&I1(ke,Q2,ot),Me.buffers.depth.setTest(!0),Me.buffers.depth.setMask(!0),Me.buffers.color.setMask(!0),Me.setPolygonOffset(!1)}function Qu(C2,Q2,ot,z2){const rt=Re.isWebGL2;de===null&&(de=new us(1,1,{generateMipmaps:!0,type:Ce.has("EXT_color_buffer_half_float")?Ou:D1,minFilter:ju,samples:rt?4:0})),d2.getDrawingBufferSize(me),rt?de.setSize(me.x,me.y):de.setSize(w6(me.x),w6(me.y));const te=d2.getRenderTarget();d2.setRenderTarget(de),d2.getClearColor(q2),tt=d2.getClearAlpha(),tt<1&&d2.setClearColor(16777215,.5),d2.clear();const ke=d2.toneMapping;d2.toneMapping=R1,I1(C2,ot,z2),be.updateMultisampleRenderTarget(de),be.updateRenderTargetMipmap(de);let De=!1;for(let Pe=0,Ve=Q2.length;Pe0),Oe=!!ot.morphAttributes.position,L0=!!ot.morphAttributes.normal,U0=!!ot.morphAttributes.color;let li=R1;z2.toneMapped&&(j2===null||j2.isXRRenderTarget===!0)&&(li=d2.toneMapping);const or=ot.morphAttributes.position||ot.morphAttributes.normal||ot.morphAttributes.color,z0=or!==void 0?or.length:0,Ze=He.get(z2),ps=p2.state.lights;if(Qt===!0&&(Kt===!0||C2!==B2)){const Jn=C2===B2&&z2.id===J2;le.setState(z2,C2,Jn)}let V0=!1;z2.version===Ze.__version?(Ze.needsLights&&Ze.lightsStateVersion!==ps.state.version||Ze.outputColorSpace!==De||rt.isInstancedMesh&&Ze.instancing===!1||!rt.isInstancedMesh&&Ze.instancing===!0||rt.isSkinnedMesh&&Ze.skinning===!1||!rt.isSkinnedMesh&&Ze.skinning===!0||rt.isInstancedMesh&&Ze.instancingColor===!0&&rt.instanceColor===null||rt.isInstancedMesh&&Ze.instancingColor===!1&&rt.instanceColor!==null||Ze.envMap!==Pe||z2.fog===!0&&Ze.fog!==te||Ze.numClippingPlanes!==void 0&&(Ze.numClippingPlanes!==le.numPlanes||Ze.numIntersection!==le.numIntersection)||Ze.vertexAlphas!==Ve||Ze.vertexTangents!==Ee||Ze.morphTargets!==Oe||Ze.morphNormals!==L0||Ze.morphColors!==U0||Ze.toneMapping!==li||Re.isWebGL2===!0&&Ze.morphTargetsCount!==z0)&&(V0=!0):(V0=!0,Ze.__version=z2.version);let Jr=Ze.currentProgram;V0===!0&&(Jr=b1(z2,Q2,rt));let x4=!1,Jo=!1,_s=!1;const Fn=Jr.getUniforms(),Kr=Ze.uniforms;if(Me.useProgram(Jr.program)&&(x4=!0,Jo=!0,_s=!0),z2.id!==J2&&(J2=z2.id,Jo=!0),x4||B2!==C2){if(Fn.setValue(Y2,"projectionMatrix",C2.projectionMatrix),Re.logarithmicDepthBuffer&&Fn.setValue(Y2,"logDepthBufFC",2/(Math.log(C2.far+1)/Math.LN2)),B2!==C2&&(B2=C2,Jo=!0,_s=!0),z2.isShaderMaterial||z2.isMeshPhongMaterial||z2.isMeshToonMaterial||z2.isMeshStandardMaterial||z2.envMap){const Jn=Fn.map.cameraPosition;Jn!==void 0&&Jn.setValue(Y2,h0.setFromMatrixPosition(C2.matrixWorld))}(z2.isMeshPhongMaterial||z2.isMeshToonMaterial||z2.isMeshLambertMaterial||z2.isMeshBasicMaterial||z2.isMeshStandardMaterial||z2.isShaderMaterial)&&Fn.setValue(Y2,"isOrthographic",C2.isOrthographicCamera===!0),(z2.isMeshPhongMaterial||z2.isMeshToonMaterial||z2.isMeshLambertMaterial||z2.isMeshBasicMaterial||z2.isMeshStandardMaterial||z2.isShaderMaterial||z2.isShadowMaterial||rt.isSkinnedMesh)&&Fn.setValue(Y2,"viewMatrix",C2.matrixWorldInverse)}if(rt.isSkinnedMesh){Fn.setOptional(Y2,rt,"bindMatrix"),Fn.setOptional(Y2,rt,"bindMatrixInverse");const Jn=rt.skeleton;Jn&&(Re.floatVertexTextures?(Jn.boneTexture===null&&Jn.computeBoneTexture(),Fn.setValue(Y2,"boneTexture",Jn.boneTexture,be),Fn.setValue(Y2,"boneTextureSize",Jn.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}const cs=ot.morphAttributes;if((cs.position!==void 0||cs.normal!==void 0||cs.color!==void 0&&Re.isWebGL2===!0)&&ge.update(rt,ot,Jr),(Jo||Ze.receiveShadow!==rt.receiveShadow)&&(Ze.receiveShadow=rt.receiveShadow,Fn.setValue(Y2,"receiveShadow",rt.receiveShadow)),z2.isMeshGouraudMaterial&&z2.envMap!==null&&(Kr.envMap.value=Pe,Kr.flipEnvMap.value=Pe.isCubeTexture&&Pe.isRenderTargetTexture===!1?-1:1),Jo&&(Fn.setValue(Y2,"toneMappingExposure",d2.toneMappingExposure),Ze.needsLights&&Xu(Kr,_s),te&&z2.fog===!0&&Dt.refreshFogUniforms(Kr,te),Dt.refreshMaterialUniforms(Kr,z2,_t,Ct,de),up.upload(Y2,Ze.uniformsList,Kr,be)),z2.isShaderMaterial&&z2.uniformsNeedUpdate===!0&&(up.upload(Y2,Ze.uniformsList,Kr,be),z2.uniformsNeedUpdate=!1),z2.isSpriteMaterial&&Fn.setValue(Y2,"center",rt.center),Fn.setValue(Y2,"modelViewMatrix",rt.modelViewMatrix),Fn.setValue(Y2,"normalMatrix",rt.normalMatrix),Fn.setValue(Y2,"modelMatrix",rt.matrixWorld),z2.isShaderMaterial||z2.isRawShaderMaterial){const Jn=z2.uniformsGroups;for(let hs=0,Zu=Jn.length;hs0&&be.useMultisampledRTT(C2)===!1?rt=He.get(C2).__webglMultisampledFramebuffer:Array.isArray(Ee)?rt=Ee[ot]:rt=Ee,T2.copy(C2.viewport),ht.copy(C2.scissor),St=C2.scissorTest}else T2.copy(Bt).multiplyScalar(_t).floor(),ht.copy(X2).multiplyScalar(_t).floor(),St=ct;if(Me.bindFramebuffer(Y2.FRAMEBUFFER,rt)&&Re.drawBuffers&&z2&&Me.drawBuffers(C2,rt),Me.viewport(T2),Me.scissor(ht),Me.setScissorTest(St),te){const Pe=He.get(C2.texture);Y2.framebufferTexture2D(Y2.FRAMEBUFFER,Y2.COLOR_ATTACHMENT0,Y2.TEXTURE_CUBE_MAP_POSITIVE_X+Q2,Pe.__webglTexture,ot)}else if(ke){const Pe=He.get(C2.texture),Ve=Q2||0;Y2.framebufferTextureLayer(Y2.FRAMEBUFFER,Y2.COLOR_ATTACHMENT0,Pe.__webglTexture,ot||0,Ve)}J2=-1},this.readRenderTargetPixels=function(C2,Q2,ot,z2,rt,te,ke){if(!(C2&&C2.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let De=He.get(C2).__webglFramebuffer;if(C2.isWebGLCubeRenderTarget&&ke!==void 0&&(De=De[ke]),De){Me.bindFramebuffer(Y2.FRAMEBUFFER,De);try{const Pe=C2.texture,Ve=Pe.format,Ee=Pe.type;if(Ve!==Zr&&oe.convert(Ve)!==Y2.getParameter(Y2.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const Oe=Ee===Ou&&(Ce.has("EXT_color_buffer_half_float")||Re.isWebGL2&&Ce.has("EXT_color_buffer_float"));if(Ee!==D1&&oe.convert(Ee)!==Y2.getParameter(Y2.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Ee===E1&&(Re.isWebGL2||Ce.has("OES_texture_float")||Ce.has("WEBGL_color_buffer_float")))&&!Oe){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Q2>=0&&Q2<=C2.width-z2&&ot>=0&&ot<=C2.height-rt&&Y2.readPixels(Q2,ot,z2,rt,oe.convert(Ve),oe.convert(Ee),te)}finally{const Pe=j2!==null?He.get(j2).__webglFramebuffer:null;Me.bindFramebuffer(Y2.FRAMEBUFFER,Pe)}}},this.copyFramebufferToTexture=function(C2,Q2,ot=0){const z2=Math.pow(2,-ot),rt=Math.floor(Q2.image.width*z2),te=Math.floor(Q2.image.height*z2);be.setTexture2D(Q2,0),Y2.copyTexSubImage2D(Y2.TEXTURE_2D,ot,0,0,C2.x,C2.y,rt,te),Me.unbindTexture()},this.copyTextureToTexture=function(C2,Q2,ot,z2=0){const rt=Q2.image.width,te=Q2.image.height,ke=oe.convert(ot.format),De=oe.convert(ot.type);be.setTexture2D(ot,0),Y2.pixelStorei(Y2.UNPACK_FLIP_Y_WEBGL,ot.flipY),Y2.pixelStorei(Y2.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ot.premultiplyAlpha),Y2.pixelStorei(Y2.UNPACK_ALIGNMENT,ot.unpackAlignment),Q2.isDataTexture?Y2.texSubImage2D(Y2.TEXTURE_2D,z2,C2.x,C2.y,rt,te,ke,De,Q2.image.data):Q2.isCompressedTexture?Y2.compressedTexSubImage2D(Y2.TEXTURE_2D,z2,C2.x,C2.y,Q2.mipmaps[0].width,Q2.mipmaps[0].height,ke,Q2.mipmaps[0].data):Y2.texSubImage2D(Y2.TEXTURE_2D,z2,C2.x,C2.y,ke,De,Q2.image),z2===0&&ot.generateMipmaps&&Y2.generateMipmap(Y2.TEXTURE_2D),Me.unbindTexture()},this.copyTextureToTexture3D=function(C2,Q2,ot,z2,rt=0){if(d2.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const te=C2.max.x-C2.min.x+1,ke=C2.max.y-C2.min.y+1,De=C2.max.z-C2.min.z+1,Pe=oe.convert(z2.format),Ve=oe.convert(z2.type);let Ee;if(z2.isData3DTexture)be.setTexture3D(z2,0),Ee=Y2.TEXTURE_3D;else if(z2.isDataArrayTexture)be.setTexture2DArray(z2,0),Ee=Y2.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}Y2.pixelStorei(Y2.UNPACK_FLIP_Y_WEBGL,z2.flipY),Y2.pixelStorei(Y2.UNPACK_PREMULTIPLY_ALPHA_WEBGL,z2.premultiplyAlpha),Y2.pixelStorei(Y2.UNPACK_ALIGNMENT,z2.unpackAlignment);const Oe=Y2.getParameter(Y2.UNPACK_ROW_LENGTH),L0=Y2.getParameter(Y2.UNPACK_IMAGE_HEIGHT),U0=Y2.getParameter(Y2.UNPACK_SKIP_PIXELS),li=Y2.getParameter(Y2.UNPACK_SKIP_ROWS),or=Y2.getParameter(Y2.UNPACK_SKIP_IMAGES),z0=ot.isCompressedTexture?ot.mipmaps[0]:ot.image;Y2.pixelStorei(Y2.UNPACK_ROW_LENGTH,z0.width),Y2.pixelStorei(Y2.UNPACK_IMAGE_HEIGHT,z0.height),Y2.pixelStorei(Y2.UNPACK_SKIP_PIXELS,C2.min.x),Y2.pixelStorei(Y2.UNPACK_SKIP_ROWS,C2.min.y),Y2.pixelStorei(Y2.UNPACK_SKIP_IMAGES,C2.min.z),ot.isDataTexture||ot.isData3DTexture?Y2.texSubImage3D(Ee,rt,Q2.x,Q2.y,Q2.z,te,ke,De,Pe,Ve,z0.data):ot.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Y2.compressedTexSubImage3D(Ee,rt,Q2.x,Q2.y,Q2.z,te,ke,De,Pe,z0.data)):Y2.texSubImage3D(Ee,rt,Q2.x,Q2.y,Q2.z,te,ke,De,Pe,Ve,z0),Y2.pixelStorei(Y2.UNPACK_ROW_LENGTH,Oe),Y2.pixelStorei(Y2.UNPACK_IMAGE_HEIGHT,L0),Y2.pixelStorei(Y2.UNPACK_SKIP_PIXELS,U0),Y2.pixelStorei(Y2.UNPACK_SKIP_ROWS,li),Y2.pixelStorei(Y2.UNPACK_SKIP_IMAGES,or),rt===0&&z2.generateMipmaps&&Y2.generateMipmap(Ee),Me.unbindTexture()},this.initTexture=function(C2){C2.isCubeTexture?be.setTextureCube(C2,0):C2.isData3DTexture?be.setTexture3D(C2,0):C2.isDataArrayTexture||C2.isCompressedArrayTexture?be.setTexture2DArray(C2,0):be.setTexture2D(C2,0),Me.unbindTexture()},this.resetState=function(){b2=0,F2=0,j2=null,Me.reset(),se.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Zo}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(g){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!g}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===qe?os:eH}set outputEncoding(g){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=g===os?qe:go}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(g){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=g}}class b82 extends vH{}b82.prototype.isWebGL1Renderer=!0;class F82 extends Zn{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(g,S){return super.copy(g,S),g.background!==null&&(this.background=g.background.clone()),g.environment!==null&&(this.environment=g.environment.clone()),g.fog!==null&&(this.fog=g.fog.clone()),this.backgroundBlurriness=g.backgroundBlurriness,this.backgroundIntensity=g.backgroundIntensity,g.overrideMaterial!==null&&(this.overrideMaterial=g.overrideMaterial.clone()),this.matrixAutoUpdate=g.matrixAutoUpdate,this}toJSON(g){const S=super.toJSON(g);return this.fog!==null&&(S.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(S.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(S.object.backgroundIntensity=this.backgroundIntensity),S}}class BH extends fs{constructor(g){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new f0(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(g)}copy(g){return super.copy(g),this.color.copy(g.color),this.map=g.map,this.linewidth=g.linewidth,this.linecap=g.linecap,this.linejoin=g.linejoin,this.fog=g.fog,this}}const gW=new L2,kW=new L2,vW=new fn,_6=new uH,ip=new _p;class L82 extends Zn{constructor(g=new xr,S=new BH){super(),this.isLine=!0,this.type="Line",this.geometry=g,this.material=S,this.updateMorphTargets()}copy(g,S){return super.copy(g,S),this.material=g.material,this.geometry=g.geometry,this}computeLineDistances(){const g=this.geometry;if(g.index===null){const S=g.attributes.position,D=[0];for(let j=1,U=S.count;j$)continue;m.applyMatrix4(this.matrixWorld);const J2=g.ray.origin.distanceTo(m);J2g.far||S.push({distance:J2,point:s2.clone().applyMatrix4(this.matrixWorld),index:d2,face:null,faceIndex:null,object:this})}}else{const o2=Math.max(0,Y.start),x2=Math.min(p2.count,Y.start+Y.count);for(let d2=o2,P2=x2-1;d2$)continue;m.applyMatrix4(this.matrixWorld);const F2=g.ray.origin.distanceTo(m);F2g.far||S.push({distance:F2,point:s2.clone().applyMatrix4(this.matrixWorld),index:d2,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const S=this.geometry.morphAttributes,D=Object.keys(S);if(D.length>0){const j=S[D[0]];if(j!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let U=0,Y=j.length;U0)$=j-1;else{$=j;break}if(j=$,D[j]===Y)return j/(U-1);const n2=D[j],m=D[j+1]-n2,f2=(Y-n2)/m;return(j+f2)/(U-1)}getTangent(g,S){let j=g-1e-4,U=g+1e-4;j<0&&(j=0),U>1&&(U=1);const Y=this.getPoint(j),X=this.getPoint(U),$=S||(Y.isVector2?new _e:new L2);return $.copy(X).sub(Y).normalize(),$}getTangentAt(g,S){const D=this.getUtoTmapping(g);return this.getTangent(D,S)}computeFrenetFrames(g,S){const D=new L2,j=[],U=[],Y=[],X=new L2,$=new fn;for(let f2=0;f2<=g;f2++){const a2=f2/g;j[f2]=this.getTangentAt(a2,new L2)}U[0]=new L2,Y[0]=new L2;let t2=Number.MAX_VALUE;const n2=Math.abs(j[0].x),s2=Math.abs(j[0].y),m=Math.abs(j[0].z);n2<=t2&&(t2=n2,D.set(1,0,0)),s2<=t2&&(t2=s2,D.set(0,1,0)),m<=t2&&D.set(0,0,1),X.crossVectors(j[0],D).normalize(),U[0].crossVectors(j[0],X),Y[0].crossVectors(j[0],U[0]);for(let f2=1;f2<=g;f2++){if(U[f2]=U[f2-1].clone(),Y[f2]=Y[f2-1].clone(),X.crossVectors(j[f2-1],j[f2]),X.length()>Number.EPSILON){X.normalize();const a2=Math.acos(qn(j[f2-1].dot(j[f2]),-1,1));U[f2].applyMatrix4($.makeRotationAxis(X,a2))}Y[f2].crossVectors(j[f2],U[f2])}if(S===!0){let f2=Math.acos(qn(U[0].dot(U[g]),-1,1));f2/=g,j[0].dot(X.crossVectors(U[0],U[g]))>0&&(f2=-f2);for(let a2=1;a2<=g;a2++)U[a2].applyMatrix4($.makeRotationAxis(j[a2],f2*a2)),Y[a2].crossVectors(j[a2],U[a2])}return{tangents:j,normals:U,binormals:Y}}clone(){return new this.constructor().copy(this)}copy(g){return this.arcLengthDivisions=g.arcLengthDivisions,this}toJSON(){const g={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return g.arcLengthDivisions=this.arcLengthDivisions,g.type=this.type,g}fromJSON(g){return this.arcLengthDivisions=g.arcLengthDivisions,this}}class b6 extends ko{constructor(g=0,S=0,D=1,j=1,U=0,Y=Math.PI*2,X=!1,$=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=g,this.aY=S,this.xRadius=D,this.yRadius=j,this.aStartAngle=U,this.aEndAngle=Y,this.aClockwise=X,this.aRotation=$}getPoint(g,S){const D=S||new _e,j=Math.PI*2;let U=this.aEndAngle-this.aStartAngle;const Y=Math.abs(U)j;)U-=j;U0?0:(Math.floor(Math.abs(X)/U)+1)*U:$===0&&X===U-1&&(X=U-2,$=1);let t2,n2;this.closed||X>0?t2=j[(X-1)%U]:(rp.subVectors(j[0],j[1]).add(j[0]),t2=rp);const s2=j[X%U],m=j[(X+1)%U];if(this.closed||X+2j.length-2?j.length-1:Y+1],s2=j[Y>j.length-3?j.length-1:Y+2];return D.set(CW(X,$.x,t2.x,n2.x,s2.x),CW(X,$.y,t2.y,n2.y,s2.y)),D}copy(g){super.copy(g),this.points=[];for(let S=0,D=g.points.length;S=D){const Y=j[U]-D,X=this.curves[U],$=X.getLength(),t2=$===0?0:1-Y/$;return X.getPointAt(t2,S)}U++}return null}getLength(){const g=this.getCurveLengths();return g[g.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const g=[];let S=0;for(let D=0,j=this.curves.length;D1&&!S[S.length-1].equals(S[0])&&S.push(S[0]),S}copy(g){super.copy(g),this.curves=[];for(let S=0,D=g.curves.length;S0){const s2=t2.getPoint(0);s2.equals(this.currentPoint)||this.lineTo(s2.x,s2.y)}this.curves.push(t2);const n2=t2.getPoint(1);return this.currentPoint.copy(n2),this}copy(g){return super.copy(g),this.currentPoint.copy(g.currentPoint),this}toJSON(){const g=super.toJSON();return g.currentPoint=this.currentPoint.toArray(),g}fromJSON(g){return super.fromJSON(g),this.currentPoint.fromArray(g.currentPoint),this}}class j6 extends xr{constructor(g=[new _e(0,-.5),new _e(.5,0),new _e(0,.5)],S=12,D=0,j=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:g,segments:S,phiStart:D,phiLength:j},S=Math.floor(S),j=qn(j,0,Math.PI*2);const U=[],Y=[],X=[],$=[],t2=[],n2=1/S,s2=new L2,m=new _e,f2=new L2,a2=new L2,A2=new L2;let p2=0,o2=0;for(let x2=0;x2<=g.length-1;x2++)switch(x2){case 0:p2=g[x2+1].x-g[x2].x,o2=g[x2+1].y-g[x2].y,f2.x=o2*1,f2.y=-p2,f2.z=o2*0,A2.copy(f2),f2.normalize(),$.push(f2.x,f2.y,f2.z);break;case g.length-1:$.push(A2.x,A2.y,A2.z);break;default:p2=g[x2+1].x-g[x2].x,o2=g[x2+1].y-g[x2].y,f2.x=o2*1,f2.y=-p2,f2.z=o2*0,a2.copy(f2),f2.x+=A2.x,f2.y+=A2.y,f2.z+=A2.z,f2.normalize(),$.push(f2.x,f2.y,f2.z),A2.copy(a2)}for(let x2=0;x2<=S;x2++){const d2=D+x2*n2*j,P2=Math.sin(d2),b2=Math.cos(d2);for(let F2=0;F2<=g.length-1;F2++){s2.x=g[F2].x*P2,s2.y=g[F2].y,s2.z=g[F2].x*b2,Y.push(s2.x,s2.y,s2.z),m.x=x2/S,m.y=F2/(g.length-1),X.push(m.x,m.y);const j2=$[3*F2+0]*P2,J2=$[3*F2+1],B2=$[3*F2+0]*b2;t2.push(j2,J2,B2)}}for(let x2=0;x20&&d2(!0),S>0&&d2(!1)),this.setIndex(n2),this.setAttribute("position",new kn(s2,3)),this.setAttribute("normal",new kn(m,3)),this.setAttribute("uv",new kn(f2,2));function x2(){const P2=new L2,b2=new L2;let F2=0;const j2=(S-g)/D;for(let J2=0;J2<=U;J2++){const B2=[],T2=J2/U,ht=T2*(S-g)+g;for(let St=0;St<=j;St++){const q2=St/j,tt=q2*$+X,it=Math.sin(tt),Ct=Math.cos(tt);b2.x=ht*it,b2.y=-T2*D+p2,b2.z=ht*Ct,s2.push(b2.x,b2.y,b2.z),P2.set(it,j2,Ct).normalize(),m.push(P2.x,P2.y,P2.z),f2.push(q2,1-T2),B2.push(a2++)}A2.push(B2)}for(let J2=0;J20)&&f2.push(d2,P2,F2),(o2!==D-1||$"u"?Date:performance).now()}class RW extends j82{constructor(g=10,S=10,D=4473924,j=8947848){D=new f0(D),j=new f0(j);const U=S/2,Y=g/S,X=g/2,$=[],t2=[];for(let m=0,f2=0,a2=-X;m<=S;m++,a2+=Y){$.push(-X,0,a2,X,0,a2),$.push(a2,0,-X,a2,0,X);const A2=m===U?D:j;A2.toArray(t2,f2),f2+=3,A2.toArray(t2,f2),f2+=3,A2.toArray(t2,f2),f2+=3,A2.toArray(t2,f2),f2+=3}const n2=new xr;n2.setAttribute("position",new kn($,3)),n2.setAttribute("color",new kn(t2,3));const s2=new BH({vertexColors:!0,toneMapped:!1});super(n2,s2),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:E6}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=E6);const u62=.4,l62=2.5;class v4{constructor(g,S,D=1,j=1,U=.5,Y=16777215){wt(this,"position");wt(this,"size");wt(this,"mass");wt(this,"friction");wt(this,"color");wt(this,"id");wt(this,"scalingFactor",1);wt(this,"isPhysicsEnabled",!1);wt(this,"isDestructible",!1);wt(this,"mesh",new yi);wt(this,"rigidBody");this.position=g.clone(),this.size=D,this.mass=j,this.friction=U,this.color=Y,this.id=S}addPhysics(g){return this.isPhysicsEnabled?!1:(this.rigidBody=g,this.isPhysicsEnabled=!0,!0)}isAffectedByPhysics(){return this.isPhysicsEnabled}getFriction(){return this.friction}update(){!this.isAffectedByPhysics()||this.rigidBody===void 0||(M42(this.mesh,this.rigidBody),this.position.copy(this.mesh.position))}getRigidBody(){return this.rigidBody}setPosition(g){if(this.position.copy(g),this.mesh.position.copy(g),this.isAffectedByPhysics())throw"setPosition: objects with enabled physics cannot be repositioned"}getPosition(){return this.position.clone()}setColor(g){this.color=g,this.mesh.material.color.setHex(g)}getColor(){return this.color}getMesh(){return this.mesh}translateX(g){this.position.add(new L2(g,0,0)),this.mesh.translateX(g)}translateY(g){this.position.add(new L2(0,g,0)),this.mesh.translateY(g)}translateZ(g){this.position.add(new L2(0,0,g)),this.mesh.translateZ(g)}scale(g){this.scalingFactor+g>l62||this.scalingFactor+g(F[F.Box=0]="Box",F[F.HealthCheck=1]="HealthCheck",F[F.DeletetionRay=2]="DeletetionRay",F))(Uu||{});function m62(F){return(F+1)%(Object.keys(Uu).length/2)}function a62(F){return(F-1>=0?F-1:Object.keys(Uu).length/2-1)%(Object.keys(Uu).length/2)}function d6(F,g){const S=F.getPosition(),D=g.generateId();switch(F.getPayloadType()){case 0:{const j=new DW(S,D);return g.add(j),new LW(j)}case 1:{const j=new _4(S,D);return g.add(j),new A62(j)}case 2:{const j=new c4(F.getIndicatorPosition(),D,16711680,()=>g.getCameraPosition());return g.add(j),new d62(j)}default:{const j=new DW(S,D);return g.add(j),new LW(j)}}}class LW{constructor(g){wt(this,"payload");this.payload=g}activate(g){let S=zW(this.payload);this.payload.addPhysics(S),g.addPhysicsObject(S)}isPermanent(){return!0}getRepresentation(){return this.payload}}class A62{constructor(g){wt(this,"payload");this.payload=g}activate(g){g.startEarthquake(),g.remove(this.payload),this.payload.delete()}isPermanent(){return!1}getRepresentation(){return this.payload}}class d62{constructor(g){wt(this,"payload");this.payload=g}activate(g){let S=this.payload.getPosition();S.setY(-100);let D=g.rayHitObject(this.payload.getPosition(),S);D!==void 0&&D.getIsDestructible()&&(g.remove(D),D.delete()),g.remove(this.payload),this.payload.delete()}isPermanent(){return!1}getRepresentation(){return this.payload}}class W6{constructor(g,S){wt(this,"duration");wt(this,"startTime");wt(this,"remainingMs");wt(this,"isTimerRunning",!1);wt(this,"events",{});wt(this,"callbackFn");this.duration=g,this.remainingMs=g,this.startTime=new Date().getTime(),this.callbackFn=S}update(){this.isTimerRunning&&(this.remainingMs=this.remainingMs-(new Date().getTime()-this.startTime),Object.keys(this.events).forEach(g=>{let S=Number.parseInt(g);S{D(),S()}}else this.events[g]=S}getRemaining(){return this.remainingMs}getElapsed(){return this.duration-this.remainingMs}start(){this.startTime=new Date().getTime(),this.isTimerRunning=!0}isRunning(){return this.isTimerRunning}pause(){this.isTimerRunning=!1}}const $1=5,op=10,ji=class ji extends v4{constructor(S,D,j,U){super(S,U,2*$1,0,0,D);wt(this,"rayEnvironment");wt(this,"currentScore",0);wt(this,"material");wt(this,"heightScaling",1);this.rayEnvironment=j,this.material=new Vu({color:D,transparent:!0,opacity:.7,side:D42,alphaMap:ji.alpha}),this.mesh=new yi(ji.geometry,this.material),this.mesh.castShadow=!0,this.mesh.receiveShadow=!0,this.mesh.position.copy(this.position)}static init(){ji.geometry=new G6($1,$1,op,32,32,!0),ji.alpha=new Fu().load("area.png"),ji.alpha.magFilter=gn,ji.alpha.wrapS=Qr,ji.alpha.repeat.y=1,ji.alpha.repeat.x=3}delete(){this.material.dispose()}static cleanUp(){ji.geometry.dispose(),ji.alpha.dispose()}isAffectedByPhysics(){return!1}static staticUpdate(){}update(){this.heightScaling=Math.sin(new Date().getTime()*.001)*.3+1,this.mesh.position.set(this.position.x,this.position.y+op*this.heightScaling/2,this.position.z),this.mesh.scale.set(1,this.heightScaling,1);const S=1e3;let D=[$1,0,-$1],j=[];for(let Y=0;YY>=0&&Y<=S));U<0||U>S?this.currentScore=0:this.currentScore=S-U}setPosition(S){this.position.copy(S),this.mesh.position.set(this.position.x,this.position.y+op*this.heightScaling/2,this.position.z)}addPhysics(){return!1}getAabb(){return new L2($1*2,op,$1*2)}getHighscore(){return Math.round(this.currentScore)}getIsDestructible(){return!1}};wt(ji,"geometry"),wt(ji,"alpha");let Lu=ji;const y62=.005;class g62{constructor(g,S,D){wt(this,"startPosition");wt(this,"endPosition");wt(this,"timer");wt(this,"durationMs");wt(this,"current",new L2);this.startPosition=g,this.endPosition=S,this.durationMs=D,this.timer=new W6(D,()=>{})}start(){this.timer.start()}pause(){this.timer.pause()}isRunning(){return this.timer.isRunning()}getPosition(){return this.timer.update(),this.current.lerpVectors(this.startPosition,this.endPosition,this.timer.getElapsed()/this.durationMs),this.current.clone()}translate(g){this.startPosition.add(g),this.endPosition.add(g)}isTowards(g){return this.endPosition.distanceTo(g){const X=Y.getRepresentation();X.scale(S),X.isAffectedByPhysics()&&D(X.getRigidBody())}),(j=this.payload)==null||j.getRepresentation().scale(S),(U=this.payload)!=null&&U.getRepresentation().isAffectedByPhysics()&&D(this.payload.getRepresentation().getRigidBody())}translateX(S){var D;this.position.x+S>S62||this.position.x+Sw62||this.position.z+Sthis.stop()),this.ui=D(this.timer,()=>Object.values(this.highscores),E62,T62),this.playerConstructor=g,_4.init(),c4.init(),Lu.init(),Nu.init()}triggerHealtCheck(){this.world.startEarthquake(),this.ui.showPopup("Health Check!")}triggerDisruption(){this.world.startRotation(),this.ui.showPopup("Disruption!")}start(){this.timer.start()}stop(){this.ui.showGameOverScreen(Object.values(this.highscores).sort((g,S)=>g.getHighscore()-S.getHighscore())[0]),this.timer.pause()}getIsRunning(){return this.timer.isRunning()}isNewObjectMutable(){return Math.random()0?D.setPayloadType(m62(D.getPayloadType())):D.setPayloadType(a62(D.getPayloadType()));let U=d6(D,this.world);D.setPayload(U,this.isNewObjectMutable())}}hasPlayer(g){return Object.keys(this.players).includes(g)}getPlayer(g){return this.players[g]}activatePayload(g){if(this.getIsRunning()&&g!=""&&Object.keys(this.players).includes(g)){const S=this.players[g];if(S.getIsLocked())return;const D=S.releasePayload();D==null||D.activate(this.world),S.lock(),this.cooldownUntil[g]=new Date().getTime()+D62}}updateCooldowns(){const g=new Date().getTime();Object.keys(this.cooldownUntil).forEach(S=>{if(this.cooldownUntil[S]<=g&&this.players[S].getIsLocked()){this.players[S].unlock();const D=d6(this.players[S],this.world);this.players[S].setPayload(D,this.isNewObjectMutable())}})}update(){_4.staticUpdate(),c4.staticUpdate(),this.updateCooldowns(),this.world.update(),this.timer.update()}cleanUp(){_4.cleanup(),c4.cleanUp(),Lu.cleanUp(),Nu.cleanUp()}render(){this.world.render(),this.ui.render()}scalePlayer(g,S){this.getIsRunning()&&g!=""&&Object.keys(this.players).includes(g)&&this.players[g].scalePayload(S,D=>this.world.updateRigidBody(D))}debugRotation(){this.world.startRotation()}}const b62=3,F62=150,L62=15;class j62 extends v4{constructor(S,D,j=150){super(S,D,j,F62,b62);wt(this,"grid",new RW);const U=new zu(this.size,this.size);U.rotateX(-Math.PI/2);const Y=new Vu({color:this.color,opacity:1}),X=new yi(U,Y);X.position.copy(this.position),X.receiveShadow=!0,this.grid=new RW(this.size,L62),this.grid.position.copy(this.position),this.grid.material.transparent=!0,this.mesh=X,this.mesh.children.push(this.grid)}delete(){this.grid.dispose(),super.delete()}getIsDestructible(){return!1}getAabb(){return new L2(this.size,0,this.size)}}class O62{constructor(g,S){wt(this,"lastUpdateElapsed");wt(this,"rotationUnit");wt(this,"timer");this.rotationUnit=g/S,this.lastUpdateElapsed=0,this.timer=new W6(S,()=>{})}start(){this.timer.start()}getIsRunning(){return this.timer.isRunning()}getRotationStep(){if(!this.timer.isRunning())return 0;this.timer.update();let g=this.timer.getElapsed();const S=(g-this.lastUpdateElapsed)*this.rotationUnit;return this.lastUpdateElapsed=g,S}}const g6=150,G62=.1,U62=5,N62=500,W62=1e4,H62=70,z62=1,V62=new L2(0,15,150),Q62=1e3,Y62=-10,X62=10,q62=100,Z62=1e3,J62=-100,GW=10,K62=12578030,UW=0,NW=2048;class $62{constructor(g){wt(this,"camera");wt(this,"scene");wt(this,"light",new EW);wt(this,"renderer");wt(this,"physicsUniverse",{});wt(this,"bedrock");wt(this,"clock");wt(this,"objects",{});wt(this,"players",[]);wt(this,"objectCounter",0);wt(this,"currentId",0);wt(this,"sceneRotationMovement");this.camera=new rr(H62,window.innerWidth/window.innerHeight,z62,W62),this.scene=new F82,this.renderer=new vH({antialias:!0}),this.clock=new s62,this.initGraphicsUniverse(),this.initPhysicsUniverse(),this.initBedrock(g)}getCameraPosition(){let g=new L2;return this.camera.getWorldPosition(g),g}generateId(){let g=this.currentId;return this.currentId++,g}initBedrock(g){this.bedrock=new j62(new L2(0,g,0),this.generateId(),g6),this.bedrock.addPhysics(zW(this.bedrock)),this.add(this.bedrock);const S=g6/2,D=g6/2-U62,j=[-S,-S,+S,+S,+D,-D,+D,-D],U=[-D,+D,-D,+D,-S,-S,+S,+S],Y=new re.Ammo.btVector3(1,0,1),X=new re.Ammo.btVector3(0,0,0),n2=[0,2];for(let s2=0;s2{f2.enableSpring(a2,!0),f2.setStiffness(a2,N62),f2.setDamping(a2,G62)}),f2.setEquilibriumPoint(),this.physicsUniverse.addConstraint(f2,!1)}re.Ammo.destroy(Y),re.Ammo.destroy(X)}onWindowResize(){this.camera.aspect=window.innerWidth/window.innerHeight,this.camera.updateProjectionMatrix(),this.renderer.setSize(window.innerWidth,window.innerHeight)}initGraphicsUniverse(){this.camera.position.copy(V62),this.scene.background=new f0(K62),this.scene.add(new o62(16777215)),this.light=new EW(16777215,4.5),this.light.position.set(10,500,5),this.light.angle=Math.PI*.2,this.light.decay=0,this.light.castShadow=!0,this.light.shadow.camera.near=300,this.light.shadow.camera.far=600,this.light.shadow.bias=-222e-6,this.light.shadow.mapSize.width=NW,this.light.shadow.mapSize.height=NW,this.scene.add(this.light),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(window.innerWidth-UW,window.innerHeight-UW),this.renderer.shadowMap.enabled=!0,document.body.appendChild(this.renderer.domElement),window.addEventListener("resize",()=>this.onWindowResize())}initPhysicsUniverse(){let g=new re.Ammo.btDefaultCollisionConfiguration,S=new re.Ammo.btCollisionDispatcher(g),D=new re.Ammo.btDbvtBroadphase,j=new re.Ammo.btSequentialImpulseConstraintSolver;this.physicsUniverse=new re.Ammo.btDiscreteDynamicsWorld(S,D,j,g),re.auxVector3.setValue(0,Y62,0),this.physicsUniverse.setGravity(re.auxVector3)}startEarthquake(){var D;let g=Q62+this.objectCounter*50,S=(D=this.bedrock)==null?void 0:D.getRigidBody();S!==void 0&&(S.activate(),S.applyCentralImpulse(new re.Ammo.btVector3(g,0,0)),S.applyCentralImpulse(new re.Ammo.btVector3(0,0,g)))}update(){this.physicsUniverse.stepSimulation(this.clock.getDelta(),X62),Object.values(this.objects).forEach(g=>{g.update()}),this.sceneRotationMovement!==void 0&&this.sceneRotationMovement.getIsRunning()&&this.scene.rotateY(this.sceneRotationMovement.getRotationStep()),this.adjustPlayerHeights()}render(){this.renderer.render(this.scene,this.camera)}startRotation(){this.sceneRotationMovement=new O62(1.57,1e3),this.sceneRotationMovement.start()}adjustPlayerHeights(){let g=new re.Ammo.btVector3(0,0,0),S=new re.Ammo.btVector3(0,0,0);this.players.forEach(D=>{let U=D.getPointsForHeightTest().map(X=>{g.setValue(X.x,Z62,X.z),S.setValue(X.x,J62,X.z);let $=new re.Ammo.ClosestRayResultCallback(g,S);this.physicsUniverse.rayTest(g,S,$);let t2=0;return $.hasHit()&&(t2=$.get_m_hitPointWorld().y()+GW),re.Ammo.destroy($),t2}),Y=D.getPosition();D.moveToTarget(new L2(Y.x,Math.max(...U),Y.z),q62)}),re.Ammo.destroy(g),re.Ammo.destroy(S)}rayDistance(g,S){let D=-1,j=new re.Ammo.btVector3(g.x,g.y,g.z),U=new re.Ammo.btVector3(S.x,S.y,S.z),Y=new re.Ammo.ClosestRayResultCallback(j,U);return this.physicsUniverse.rayTest(j,U,Y),Y.hasHit()&&(D=g.distanceTo(new L2(Y.get_m_hitPointWorld().x(),Y.get_m_hitPointWorld().y(),Y.get_m_hitPointWorld().z()))),re.Ammo.destroy(j),re.Ammo.destroy(U),re.Ammo.destroy(Y),D}rayHitObject(g,S){let D,j=new re.Ammo.btVector3(g.x,g.y,g.z),U=new re.Ammo.btVector3(S.x,S.y,S.z),Y=new re.Ammo.ClosestRayResultCallback(j,U);if(this.physicsUniverse.rayTest(j,U,Y),Y.hasHit()){let X=Y.get_m_collisionObject();D=this.objects[X.getUserIndex()]}return re.Ammo.destroy(j),re.Ammo.destroy(U),re.Ammo.destroy(Y),D}updateRigidBody(g){this.physicsUniverse.removeRigidBody(g),this.physicsUniverse.addRigidBody(g)}add(g){this.scene.add(g.getMesh()),g.getMesh().children.forEach(S=>this.scene.add(S)),this.objects[String(g.getId())]=g,g.isAffectedByPhysics()&&this.addPhysicsObject(g.getRigidBody())}remove(g){this.scene.remove(g.getMesh()),g.getMesh().children.forEach(S=>this.scene.remove(S)),this.players.forEach(S=>{S.removePotentialChild(String(g.getId()))}),delete this.objects[String(g.getId())],g.isAffectedByPhysics()&&(this.objectCounter--,this.physicsUniverse.removeRigidBody(g.getRigidBody()))}addPhysicsObject(g){this.objectCounter++,this.physicsUniverse.addRigidBody(g)}addPlayer(g){this.players.push(g)}rotateX(g){this.scene.rotateX(g)}rotateY(g){this.scene.rotateY(g)}rotateZ(g){this.scene.rotateZ(g)}getPlayerOffset(){return GW}}const tc2="panel";class mp{constructor(g){wt(this,"target");wt(this,"isHidden",!0);this.target=document.createElement("div"),this.target.id=g,this.target.classList.add(tc2)}show(){this.isHidden&&document.body.append(this.target),this.isHidden=!1}hide(){this.isHidden||document.body.removeChild(this.target),this.isHidden=!0}render(){}}const ec2="counter";class nc2 extends mp{constructor(S,D){super(S);wt(this,"timeSupplier");this.timeSupplier=D,this.target.classList.add(ec2)}pad(S,D){let j=S.toString();for(;j.lengthU.getHighscore()-j.getHighscore()),S.forEach(j=>{let U=document.createElement("li");U.innerText=Math.round(j.getHighscore()).toString(),D.append(U)}),this.target.replaceChildren(D),this.target.insertBefore(this.heading,D)}}const uc2="overlay";class lc2 extends mp{constructor(S,D,j){super(S);wt(this,"message","");wt(this,"timer");wt(this,"visibleMs");this.timer=D,this.visibleMs=j,this.target.classList.add(uc2)}setMessage(S){this.message=S}show(){super.show(),this.timer.on(this.timer.getElapsed()+this.visibleMs,()=>{this.hide()})}render(){this.target.innerHTML=this.message}}class fc2{constructor(g){wt(this,"panels");wt(this,"renderInterval");wt(this,"lastRender");this.lastRender=new Date().getTime(),this.panels=[],this.renderInterval=g}render(){new Date().getTime()<=this.lastRender+this.renderInterval||(this.panels.forEach(g=>g.render()),this.lastRender=new Date().getTime())}add(g){this.panels.push(g)}}class pc2{constructor(g,S,D,j){wt(this,"timer");wt(this,"panels");wt(this,"overlay");this.timer=g,this.panels=new fc2(D);let U=new sc2("highscore",S);U.show(),this.panels.add(U);let Y=new nc2("countdown",()=>this.timer.getRemaining());Y.show(),this.panels.add(Y),this.overlay=new lc2("overlay",this.timer,j),this.panels.add(this.overlay)}render(){this.panels.render()}showGameOverScreen(g){let S=new rc2("game-over",()=>g);S.show(),this.panels.add(S)}showPopup(g){this.overlay.setMessage(g),this.overlay.show()}}const _c2=443,cc2="wss",hc2="42.scytec.de",sp=new v42(B42.connect(`${cc2}://${hc2}:${_c2}`));let Xn;(async()=>(re.Ammo=await HW.bind(window)(),re.initAuxObjects(),mc2()))();function mc2(){Xn=new I62((S,D,j,U,Y)=>new Nu(new L2(S,D,j),U,Y),S=>new $62(S),(S,D,j,U)=>new pc2(S,D,j,U)),sp.on("message",(S,D)=>{const j=D.toString(),[U,Y]=sp.parseTopic(S);switch(U){case Nr.Init:{if(Y!=""&&Xn.isPlayerAddable()){let $=Xn.addPlayer(Y).toString(16);for(;$.length<6;)$=`0${$}`;sp.publishClientSpecific(Nr.ColorResponse,Y,`#${$}`),Xn.getIsRunning()&&sp.publishClientSpecific(Nr.Start,Y,"")}break}case Nr.XMovement:{Xn.hasPlayer(Y)&&(Xn.getPlayer(Y).translateX(parseFloat(j)),console.log(new Date,j));break}case Nr.YMovement:{Xn.hasPlayer(Y);break}case Nr.ZMovement:{Xn.hasPlayer(Y)&&(Xn.getPlayer(Y).translateZ(parseFloat(j)),console.log(new Date,j));break}case Nr.Drop:{Xn.activatePayload(Y);break}case Nr.Scale:{Xn.scalePlayer(Y,parseFloat(j));break}case Nr.ColorResponse:break;case Nr.Start:{Xn.start();break}case Nr.RoatetPayload:{Xn.switchPlayerPayload(Y,parseInt(j));break}default:console.warn(`topic ${S} undefined`)}});function F(){document.body.addEventListener("keydown",S=>{switch(S.key){case"ArrowLeft":Xn.debugRotation();break;case"ArrowRight":Xn.triggerDisruption();break}})}function g(){requestAnimationFrame(g),Xn.update(),Xn.render()}F(),g()} +}`;function S82(F,g,S){let D=new P6;const j=new _e,U=new _e,Y=new Gn,X=new g82({depthPacking:au2}),$=new k82,t2={},n2=S.maxTextureSize,s2={[P1]:Oi,[Oi]:P1,[Xr]:Xr},m=new ls({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new _e},radius:{value:4}},vertexShader:v82,fragmentShader:B82}),f2=m.clone();f2.defines.HORIZONTAL_PASS=1;const a2=new xr;a2.setAttribute("position",new yo(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const A2=new yi(a2,m),p2=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=VW;let o2=this.type;this.render=function(b2,F2,j2){if(p2.enabled===!1||p2.autoUpdate===!1&&p2.needsUpdate===!1||b2.length===0)return;const J2=F.getRenderTarget(),B2=F.getActiveCubeFace(),T2=F.getActiveMipmapLevel(),ht=F.state;ht.setBlending(T1),ht.buffers.color.setClear(1,1,1,1),ht.buffers.depth.setTest(!0),ht.setScissorTest(!1);const St=o2!==qo&&this.type===qo,q2=o2===qo&&this.type!==qo;for(let tt=0,it=b2.length;ttn2||j.y>n2)&&(j.x>n2&&(U.x=Math.floor(n2/mt.x),j.x=U.x*mt.x,_t.mapSize.x=U.x),j.y>n2&&(U.y=Math.floor(n2/mt.y),j.y=U.y*mt.y,_t.mapSize.y=U.y)),_t.map===null||St===!0||q2===!0){const Bt=this.type!==qo?{minFilter:gn,magFilter:gn}:{};_t.map!==null&&_t.map.dispose(),_t.map=new us(j.x,j.y,Bt),_t.map.texture.name=Ct.name+".shadowMap",_t.camera.updateProjectionMatrix()}F.setRenderTarget(_t.map),F.clear();const vt=_t.getViewportCount();for(let Bt=0;Bt0||F2.map&&F2.alphaTest>0){const ht=B2.uuid,St=F2.uuid;let q2=t2[ht];q2===void 0&&(q2={},t2[ht]=q2);let tt=q2[St];tt===void 0&&(tt=B2.clone(),q2[St]=tt),B2=tt}if(B2.visible=F2.visible,B2.wireframe=F2.wireframe,J2===qo?B2.side=F2.shadowSide!==null?F2.shadowSide:F2.side:B2.side=F2.shadowSide!==null?F2.shadowSide:s2[F2.side],B2.alphaMap=F2.alphaMap,B2.alphaTest=F2.alphaTest,B2.map=F2.map,B2.clipShadows=F2.clipShadows,B2.clippingPlanes=F2.clippingPlanes,B2.clipIntersection=F2.clipIntersection,B2.displacementMap=F2.displacementMap,B2.displacementScale=F2.displacementScale,B2.displacementBias=F2.displacementBias,B2.wireframeLinewidth=F2.wireframeLinewidth,B2.linewidth=F2.linewidth,j2.isPointLight===!0&&B2.isMeshDistanceMaterial===!0){const ht=F.properties.get(B2);ht.light=j2}return B2}function P2(b2,F2,j2,J2,B2){if(b2.visible===!1)return;if(b2.layers.test(F2.layers)&&(b2.isMesh||b2.isLine||b2.isPoints)&&(b2.castShadow||b2.receiveShadow&&B2===qo)&&(!b2.frustumCulled||D.intersectsObject(b2))){b2.modelViewMatrix.multiplyMatrices(j2.matrixWorldInverse,b2.matrixWorld);const St=g.update(b2),q2=b2.material;if(Array.isArray(q2)){const tt=St.groups;for(let it=0,Ct=tt.length;it=1):mt.indexOf("OpenGL ES")!==-1&&(_t=parseFloat(/^OpenGL ES (\d)/.exec(mt)[1]),Ct=_t>=2);let vt=null,Bt={};const X2=F.getParameter(F.SCISSOR_BOX),ct=F.getParameter(F.VIEWPORT),zt=new Gn().fromArray(X2),Qt=new Gn().fromArray(ct);function Kt(G2,Ht,$2,Lt){const Yt=new Uint8Array(4),o0=F.createTexture();F.bindTexture(G2,o0),F.texParameteri(G2,F.TEXTURE_MIN_FILTER,F.NEAREST),F.texParameteri(G2,F.TEXTURE_MAG_FILTER,F.NEAREST);for(let I0=0;I0<$2;I0++)D&&(G2===F.TEXTURE_3D||G2===F.TEXTURE_2D_ARRAY)?F.texImage3D(Ht,0,F.RGBA,1,1,Lt,0,F.RGBA,F.UNSIGNED_BYTE,Yt):F.texImage2D(Ht+I0,0,F.RGBA,1,1,0,F.RGBA,F.UNSIGNED_BYTE,Yt);return o0}const de={};de[F.TEXTURE_2D]=Kt(F.TEXTURE_2D,F.TEXTURE_2D,1),de[F.TEXTURE_CUBE_MAP]=Kt(F.TEXTURE_CUBE_MAP,F.TEXTURE_CUBE_MAP_POSITIVE_X,6),D&&(de[F.TEXTURE_2D_ARRAY]=Kt(F.TEXTURE_2D_ARRAY,F.TEXTURE_2D_ARRAY,1,1),de[F.TEXTURE_3D]=Kt(F.TEXTURE_3D,F.TEXTURE_3D,1,1)),X.setClear(0,0,0,1),$.setClear(1),t2.setClear(0),Be(F.DEPTH_TEST),$.setFunc(k6),Me(!1),p0(iN),Be(F.CULL_FACE),Ce(T1);function Be(G2){m[G2]!==!0&&(F.enable(G2),m[G2]=!0)}function me(G2){m[G2]!==!1&&(F.disable(G2),m[G2]=!1)}function h0(G2,Ht){return f2[G2]!==Ht?(F.bindFramebuffer(G2,Ht),f2[G2]=Ht,D&&(G2===F.DRAW_FRAMEBUFFER&&(f2[F.FRAMEBUFFER]=Ht),G2===F.FRAMEBUFFER&&(f2[F.DRAW_FRAMEBUFFER]=Ht)),!0):!1}function Dn(G2,Ht){let $2=A2,Lt=!1;if(G2)if($2=a2.get(Ht),$2===void 0&&($2=[],a2.set(Ht,$2)),G2.isWebGLMultipleRenderTargets){const Yt=G2.texture;if($2.length!==Yt.length||$2[0]!==F.COLOR_ATTACHMENT0){for(let o0=0,I0=Yt.length;o0"u"?!1:/OculusBrowser/g.test(navigator.userAgent),a2=new WeakMap;let A2;const p2=new WeakMap;let o2=!1;try{o2=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x2(M2,g2){return o2?new OffscreenCanvas(M2,g2):Gu("canvas")}function d2(M2,g2,Z2,Dt){let xt=1;if((M2.width>Dt||M2.height>Dt)&&(xt=Dt/Math.max(M2.width,M2.height)),xt<1||g2===!0)if(typeof HTMLImageElement<"u"&&M2 instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&M2 instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&M2 instanceof ImageBitmap){const It=g2?w6:Math.floor,le=It(xt*M2.width),Pt=It(xt*M2.height);A2===void 0&&(A2=x2(le,Pt));const et=Z2?x2(le,Pt):A2;return et.width=le,et.height=Pt,et.getContext("2d").drawImage(M2,0,0,le,Pt),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+M2.width+"x"+M2.height+") to ("+le+"x"+Pt+")."),et}else return"data"in M2&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+M2.width+"x"+M2.height+")."),M2;return M2}function P2(M2){return FN(M2.width)&&FN(M2.height)}function b2(M2){return X?!1:M2.wrapS!==qr||M2.wrapT!==qr||M2.minFilter!==gn&&M2.minFilter!==wr}function F2(M2,g2){return M2.generateMipmaps&&g2&&M2.minFilter!==gn&&M2.minFilter!==wr}function j2(M2){F.generateMipmap(M2)}function J2(M2,g2,Z2,Dt,xt=!1){if(X===!1)return g2;if(M2!==null){if(F[M2]!==void 0)return F[M2];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+M2+"'")}let It=g2;return g2===F.RED&&(Z2===F.FLOAT&&(It=F.R32F),Z2===F.HALF_FLOAT&&(It=F.R16F),Z2===F.UNSIGNED_BYTE&&(It=F.R8)),g2===F.RED_INTEGER&&(Z2===F.UNSIGNED_BYTE&&(It=F.R8UI),Z2===F.UNSIGNED_SHORT&&(It=F.R16UI),Z2===F.UNSIGNED_INT&&(It=F.R32UI),Z2===F.BYTE&&(It=F.R8I),Z2===F.SHORT&&(It=F.R16I),Z2===F.INT&&(It=F.R32I)),g2===F.RG&&(Z2===F.FLOAT&&(It=F.RG32F),Z2===F.HALF_FLOAT&&(It=F.RG16F),Z2===F.UNSIGNED_BYTE&&(It=F.RG8)),g2===F.RGBA&&(Z2===F.FLOAT&&(It=F.RGBA32F),Z2===F.HALF_FLOAT&&(It=F.RGBA16F),Z2===F.UNSIGNED_BYTE&&(It=Dt===qe&&xt===!1?F.SRGB8_ALPHA8:F.RGBA8),Z2===F.UNSIGNED_SHORT_4_4_4_4&&(It=F.RGBA4),Z2===F.UNSIGNED_SHORT_5_5_5_1&&(It=F.RGB5_A1)),(It===F.R16F||It===F.R32F||It===F.RG16F||It===F.RG32F||It===F.RGBA16F||It===F.RGBA32F)&&g.get("EXT_color_buffer_float"),It}function B2(M2,g2,Z2){return F2(M2,Z2)===!0||M2.isFramebufferTexture&&M2.minFilter!==gn&&M2.minFilter!==wr?Math.log2(Math.max(g2.width,g2.height))+1:M2.mipmaps!==void 0&&M2.mipmaps.length>0?M2.mipmaps.length:M2.isCompressedTexture&&Array.isArray(M2.image)?g2.mipmaps.length:1}function T2(M2){return M2===gn||M2===fN||M2===F8?F.NEAREST:F.LINEAR}function ht(M2){const g2=M2.target;g2.removeEventListener("dispose",ht),q2(g2),g2.isVideoTexture&&a2.delete(g2)}function St(M2){const g2=M2.target;g2.removeEventListener("dispose",St),it(g2)}function q2(M2){const g2=D.get(M2);if(g2.__webglInit===void 0)return;const Z2=M2.source,Dt=p2.get(Z2);if(Dt){const xt=Dt[g2.__cacheKey];xt.usedTimes--,xt.usedTimes===0&&tt(M2),Object.keys(Dt).length===0&&p2.delete(Z2)}D.remove(M2)}function tt(M2){const g2=D.get(M2);F.deleteTexture(g2.__webglTexture);const Z2=M2.source,Dt=p2.get(Z2);delete Dt[g2.__cacheKey],Y.memory.textures--}function it(M2){const g2=M2.texture,Z2=D.get(M2),Dt=D.get(g2);if(Dt.__webglTexture!==void 0&&(F.deleteTexture(Dt.__webglTexture),Y.memory.textures--),M2.depthTexture&&M2.depthTexture.dispose(),M2.isWebGLCubeRenderTarget)for(let xt=0;xt<6;xt++){if(Array.isArray(Z2.__webglFramebuffer[xt]))for(let It=0;It=$&&console.warn("THREE.WebGLTextures: Trying to use "+M2+" texture units while this GPU supports only "+$),Ct+=1,M2}function vt(M2){const g2=[];return g2.push(M2.wrapS),g2.push(M2.wrapT),g2.push(M2.wrapR||0),g2.push(M2.magFilter),g2.push(M2.minFilter),g2.push(M2.anisotropy),g2.push(M2.internalFormat),g2.push(M2.format),g2.push(M2.type),g2.push(M2.generateMipmaps),g2.push(M2.premultiplyAlpha),g2.push(M2.flipY),g2.push(M2.unpackAlignment),g2.push(M2.colorSpace),g2.join()}function Bt(M2,g2){const Z2=D.get(M2);if(M2.isVideoTexture&&pn(M2),M2.isRenderTargetTexture===!1&&M2.version>0&&Z2.__version!==M2.version){const Dt=M2.image;if(Dt===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Dt.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{h0(Z2,M2,g2);return}}S.bindTexture(F.TEXTURE_2D,Z2.__webglTexture,F.TEXTURE0+g2)}function X2(M2,g2){const Z2=D.get(M2);if(M2.version>0&&Z2.__version!==M2.version){h0(Z2,M2,g2);return}S.bindTexture(F.TEXTURE_2D_ARRAY,Z2.__webglTexture,F.TEXTURE0+g2)}function ct(M2,g2){const Z2=D.get(M2);if(M2.version>0&&Z2.__version!==M2.version){h0(Z2,M2,g2);return}S.bindTexture(F.TEXTURE_3D,Z2.__webglTexture,F.TEXTURE0+g2)}function zt(M2,g2){const Z2=D.get(M2);if(M2.version>0&&Z2.__version!==M2.version){Dn(Z2,M2,g2);return}S.bindTexture(F.TEXTURE_CUBE_MAP,Z2.__webglTexture,F.TEXTURE0+g2)}const Qt={[Qr]:F.REPEAT,[qr]:F.CLAMP_TO_EDGE,[S6]:F.MIRRORED_REPEAT},Kt={[gn]:F.NEAREST,[fN]:F.NEAREST_MIPMAP_NEAREST,[F8]:F.NEAREST_MIPMAP_LINEAR,[wr]:F.LINEAR,[ru2]:F.LINEAR_MIPMAP_NEAREST,[ju]:F.LINEAR_MIPMAP_LINEAR},de={[yu2]:F.NEVER,[wu2]:F.ALWAYS,[gu2]:F.LESS,[vu2]:F.LEQUAL,[ku2]:F.EQUAL,[Cu2]:F.GEQUAL,[Bu2]:F.GREATER,[Su2]:F.NOTEQUAL};function Be(M2,g2,Z2){if(Z2?(F.texParameteri(M2,F.TEXTURE_WRAP_S,Qt[g2.wrapS]),F.texParameteri(M2,F.TEXTURE_WRAP_T,Qt[g2.wrapT]),(M2===F.TEXTURE_3D||M2===F.TEXTURE_2D_ARRAY)&&F.texParameteri(M2,F.TEXTURE_WRAP_R,Qt[g2.wrapR]),F.texParameteri(M2,F.TEXTURE_MAG_FILTER,Kt[g2.magFilter]),F.texParameteri(M2,F.TEXTURE_MIN_FILTER,Kt[g2.minFilter])):(F.texParameteri(M2,F.TEXTURE_WRAP_S,F.CLAMP_TO_EDGE),F.texParameteri(M2,F.TEXTURE_WRAP_T,F.CLAMP_TO_EDGE),(M2===F.TEXTURE_3D||M2===F.TEXTURE_2D_ARRAY)&&F.texParameteri(M2,F.TEXTURE_WRAP_R,F.CLAMP_TO_EDGE),(g2.wrapS!==qr||g2.wrapT!==qr)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),F.texParameteri(M2,F.TEXTURE_MAG_FILTER,T2(g2.magFilter)),F.texParameteri(M2,F.TEXTURE_MIN_FILTER,T2(g2.minFilter)),g2.minFilter!==gn&&g2.minFilter!==wr&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),g2.compareFunction&&(F.texParameteri(M2,F.TEXTURE_COMPARE_MODE,F.COMPARE_REF_TO_TEXTURE),F.texParameteri(M2,F.TEXTURE_COMPARE_FUNC,de[g2.compareFunction])),g.has("EXT_texture_filter_anisotropic")===!0){const Dt=g.get("EXT_texture_filter_anisotropic");if(g2.magFilter===gn||g2.minFilter!==F8&&g2.minFilter!==ju||g2.type===E1&&g.has("OES_texture_float_linear")===!1||X===!1&&g2.type===Ou&&g.has("OES_texture_half_float_linear")===!1)return;(g2.anisotropy>1||D.get(g2).__currentAnisotropy)&&(F.texParameterf(M2,Dt.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(g2.anisotropy,j.getMaxAnisotropy())),D.get(g2).__currentAnisotropy=g2.anisotropy)}}function me(M2,g2){let Z2=!1;M2.__webglInit===void 0&&(M2.__webglInit=!0,g2.addEventListener("dispose",ht));const Dt=g2.source;let xt=p2.get(Dt);xt===void 0&&(xt={},p2.set(Dt,xt));const It=vt(g2);if(It!==M2.__cacheKey){xt[It]===void 0&&(xt[It]={texture:F.createTexture(),usedTimes:0},Y.memory.textures++,Z2=!0),xt[It].usedTimes++;const le=xt[M2.__cacheKey];le!==void 0&&(xt[M2.__cacheKey].usedTimes--,le.usedTimes===0&&tt(g2)),M2.__cacheKey=It,M2.__webglTexture=xt[It].texture}return Z2}function h0(M2,g2,Z2){let Dt=F.TEXTURE_2D;(g2.isDataArrayTexture||g2.isCompressedArrayTexture)&&(Dt=F.TEXTURE_2D_ARRAY),g2.isData3DTexture&&(Dt=F.TEXTURE_3D);const xt=me(M2,g2),It=g2.source;S.bindTexture(Dt,M2.__webglTexture,F.TEXTURE0+Z2);const le=D.get(It);if(It.version!==le.__version||xt===!0){S.activeTexture(F.TEXTURE0+Z2),F.pixelStorei(F.UNPACK_FLIP_Y_WEBGL,g2.flipY),F.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL,g2.premultiplyAlpha),F.pixelStorei(F.UNPACK_ALIGNMENT,g2.unpackAlignment),F.pixelStorei(F.UNPACK_COLORSPACE_CONVERSION_WEBGL,F.NONE);const Pt=b2(g2)&&P2(g2.image)===!1;let et=d2(g2.image,Pt,!1,n2);et=In(g2,et);const ge=P2(et)||X,fe=U.convert(g2.format,g2.colorSpace);let ye=U.convert(g2.type),oe=J2(g2.internalFormat,fe,ye,g2.colorSpace);Be(Dt,g2,ge);let se;const ze=g2.mipmaps,C0=X&&g2.isVideoTexture!==!0,G2=le.__version===void 0||xt===!0,Ht=B2(g2,et,ge);if(g2.isDepthTexture)oe=F.DEPTH_COMPONENT,X?g2.type===E1?oe=F.DEPTH_COMPONENT32F:g2.type===M1?oe=F.DEPTH_COMPONENT24:g2.type===is?oe=F.DEPTH24_STENCIL8:oe=F.DEPTH_COMPONENT16:g2.type===E1&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),g2.format===rs&&oe===F.DEPTH_COMPONENT&&g2.type!==R6&&g2.type!==M1&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),g2.type=M1,ye=U.convert(g2.type)),g2.format===a4&&oe===F.DEPTH_COMPONENT&&(oe=F.DEPTH_STENCIL,g2.type!==is&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),g2.type=is,ye=U.convert(g2.type))),G2&&(C0?S.texStorage2D(F.TEXTURE_2D,1,oe,et.width,et.height):S.texImage2D(F.TEXTURE_2D,0,oe,et.width,et.height,0,fe,ye,null));else if(g2.isDataTexture)if(ze.length>0&&ge){C0&&G2&&S.texStorage2D(F.TEXTURE_2D,Ht,oe,ze[0].width,ze[0].height);for(let $2=0,Lt=ze.length;$2>=1,Lt>>=1}}else if(ze.length>0&&ge){C0&&G2&&S.texStorage2D(F.TEXTURE_2D,Ht,oe,ze[0].width,ze[0].height);for(let $2=0,Lt=ze.length;$20&&G2++,S.texStorage2D(F.TEXTURE_CUBE_MAP,G2,se,et[0].width,et[0].height));for(let $2=0;$2<6;$2++)if(Pt){ze?S.texSubImage2D(F.TEXTURE_CUBE_MAP_POSITIVE_X+$2,0,0,0,et[$2].width,et[$2].height,ye,oe,et[$2].data):S.texImage2D(F.TEXTURE_CUBE_MAP_POSITIVE_X+$2,0,se,et[$2].width,et[$2].height,0,ye,oe,et[$2].data);for(let Lt=0;Lt>It),ye=Math.max(1,g2.height>>It);xt===F.TEXTURE_3D||xt===F.TEXTURE_2D_ARRAY?S.texImage3D(xt,It,et,fe,ye,g2.depth,0,le,Pt,null):S.texImage2D(xt,It,et,fe,ye,0,le,Pt,null)}S.bindFramebuffer(F.FRAMEBUFFER,M2),v0(g2)?m.framebufferTexture2DMultisampleEXT(F.FRAMEBUFFER,Dt,xt,D.get(Z2).__webglTexture,0,be(g2)):(xt===F.TEXTURE_2D||xt>=F.TEXTURE_CUBE_MAP_POSITIVE_X&&xt<=F.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&F.framebufferTexture2D(F.FRAMEBUFFER,Dt,xt,D.get(Z2).__webglTexture,It),S.bindFramebuffer(F.FRAMEBUFFER,null)}function Y2(M2,g2,Z2){if(F.bindRenderbuffer(F.RENDERBUFFER,M2),g2.depthBuffer&&!g2.stencilBuffer){let Dt=F.DEPTH_COMPONENT16;if(Z2||v0(g2)){const xt=g2.depthTexture;xt&&xt.isDepthTexture&&(xt.type===E1?Dt=F.DEPTH_COMPONENT32F:xt.type===M1&&(Dt=F.DEPTH_COMPONENT24));const It=be(g2);v0(g2)?m.renderbufferStorageMultisampleEXT(F.RENDERBUFFER,It,Dt,g2.width,g2.height):F.renderbufferStorageMultisample(F.RENDERBUFFER,It,Dt,g2.width,g2.height)}else F.renderbufferStorage(F.RENDERBUFFER,Dt,g2.width,g2.height);F.framebufferRenderbuffer(F.FRAMEBUFFER,F.DEPTH_ATTACHMENT,F.RENDERBUFFER,M2)}else if(g2.depthBuffer&&g2.stencilBuffer){const Dt=be(g2);Z2&&v0(g2)===!1?F.renderbufferStorageMultisample(F.RENDERBUFFER,Dt,F.DEPTH24_STENCIL8,g2.width,g2.height):v0(g2)?m.renderbufferStorageMultisampleEXT(F.RENDERBUFFER,Dt,F.DEPTH24_STENCIL8,g2.width,g2.height):F.renderbufferStorage(F.RENDERBUFFER,F.DEPTH_STENCIL,g2.width,g2.height),F.framebufferRenderbuffer(F.FRAMEBUFFER,F.DEPTH_STENCIL_ATTACHMENT,F.RENDERBUFFER,M2)}else{const Dt=g2.isWebGLMultipleRenderTargets===!0?g2.texture:[g2.texture];for(let xt=0;xt0){Z2.__webglFramebuffer[Pt]=[];for(let et=0;et0){Z2.__webglFramebuffer=[];for(let Pt=0;Pt0&&v0(M2)===!1){const Pt=It?g2:[g2];Z2.__webglMultisampledFramebuffer=F.createFramebuffer(),Z2.__webglColorRenderbuffer=[],S.bindFramebuffer(F.FRAMEBUFFER,Z2.__webglMultisampledFramebuffer);for(let et=0;et0)for(let et=0;et0)for(let et=0;et0&&v0(M2)===!1){const g2=M2.isWebGLMultipleRenderTargets?M2.texture:[M2.texture],Z2=M2.width,Dt=M2.height;let xt=F.COLOR_BUFFER_BIT;const It=[],le=M2.stencilBuffer?F.DEPTH_STENCIL_ATTACHMENT:F.DEPTH_ATTACHMENT,Pt=D.get(M2),et=M2.isWebGLMultipleRenderTargets===!0;if(et)for(let ge=0;ge0&&g.has("WEBGL_multisampled_render_to_texture")===!0&&g2.__useRenderToTexture!==!1}function pn(M2){const g2=Y.render.frame;a2.get(M2)!==g2&&(a2.set(M2,g2),M2.update())}function In(M2,g2){const Z2=M2.colorSpace,Dt=M2.format,xt=M2.type;return M2.isCompressedTexture===!0||M2.format===C6||Z2!==go&&Z2!==ss&&(Z2===qe?X===!1?g.has("EXT_sRGB")===!0&&Dt===Zr?(M2.format=C6,M2.minFilter=wr,M2.generateMipmaps=!1):g2=rH.sRGBToLinear(g2):(Dt!==Zr||xt!==D1)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",Z2)),g2}this.allocateTextureUnit=mt,this.resetTextureUnits=_t,this.setTexture2D=Bt,this.setTexture2DArray=X2,this.setTexture3D=ct,this.setTextureCube=zt,this.rebindTextures=Re,this.setupRenderTarget=Me,this.updateRenderTargetMipmap=p0,this.updateMultisampleRenderTarget=He,this.setupDepthRenderbuffer=Ce,this.setupFrameBufferTexture=We,this.useMultisampledRTT=v0}function x82(F,g,S){const D=S.isWebGL2;function j(U,Y=ss){let X;if(U===D1)return F.UNSIGNED_BYTE;if(U===ZW)return F.UNSIGNED_SHORT_4_4_4_4;if(U===JW)return F.UNSIGNED_SHORT_5_5_5_1;if(U===ou2)return F.BYTE;if(U===su2)return F.SHORT;if(U===R6)return F.UNSIGNED_SHORT;if(U===qW)return F.INT;if(U===M1)return F.UNSIGNED_INT;if(U===E1)return F.FLOAT;if(U===Ou)return D?F.HALF_FLOAT:(X=g.get("OES_texture_half_float"),X!==null?X.HALF_FLOAT_OES:null);if(U===uu2)return F.ALPHA;if(U===Zr)return F.RGBA;if(U===lu2)return F.LUMINANCE;if(U===fu2)return F.LUMINANCE_ALPHA;if(U===rs)return F.DEPTH_COMPONENT;if(U===a4)return F.DEPTH_STENCIL;if(U===C6)return X=g.get("EXT_sRGB"),X!==null?X.SRGB_ALPHA_EXT:null;if(U===pu2)return F.RED;if(U===KW)return F.RED_INTEGER;if(U===_u2)return F.RG;if(U===$W)return F.RG_INTEGER;if(U===tH)return F.RGBA_INTEGER;if(U===L8||U===j8||U===O8||U===G8)if(Y===qe)if(X=g.get("WEBGL_compressed_texture_s3tc_srgb"),X!==null){if(U===L8)return X.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(U===j8)return X.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(U===O8)return X.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(U===G8)return X.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(X=g.get("WEBGL_compressed_texture_s3tc"),X!==null){if(U===L8)return X.COMPRESSED_RGB_S3TC_DXT1_EXT;if(U===j8)return X.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(U===O8)return X.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(U===G8)return X.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(U===pN||U===_N||U===cN||U===hN)if(X=g.get("WEBGL_compressed_texture_pvrtc"),X!==null){if(U===pN)return X.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(U===_N)return X.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(U===cN)return X.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(U===hN)return X.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(U===cu2)return X=g.get("WEBGL_compressed_texture_etc1"),X!==null?X.COMPRESSED_RGB_ETC1_WEBGL:null;if(U===mN||U===aN)if(X=g.get("WEBGL_compressed_texture_etc"),X!==null){if(U===mN)return Y===qe?X.COMPRESSED_SRGB8_ETC2:X.COMPRESSED_RGB8_ETC2;if(U===aN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:X.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(U===AN||U===dN||U===yN||U===gN||U===kN||U===vN||U===BN||U===SN||U===CN||U===wN||U===xN||U===MN||U===EN||U===TN)if(X=g.get("WEBGL_compressed_texture_astc"),X!==null){if(U===AN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:X.COMPRESSED_RGBA_ASTC_4x4_KHR;if(U===dN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:X.COMPRESSED_RGBA_ASTC_5x4_KHR;if(U===yN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:X.COMPRESSED_RGBA_ASTC_5x5_KHR;if(U===gN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:X.COMPRESSED_RGBA_ASTC_6x5_KHR;if(U===kN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:X.COMPRESSED_RGBA_ASTC_6x6_KHR;if(U===vN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:X.COMPRESSED_RGBA_ASTC_8x5_KHR;if(U===BN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:X.COMPRESSED_RGBA_ASTC_8x6_KHR;if(U===SN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:X.COMPRESSED_RGBA_ASTC_8x8_KHR;if(U===CN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:X.COMPRESSED_RGBA_ASTC_10x5_KHR;if(U===wN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:X.COMPRESSED_RGBA_ASTC_10x6_KHR;if(U===xN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:X.COMPRESSED_RGBA_ASTC_10x8_KHR;if(U===MN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:X.COMPRESSED_RGBA_ASTC_10x10_KHR;if(U===EN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:X.COMPRESSED_RGBA_ASTC_12x10_KHR;if(U===TN)return Y===qe?X.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:X.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(U===U8)if(X=g.get("EXT_texture_compression_bptc"),X!==null){if(U===U8)return Y===qe?X.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:X.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(U===hu2||U===RN||U===DN||U===PN)if(X=g.get("EXT_texture_compression_rgtc"),X!==null){if(U===U8)return X.COMPRESSED_RED_RGTC1_EXT;if(U===RN)return X.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(U===DN)return X.COMPRESSED_RED_GREEN_RGTC2_EXT;if(U===PN)return X.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return U===is?D?F.UNSIGNED_INT_24_8:(X=g.get("WEBGL_depth_texture"),X!==null?X.UNSIGNED_INT_24_8_WEBGL:null):F[U]!==void 0?F[U]:null}return{convert:j}}class M82 extends rr{constructor(g=[]){super(),this.isArrayCamera=!0,this.cameras=g}}class np extends Zn{constructor(){super(),this.isGroup=!0,this.type="Group"}}const E82={type:"move"};class p6{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new np,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new np,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new L2,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new L2),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new np,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new L2,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new L2),this._grip}dispatchEvent(g){return this._targetRay!==null&&this._targetRay.dispatchEvent(g),this._grip!==null&&this._grip.dispatchEvent(g),this._hand!==null&&this._hand.dispatchEvent(g),this}connect(g){if(g&&g.hand){const S=this._hand;if(S)for(const D of g.hand.values())this._getHandJoint(S,D)}return this.dispatchEvent({type:"connected",data:g}),this}disconnect(g){return this.dispatchEvent({type:"disconnected",data:g}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(g,S,D){let j=null,U=null,Y=null;const X=this._targetRay,$=this._grip,t2=this._hand;if(g&&S.session.visibilityState!=="visible-blurred"){if(t2&&g.hand){Y=!0;for(const A2 of g.hand.values()){const p2=S.getJointPose(A2,D),o2=this._getHandJoint(t2,A2);p2!==null&&(o2.matrix.fromArray(p2.transform.matrix),o2.matrix.decompose(o2.position,o2.rotation,o2.scale),o2.matrixWorldNeedsUpdate=!0,o2.jointRadius=p2.radius),o2.visible=p2!==null}const n2=t2.joints["index-finger-tip"],s2=t2.joints["thumb-tip"],m=n2.position.distanceTo(s2.position),f2=.02,a2=.005;t2.inputState.pinching&&m>f2+a2?(t2.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:g.handedness,target:this})):!t2.inputState.pinching&&m<=f2-a2&&(t2.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:g.handedness,target:this}))}else $!==null&&g.gripSpace&&(U=S.getPose(g.gripSpace,D),U!==null&&($.matrix.fromArray(U.transform.matrix),$.matrix.decompose($.position,$.rotation,$.scale),$.matrixWorldNeedsUpdate=!0,U.linearVelocity?($.hasLinearVelocity=!0,$.linearVelocity.copy(U.linearVelocity)):$.hasLinearVelocity=!1,U.angularVelocity?($.hasAngularVelocity=!0,$.angularVelocity.copy(U.angularVelocity)):$.hasAngularVelocity=!1));X!==null&&(j=S.getPose(g.targetRaySpace,D),j===null&&U!==null&&(j=U),j!==null&&(X.matrix.fromArray(j.transform.matrix),X.matrix.decompose(X.position,X.rotation,X.scale),X.matrixWorldNeedsUpdate=!0,j.linearVelocity?(X.hasLinearVelocity=!0,X.linearVelocity.copy(j.linearVelocity)):X.hasLinearVelocity=!1,j.angularVelocity?(X.hasAngularVelocity=!0,X.angularVelocity.copy(j.angularVelocity)):X.hasAngularVelocity=!1,this.dispatchEvent(E82)))}return X!==null&&(X.visible=j!==null),$!==null&&($.visible=U!==null),t2!==null&&(t2.visible=Y!==null),this}_getHandJoint(g,S){if(g.joints[S.jointName]===void 0){const D=new np;D.matrixAutoUpdate=!1,D.visible=!1,g.joints[S.jointName]=D,g.add(D)}return g.joints[S.jointName]}}class T82 extends gi{constructor(g,S,D,j,U,Y,X,$,t2,n2){if(n2=n2!==void 0?n2:rs,n2!==rs&&n2!==a4)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");D===void 0&&n2===rs&&(D=M1),D===void 0&&n2===a4&&(D=is),super(null,j,U,Y,X,$,n2,D,t2),this.isDepthTexture=!0,this.image={width:g,height:S},this.magFilter=X!==void 0?X:gn,this.minFilter=$!==void 0?$:gn,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(g){return super.copy(g),this.compareFunction=g.compareFunction,this}toJSON(g){const S=super.toJSON(g);return this.compareFunction!==null&&(S.compareFunction=this.compareFunction),S}}class R82 extends d4{constructor(g,S){super();const D=this;let j=null,U=1,Y=null,X="local-floor",$=1,t2=null,n2=null,s2=null,m=null,f2=null,a2=null;const A2=S.getContextAttributes();let p2=null,o2=null;const x2=[],d2=[],P2=new rr;P2.layers.enable(1),P2.viewport=new Gn;const b2=new rr;b2.layers.enable(2),b2.viewport=new Gn;const F2=[P2,b2],j2=new M82;j2.layers.enable(1),j2.layers.enable(2);let J2=null,B2=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(X2){let ct=x2[X2];return ct===void 0&&(ct=new p6,x2[X2]=ct),ct.getTargetRaySpace()},this.getControllerGrip=function(X2){let ct=x2[X2];return ct===void 0&&(ct=new p6,x2[X2]=ct),ct.getGripSpace()},this.getHand=function(X2){let ct=x2[X2];return ct===void 0&&(ct=new p6,x2[X2]=ct),ct.getHandSpace()};function T2(X2){const ct=d2.indexOf(X2.inputSource);if(ct===-1)return;const zt=x2[ct];zt!==void 0&&(zt.update(X2.inputSource,X2.frame,t2||Y),zt.dispatchEvent({type:X2.type,data:X2.inputSource}))}function ht(){j.removeEventListener("select",T2),j.removeEventListener("selectstart",T2),j.removeEventListener("selectend",T2),j.removeEventListener("squeeze",T2),j.removeEventListener("squeezestart",T2),j.removeEventListener("squeezeend",T2),j.removeEventListener("end",ht),j.removeEventListener("inputsourceschange",St);for(let X2=0;X2=0&&(d2[Qt]=null,x2[Qt].disconnect(zt))}for(let ct=0;ct=d2.length){d2.push(zt),Qt=de;break}else if(d2[de]===null){d2[de]=zt,Qt=de;break}if(Qt===-1)break}const Kt=x2[Qt];Kt&&Kt.connect(zt)}}const q2=new L2,tt=new L2;function it(X2,ct,zt){q2.setFromMatrixPosition(ct.matrixWorld),tt.setFromMatrixPosition(zt.matrixWorld);const Qt=q2.distanceTo(tt),Kt=ct.projectionMatrix.elements,de=zt.projectionMatrix.elements,Be=Kt[14]/(Kt[10]-1),me=Kt[14]/(Kt[10]+1),h0=(Kt[9]+1)/Kt[5],Dn=(Kt[9]-1)/Kt[5],We=(Kt[8]-1)/Kt[0],Y2=(de[8]+1)/de[0],Pn=Be*We,Ce=Be*Y2,Re=Qt/(-We+Y2),Me=Re*-We;ct.matrixWorld.decompose(X2.position,X2.quaternion,X2.scale),X2.translateX(Me),X2.translateZ(Re),X2.matrixWorld.compose(X2.position,X2.quaternion,X2.scale),X2.matrixWorldInverse.copy(X2.matrixWorld).invert();const p0=Be+Re,He=me+Re,be=Pn-Me,v0=Ce+(Qt-Me),pn=h0*me/He*p0,In=Dn*me/He*p0;X2.projectionMatrix.makePerspective(be,v0,pn,In,p0,He),X2.projectionMatrixInverse.copy(X2.projectionMatrix).invert()}function Ct(X2,ct){ct===null?X2.matrixWorld.copy(X2.matrix):X2.matrixWorld.multiplyMatrices(ct.matrixWorld,X2.matrix),X2.matrixWorldInverse.copy(X2.matrixWorld).invert()}this.updateCamera=function(X2){if(j===null)return;j2.near=b2.near=P2.near=X2.near,j2.far=b2.far=P2.far=X2.far,(J2!==j2.near||B2!==j2.far)&&(j.updateRenderState({depthNear:j2.near,depthFar:j2.far}),J2=j2.near,B2=j2.far);const ct=X2.parent,zt=j2.cameras;Ct(j2,ct);for(let Qt=0;Qt0&&(p2.alphaTest.value=o2.alphaTest);const x2=g.get(o2).envMap;if(x2&&(p2.envMap.value=x2,p2.flipEnvMap.value=x2.isCubeTexture&&x2.isRenderTargetTexture===!1?-1:1,p2.reflectivity.value=o2.reflectivity,p2.ior.value=o2.ior,p2.refractionRatio.value=o2.refractionRatio),o2.lightMap){p2.lightMap.value=o2.lightMap;const d2=F._useLegacyLights===!0?Math.PI:1;p2.lightMapIntensity.value=o2.lightMapIntensity*d2,S(o2.lightMap,p2.lightMapTransform)}o2.aoMap&&(p2.aoMap.value=o2.aoMap,p2.aoMapIntensity.value=o2.aoMapIntensity,S(o2.aoMap,p2.aoMapTransform))}function Y(p2,o2){p2.diffuse.value.copy(o2.color),p2.opacity.value=o2.opacity,o2.map&&(p2.map.value=o2.map,S(o2.map,p2.mapTransform))}function X(p2,o2){p2.dashSize.value=o2.dashSize,p2.totalSize.value=o2.dashSize+o2.gapSize,p2.scale.value=o2.scale}function $(p2,o2,x2,d2){p2.diffuse.value.copy(o2.color),p2.opacity.value=o2.opacity,p2.size.value=o2.size*x2,p2.scale.value=d2*.5,o2.map&&(p2.map.value=o2.map,S(o2.map,p2.uvTransform)),o2.alphaMap&&(p2.alphaMap.value=o2.alphaMap,S(o2.alphaMap,p2.alphaMapTransform)),o2.alphaTest>0&&(p2.alphaTest.value=o2.alphaTest)}function t2(p2,o2){p2.diffuse.value.copy(o2.color),p2.opacity.value=o2.opacity,p2.rotation.value=o2.rotation,o2.map&&(p2.map.value=o2.map,S(o2.map,p2.mapTransform)),o2.alphaMap&&(p2.alphaMap.value=o2.alphaMap,S(o2.alphaMap,p2.alphaMapTransform)),o2.alphaTest>0&&(p2.alphaTest.value=o2.alphaTest)}function n2(p2,o2){p2.specular.value.copy(o2.specular),p2.shininess.value=Math.max(o2.shininess,1e-4)}function s2(p2,o2){o2.gradientMap&&(p2.gradientMap.value=o2.gradientMap)}function m(p2,o2){p2.metalness.value=o2.metalness,o2.metalnessMap&&(p2.metalnessMap.value=o2.metalnessMap,S(o2.metalnessMap,p2.metalnessMapTransform)),p2.roughness.value=o2.roughness,o2.roughnessMap&&(p2.roughnessMap.value=o2.roughnessMap,S(o2.roughnessMap,p2.roughnessMapTransform)),g.get(o2).envMap&&(p2.envMapIntensity.value=o2.envMapIntensity)}function f2(p2,o2,x2){p2.ior.value=o2.ior,o2.sheen>0&&(p2.sheenColor.value.copy(o2.sheenColor).multiplyScalar(o2.sheen),p2.sheenRoughness.value=o2.sheenRoughness,o2.sheenColorMap&&(p2.sheenColorMap.value=o2.sheenColorMap,S(o2.sheenColorMap,p2.sheenColorMapTransform)),o2.sheenRoughnessMap&&(p2.sheenRoughnessMap.value=o2.sheenRoughnessMap,S(o2.sheenRoughnessMap,p2.sheenRoughnessMapTransform))),o2.clearcoat>0&&(p2.clearcoat.value=o2.clearcoat,p2.clearcoatRoughness.value=o2.clearcoatRoughness,o2.clearcoatMap&&(p2.clearcoatMap.value=o2.clearcoatMap,S(o2.clearcoatMap,p2.clearcoatMapTransform)),o2.clearcoatRoughnessMap&&(p2.clearcoatRoughnessMap.value=o2.clearcoatRoughnessMap,S(o2.clearcoatRoughnessMap,p2.clearcoatRoughnessMapTransform)),o2.clearcoatNormalMap&&(p2.clearcoatNormalMap.value=o2.clearcoatNormalMap,S(o2.clearcoatNormalMap,p2.clearcoatNormalMapTransform),p2.clearcoatNormalScale.value.copy(o2.clearcoatNormalScale),o2.side===Oi&&p2.clearcoatNormalScale.value.negate())),o2.iridescence>0&&(p2.iridescence.value=o2.iridescence,p2.iridescenceIOR.value=o2.iridescenceIOR,p2.iridescenceThicknessMinimum.value=o2.iridescenceThicknessRange[0],p2.iridescenceThicknessMaximum.value=o2.iridescenceThicknessRange[1],o2.iridescenceMap&&(p2.iridescenceMap.value=o2.iridescenceMap,S(o2.iridescenceMap,p2.iridescenceMapTransform)),o2.iridescenceThicknessMap&&(p2.iridescenceThicknessMap.value=o2.iridescenceThicknessMap,S(o2.iridescenceThicknessMap,p2.iridescenceThicknessMapTransform))),o2.transmission>0&&(p2.transmission.value=o2.transmission,p2.transmissionSamplerMap.value=x2.texture,p2.transmissionSamplerSize.value.set(x2.width,x2.height),o2.transmissionMap&&(p2.transmissionMap.value=o2.transmissionMap,S(o2.transmissionMap,p2.transmissionMapTransform)),p2.thickness.value=o2.thickness,o2.thicknessMap&&(p2.thicknessMap.value=o2.thicknessMap,S(o2.thicknessMap,p2.thicknessMapTransform)),p2.attenuationDistance.value=o2.attenuationDistance,p2.attenuationColor.value.copy(o2.attenuationColor)),o2.anisotropy>0&&(p2.anisotropyVector.value.set(o2.anisotropy*Math.cos(o2.anisotropyRotation),o2.anisotropy*Math.sin(o2.anisotropyRotation)),o2.anisotropyMap&&(p2.anisotropyMap.value=o2.anisotropyMap,S(o2.anisotropyMap,p2.anisotropyMapTransform))),p2.specularIntensity.value=o2.specularIntensity,p2.specularColor.value.copy(o2.specularColor),o2.specularColorMap&&(p2.specularColorMap.value=o2.specularColorMap,S(o2.specularColorMap,p2.specularColorMapTransform)),o2.specularIntensityMap&&(p2.specularIntensityMap.value=o2.specularIntensityMap,S(o2.specularIntensityMap,p2.specularIntensityMapTransform))}function a2(p2,o2){o2.matcap&&(p2.matcap.value=o2.matcap)}function A2(p2,o2){const x2=g.get(o2).light;p2.referencePosition.value.setFromMatrixPosition(x2.matrixWorld),p2.nearDistance.value=x2.shadow.camera.near,p2.farDistance.value=x2.shadow.camera.far}return{refreshFogUniforms:D,refreshMaterialUniforms:j}}function P82(F,g,S,D){let j={},U={},Y=[];const X=S.isWebGL2?F.getParameter(F.MAX_UNIFORM_BUFFER_BINDINGS):0;function $(x2,d2){const P2=d2.program;D.uniformBlockBinding(x2,P2)}function t2(x2,d2){let P2=j[x2.id];P2===void 0&&(a2(x2),P2=n2(x2),j[x2.id]=P2,x2.addEventListener("dispose",p2));const b2=d2.program;D.updateUBOMapping(x2,b2);const F2=g.render.frame;U[x2.id]!==F2&&(m(x2),U[x2.id]=F2)}function n2(x2){const d2=s2();x2.__bindingPointIndex=d2;const P2=F.createBuffer(),b2=x2.__size,F2=x2.usage;return F.bindBuffer(F.UNIFORM_BUFFER,P2),F.bufferData(F.UNIFORM_BUFFER,b2,F2),F.bindBuffer(F.UNIFORM_BUFFER,null),F.bindBufferBase(F.UNIFORM_BUFFER,d2,P2),P2}function s2(){for(let x2=0;x20){F2=P2%b2;const St=b2-F2;F2!==0&&St-T2.boundary<0&&(P2+=b2-F2,B2.__offset=P2)}P2+=T2.storage}return F2=P2%b2,F2>0&&(P2+=b2-F2),x2.__size=P2,x2.__cache={},this}function A2(x2){const d2={boundary:0,storage:0};return typeof x2=="number"?(d2.boundary=4,d2.storage=4):x2.isVector2?(d2.boundary=8,d2.storage=8):x2.isVector3||x2.isColor?(d2.boundary=16,d2.storage=12):x2.isVector4?(d2.boundary=16,d2.storage=16):x2.isMatrix3?(d2.boundary=48,d2.storage=48):x2.isMatrix4?(d2.boundary=64,d2.storage=64):x2.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x2),d2}function p2(x2){const d2=x2.target;d2.removeEventListener("dispose",p2);const P2=Y.indexOf(d2.__bindingPointIndex);Y.splice(P2,1),F.deleteBuffer(j[d2.id]),delete j[d2.id],delete U[d2.id]}function o2(){for(const x2 in j)F.deleteBuffer(j[x2]);Y=[],j={},U={}}return{bind:$,update:t2,dispose:o2}}function I82(){const F=Gu("canvas");return F.style.display="block",F}class vH{constructor(g={}){const{canvas:S=I82(),context:D=null,depth:j=!0,stencil:U=!0,alpha:Y=!1,antialias:X=!1,premultipliedAlpha:$=!0,preserveDrawingBuffer:t2=!1,powerPreference:n2="default",failIfMajorPerformanceCaveat:s2=!1}=g;this.isWebGLRenderer=!0;let m;D!==null?m=D.getContextAttributes().alpha:m=Y;const f2=new Uint32Array(4),a2=new Int32Array(4);let A2=null,p2=null;const o2=[],x2=[];this.domElement=S,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputColorSpace=qe,this._useLegacyLights=!1,this.toneMapping=R1,this.toneMappingExposure=1;const d2=this;let P2=!1,b2=0,F2=0,j2=null,J2=-1,B2=null;const T2=new Gn,ht=new Gn;let St=null;const q2=new f0(0);let tt=0,it=S.width,Ct=S.height,_t=1,mt=null,vt=null;const Bt=new Gn(0,0,it,Ct),X2=new Gn(0,0,it,Ct);let ct=!1;const zt=new P6;let Qt=!1,Kt=!1,de=null;const Be=new fn,me=new _e,h0=new L2,Dn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function We(){return j2===null?_t:1}let Y2=D;function Pn(C2,Q2){for(let ot=0;ot0?p2=x2[x2.length-1]:p2=null,o2.pop(),o2.length>0?A2=o2[o2.length-1]:A2=null};function B4(C2,Q2,ot,z2){if(C2.visible===!1)return;if(C2.layers.test(Q2.layers)){if(C2.isGroup)ot=C2.renderOrder;else if(C2.isLOD)C2.autoUpdate===!0&&C2.update(Q2);else if(C2.isLight)p2.pushLight(C2),C2.castShadow&&p2.pushShadow(C2);else if(C2.isSprite){if(!C2.frustumCulled||zt.intersectsSprite(C2)){z2&&h0.setFromMatrixPosition(C2.matrixWorld).applyMatrix4(Be);const ke=g2.update(C2),De=C2.material;De.visible&&A2.push(C2,ke,De,ot,h0.z,null)}}else if((C2.isMesh||C2.isLine||C2.isPoints)&&(!C2.frustumCulled||zt.intersectsObject(C2))){const ke=g2.update(C2),De=C2.material;if(z2&&(C2.boundingSphere!==void 0?(C2.boundingSphere===null&&C2.computeBoundingSphere(),h0.copy(C2.boundingSphere.center)):(ke.boundingSphere===null&&ke.computeBoundingSphere(),h0.copy(ke.boundingSphere.center)),h0.applyMatrix4(C2.matrixWorld).applyMatrix4(Be)),Array.isArray(De)){const Pe=ke.groups;for(let Ve=0,Ee=Pe.length;Ve0&&Qu(rt,te,Q2,ot),z2&&Me.viewport(T2.copy(z2)),rt.length>0&&I1(rt,Q2,ot),te.length>0&&I1(te,Q2,ot),ke.length>0&&I1(ke,Q2,ot),Me.buffers.depth.setTest(!0),Me.buffers.depth.setMask(!0),Me.buffers.color.setMask(!0),Me.setPolygonOffset(!1)}function Qu(C2,Q2,ot,z2){const rt=Re.isWebGL2;de===null&&(de=new us(1,1,{generateMipmaps:!0,type:Ce.has("EXT_color_buffer_half_float")?Ou:D1,minFilter:ju,samples:rt?4:0})),d2.getDrawingBufferSize(me),rt?de.setSize(me.x,me.y):de.setSize(w6(me.x),w6(me.y));const te=d2.getRenderTarget();d2.setRenderTarget(de),d2.getClearColor(q2),tt=d2.getClearAlpha(),tt<1&&d2.setClearColor(16777215,.5),d2.clear();const ke=d2.toneMapping;d2.toneMapping=R1,I1(C2,ot,z2),be.updateMultisampleRenderTarget(de),be.updateRenderTargetMipmap(de);let De=!1;for(let Pe=0,Ve=Q2.length;Pe0),Oe=!!ot.morphAttributes.position,L0=!!ot.morphAttributes.normal,U0=!!ot.morphAttributes.color;let li=R1;z2.toneMapped&&(j2===null||j2.isXRRenderTarget===!0)&&(li=d2.toneMapping);const or=ot.morphAttributes.position||ot.morphAttributes.normal||ot.morphAttributes.color,z0=or!==void 0?or.length:0,Ze=He.get(z2),ps=p2.state.lights;if(Qt===!0&&(Kt===!0||C2!==B2)){const Jn=C2===B2&&z2.id===J2;le.setState(z2,C2,Jn)}let V0=!1;z2.version===Ze.__version?(Ze.needsLights&&Ze.lightsStateVersion!==ps.state.version||Ze.outputColorSpace!==De||rt.isInstancedMesh&&Ze.instancing===!1||!rt.isInstancedMesh&&Ze.instancing===!0||rt.isSkinnedMesh&&Ze.skinning===!1||!rt.isSkinnedMesh&&Ze.skinning===!0||rt.isInstancedMesh&&Ze.instancingColor===!0&&rt.instanceColor===null||rt.isInstancedMesh&&Ze.instancingColor===!1&&rt.instanceColor!==null||Ze.envMap!==Pe||z2.fog===!0&&Ze.fog!==te||Ze.numClippingPlanes!==void 0&&(Ze.numClippingPlanes!==le.numPlanes||Ze.numIntersection!==le.numIntersection)||Ze.vertexAlphas!==Ve||Ze.vertexTangents!==Ee||Ze.morphTargets!==Oe||Ze.morphNormals!==L0||Ze.morphColors!==U0||Ze.toneMapping!==li||Re.isWebGL2===!0&&Ze.morphTargetsCount!==z0)&&(V0=!0):(V0=!0,Ze.__version=z2.version);let Jr=Ze.currentProgram;V0===!0&&(Jr=b1(z2,Q2,rt));let x4=!1,Jo=!1,_s=!1;const Fn=Jr.getUniforms(),Kr=Ze.uniforms;if(Me.useProgram(Jr.program)&&(x4=!0,Jo=!0,_s=!0),z2.id!==J2&&(J2=z2.id,Jo=!0),x4||B2!==C2){if(Fn.setValue(Y2,"projectionMatrix",C2.projectionMatrix),Re.logarithmicDepthBuffer&&Fn.setValue(Y2,"logDepthBufFC",2/(Math.log(C2.far+1)/Math.LN2)),B2!==C2&&(B2=C2,Jo=!0,_s=!0),z2.isShaderMaterial||z2.isMeshPhongMaterial||z2.isMeshToonMaterial||z2.isMeshStandardMaterial||z2.envMap){const Jn=Fn.map.cameraPosition;Jn!==void 0&&Jn.setValue(Y2,h0.setFromMatrixPosition(C2.matrixWorld))}(z2.isMeshPhongMaterial||z2.isMeshToonMaterial||z2.isMeshLambertMaterial||z2.isMeshBasicMaterial||z2.isMeshStandardMaterial||z2.isShaderMaterial)&&Fn.setValue(Y2,"isOrthographic",C2.isOrthographicCamera===!0),(z2.isMeshPhongMaterial||z2.isMeshToonMaterial||z2.isMeshLambertMaterial||z2.isMeshBasicMaterial||z2.isMeshStandardMaterial||z2.isShaderMaterial||z2.isShadowMaterial||rt.isSkinnedMesh)&&Fn.setValue(Y2,"viewMatrix",C2.matrixWorldInverse)}if(rt.isSkinnedMesh){Fn.setOptional(Y2,rt,"bindMatrix"),Fn.setOptional(Y2,rt,"bindMatrixInverse");const Jn=rt.skeleton;Jn&&(Re.floatVertexTextures?(Jn.boneTexture===null&&Jn.computeBoneTexture(),Fn.setValue(Y2,"boneTexture",Jn.boneTexture,be),Fn.setValue(Y2,"boneTextureSize",Jn.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}const cs=ot.morphAttributes;if((cs.position!==void 0||cs.normal!==void 0||cs.color!==void 0&&Re.isWebGL2===!0)&&ge.update(rt,ot,Jr),(Jo||Ze.receiveShadow!==rt.receiveShadow)&&(Ze.receiveShadow=rt.receiveShadow,Fn.setValue(Y2,"receiveShadow",rt.receiveShadow)),z2.isMeshGouraudMaterial&&z2.envMap!==null&&(Kr.envMap.value=Pe,Kr.flipEnvMap.value=Pe.isCubeTexture&&Pe.isRenderTargetTexture===!1?-1:1),Jo&&(Fn.setValue(Y2,"toneMappingExposure",d2.toneMappingExposure),Ze.needsLights&&Xu(Kr,_s),te&&z2.fog===!0&&Dt.refreshFogUniforms(Kr,te),Dt.refreshMaterialUniforms(Kr,z2,_t,Ct,de),up.upload(Y2,Ze.uniformsList,Kr,be)),z2.isShaderMaterial&&z2.uniformsNeedUpdate===!0&&(up.upload(Y2,Ze.uniformsList,Kr,be),z2.uniformsNeedUpdate=!1),z2.isSpriteMaterial&&Fn.setValue(Y2,"center",rt.center),Fn.setValue(Y2,"modelViewMatrix",rt.modelViewMatrix),Fn.setValue(Y2,"normalMatrix",rt.normalMatrix),Fn.setValue(Y2,"modelMatrix",rt.matrixWorld),z2.isShaderMaterial||z2.isRawShaderMaterial){const Jn=z2.uniformsGroups;for(let hs=0,Zu=Jn.length;hs0&&be.useMultisampledRTT(C2)===!1?rt=He.get(C2).__webglMultisampledFramebuffer:Array.isArray(Ee)?rt=Ee[ot]:rt=Ee,T2.copy(C2.viewport),ht.copy(C2.scissor),St=C2.scissorTest}else T2.copy(Bt).multiplyScalar(_t).floor(),ht.copy(X2).multiplyScalar(_t).floor(),St=ct;if(Me.bindFramebuffer(Y2.FRAMEBUFFER,rt)&&Re.drawBuffers&&z2&&Me.drawBuffers(C2,rt),Me.viewport(T2),Me.scissor(ht),Me.setScissorTest(St),te){const Pe=He.get(C2.texture);Y2.framebufferTexture2D(Y2.FRAMEBUFFER,Y2.COLOR_ATTACHMENT0,Y2.TEXTURE_CUBE_MAP_POSITIVE_X+Q2,Pe.__webglTexture,ot)}else if(ke){const Pe=He.get(C2.texture),Ve=Q2||0;Y2.framebufferTextureLayer(Y2.FRAMEBUFFER,Y2.COLOR_ATTACHMENT0,Pe.__webglTexture,ot||0,Ve)}J2=-1},this.readRenderTargetPixels=function(C2,Q2,ot,z2,rt,te,ke){if(!(C2&&C2.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let De=He.get(C2).__webglFramebuffer;if(C2.isWebGLCubeRenderTarget&&ke!==void 0&&(De=De[ke]),De){Me.bindFramebuffer(Y2.FRAMEBUFFER,De);try{const Pe=C2.texture,Ve=Pe.format,Ee=Pe.type;if(Ve!==Zr&&oe.convert(Ve)!==Y2.getParameter(Y2.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const Oe=Ee===Ou&&(Ce.has("EXT_color_buffer_half_float")||Re.isWebGL2&&Ce.has("EXT_color_buffer_float"));if(Ee!==D1&&oe.convert(Ee)!==Y2.getParameter(Y2.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Ee===E1&&(Re.isWebGL2||Ce.has("OES_texture_float")||Ce.has("WEBGL_color_buffer_float")))&&!Oe){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Q2>=0&&Q2<=C2.width-z2&&ot>=0&&ot<=C2.height-rt&&Y2.readPixels(Q2,ot,z2,rt,oe.convert(Ve),oe.convert(Ee),te)}finally{const Pe=j2!==null?He.get(j2).__webglFramebuffer:null;Me.bindFramebuffer(Y2.FRAMEBUFFER,Pe)}}},this.copyFramebufferToTexture=function(C2,Q2,ot=0){const z2=Math.pow(2,-ot),rt=Math.floor(Q2.image.width*z2),te=Math.floor(Q2.image.height*z2);be.setTexture2D(Q2,0),Y2.copyTexSubImage2D(Y2.TEXTURE_2D,ot,0,0,C2.x,C2.y,rt,te),Me.unbindTexture()},this.copyTextureToTexture=function(C2,Q2,ot,z2=0){const rt=Q2.image.width,te=Q2.image.height,ke=oe.convert(ot.format),De=oe.convert(ot.type);be.setTexture2D(ot,0),Y2.pixelStorei(Y2.UNPACK_FLIP_Y_WEBGL,ot.flipY),Y2.pixelStorei(Y2.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ot.premultiplyAlpha),Y2.pixelStorei(Y2.UNPACK_ALIGNMENT,ot.unpackAlignment),Q2.isDataTexture?Y2.texSubImage2D(Y2.TEXTURE_2D,z2,C2.x,C2.y,rt,te,ke,De,Q2.image.data):Q2.isCompressedTexture?Y2.compressedTexSubImage2D(Y2.TEXTURE_2D,z2,C2.x,C2.y,Q2.mipmaps[0].width,Q2.mipmaps[0].height,ke,Q2.mipmaps[0].data):Y2.texSubImage2D(Y2.TEXTURE_2D,z2,C2.x,C2.y,ke,De,Q2.image),z2===0&&ot.generateMipmaps&&Y2.generateMipmap(Y2.TEXTURE_2D),Me.unbindTexture()},this.copyTextureToTexture3D=function(C2,Q2,ot,z2,rt=0){if(d2.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const te=C2.max.x-C2.min.x+1,ke=C2.max.y-C2.min.y+1,De=C2.max.z-C2.min.z+1,Pe=oe.convert(z2.format),Ve=oe.convert(z2.type);let Ee;if(z2.isData3DTexture)be.setTexture3D(z2,0),Ee=Y2.TEXTURE_3D;else if(z2.isDataArrayTexture)be.setTexture2DArray(z2,0),Ee=Y2.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}Y2.pixelStorei(Y2.UNPACK_FLIP_Y_WEBGL,z2.flipY),Y2.pixelStorei(Y2.UNPACK_PREMULTIPLY_ALPHA_WEBGL,z2.premultiplyAlpha),Y2.pixelStorei(Y2.UNPACK_ALIGNMENT,z2.unpackAlignment);const Oe=Y2.getParameter(Y2.UNPACK_ROW_LENGTH),L0=Y2.getParameter(Y2.UNPACK_IMAGE_HEIGHT),U0=Y2.getParameter(Y2.UNPACK_SKIP_PIXELS),li=Y2.getParameter(Y2.UNPACK_SKIP_ROWS),or=Y2.getParameter(Y2.UNPACK_SKIP_IMAGES),z0=ot.isCompressedTexture?ot.mipmaps[0]:ot.image;Y2.pixelStorei(Y2.UNPACK_ROW_LENGTH,z0.width),Y2.pixelStorei(Y2.UNPACK_IMAGE_HEIGHT,z0.height),Y2.pixelStorei(Y2.UNPACK_SKIP_PIXELS,C2.min.x),Y2.pixelStorei(Y2.UNPACK_SKIP_ROWS,C2.min.y),Y2.pixelStorei(Y2.UNPACK_SKIP_IMAGES,C2.min.z),ot.isDataTexture||ot.isData3DTexture?Y2.texSubImage3D(Ee,rt,Q2.x,Q2.y,Q2.z,te,ke,De,Pe,Ve,z0.data):ot.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Y2.compressedTexSubImage3D(Ee,rt,Q2.x,Q2.y,Q2.z,te,ke,De,Pe,z0.data)):Y2.texSubImage3D(Ee,rt,Q2.x,Q2.y,Q2.z,te,ke,De,Pe,Ve,z0),Y2.pixelStorei(Y2.UNPACK_ROW_LENGTH,Oe),Y2.pixelStorei(Y2.UNPACK_IMAGE_HEIGHT,L0),Y2.pixelStorei(Y2.UNPACK_SKIP_PIXELS,U0),Y2.pixelStorei(Y2.UNPACK_SKIP_ROWS,li),Y2.pixelStorei(Y2.UNPACK_SKIP_IMAGES,or),rt===0&&z2.generateMipmaps&&Y2.generateMipmap(Ee),Me.unbindTexture()},this.initTexture=function(C2){C2.isCubeTexture?be.setTextureCube(C2,0):C2.isData3DTexture?be.setTexture3D(C2,0):C2.isDataArrayTexture||C2.isCompressedArrayTexture?be.setTexture2DArray(C2,0):be.setTexture2D(C2,0),Me.unbindTexture()},this.resetState=function(){b2=0,F2=0,j2=null,Me.reset(),se.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Zo}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(g){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!g}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===qe?os:eH}set outputEncoding(g){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=g===os?qe:go}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(g){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=g}}class b82 extends vH{}b82.prototype.isWebGL1Renderer=!0;class F82 extends Zn{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(g,S){return super.copy(g,S),g.background!==null&&(this.background=g.background.clone()),g.environment!==null&&(this.environment=g.environment.clone()),g.fog!==null&&(this.fog=g.fog.clone()),this.backgroundBlurriness=g.backgroundBlurriness,this.backgroundIntensity=g.backgroundIntensity,g.overrideMaterial!==null&&(this.overrideMaterial=g.overrideMaterial.clone()),this.matrixAutoUpdate=g.matrixAutoUpdate,this}toJSON(g){const S=super.toJSON(g);return this.fog!==null&&(S.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(S.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(S.object.backgroundIntensity=this.backgroundIntensity),S}}class BH extends fs{constructor(g){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new f0(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(g)}copy(g){return super.copy(g),this.color.copy(g.color),this.map=g.map,this.linewidth=g.linewidth,this.linecap=g.linecap,this.linejoin=g.linejoin,this.fog=g.fog,this}}const gW=new L2,kW=new L2,vW=new fn,_6=new uH,ip=new _p;class L82 extends Zn{constructor(g=new xr,S=new BH){super(),this.isLine=!0,this.type="Line",this.geometry=g,this.material=S,this.updateMorphTargets()}copy(g,S){return super.copy(g,S),this.material=g.material,this.geometry=g.geometry,this}computeLineDistances(){const g=this.geometry;if(g.index===null){const S=g.attributes.position,D=[0];for(let j=1,U=S.count;j$)continue;m.applyMatrix4(this.matrixWorld);const J2=g.ray.origin.distanceTo(m);J2g.far||S.push({distance:J2,point:s2.clone().applyMatrix4(this.matrixWorld),index:d2,face:null,faceIndex:null,object:this})}}else{const o2=Math.max(0,Y.start),x2=Math.min(p2.count,Y.start+Y.count);for(let d2=o2,P2=x2-1;d2$)continue;m.applyMatrix4(this.matrixWorld);const F2=g.ray.origin.distanceTo(m);F2g.far||S.push({distance:F2,point:s2.clone().applyMatrix4(this.matrixWorld),index:d2,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const S=this.geometry.morphAttributes,D=Object.keys(S);if(D.length>0){const j=S[D[0]];if(j!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let U=0,Y=j.length;U0)$=j-1;else{$=j;break}if(j=$,D[j]===Y)return j/(U-1);const n2=D[j],m=D[j+1]-n2,f2=(Y-n2)/m;return(j+f2)/(U-1)}getTangent(g,S){let j=g-1e-4,U=g+1e-4;j<0&&(j=0),U>1&&(U=1);const Y=this.getPoint(j),X=this.getPoint(U),$=S||(Y.isVector2?new _e:new L2);return $.copy(X).sub(Y).normalize(),$}getTangentAt(g,S){const D=this.getUtoTmapping(g);return this.getTangent(D,S)}computeFrenetFrames(g,S){const D=new L2,j=[],U=[],Y=[],X=new L2,$=new fn;for(let f2=0;f2<=g;f2++){const a2=f2/g;j[f2]=this.getTangentAt(a2,new L2)}U[0]=new L2,Y[0]=new L2;let t2=Number.MAX_VALUE;const n2=Math.abs(j[0].x),s2=Math.abs(j[0].y),m=Math.abs(j[0].z);n2<=t2&&(t2=n2,D.set(1,0,0)),s2<=t2&&(t2=s2,D.set(0,1,0)),m<=t2&&D.set(0,0,1),X.crossVectors(j[0],D).normalize(),U[0].crossVectors(j[0],X),Y[0].crossVectors(j[0],U[0]);for(let f2=1;f2<=g;f2++){if(U[f2]=U[f2-1].clone(),Y[f2]=Y[f2-1].clone(),X.crossVectors(j[f2-1],j[f2]),X.length()>Number.EPSILON){X.normalize();const a2=Math.acos(qn(j[f2-1].dot(j[f2]),-1,1));U[f2].applyMatrix4($.makeRotationAxis(X,a2))}Y[f2].crossVectors(j[f2],U[f2])}if(S===!0){let f2=Math.acos(qn(U[0].dot(U[g]),-1,1));f2/=g,j[0].dot(X.crossVectors(U[0],U[g]))>0&&(f2=-f2);for(let a2=1;a2<=g;a2++)U[a2].applyMatrix4($.makeRotationAxis(j[a2],f2*a2)),Y[a2].crossVectors(j[a2],U[a2])}return{tangents:j,normals:U,binormals:Y}}clone(){return new this.constructor().copy(this)}copy(g){return this.arcLengthDivisions=g.arcLengthDivisions,this}toJSON(){const g={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return g.arcLengthDivisions=this.arcLengthDivisions,g.type=this.type,g}fromJSON(g){return this.arcLengthDivisions=g.arcLengthDivisions,this}}class b6 extends ko{constructor(g=0,S=0,D=1,j=1,U=0,Y=Math.PI*2,X=!1,$=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=g,this.aY=S,this.xRadius=D,this.yRadius=j,this.aStartAngle=U,this.aEndAngle=Y,this.aClockwise=X,this.aRotation=$}getPoint(g,S){const D=S||new _e,j=Math.PI*2;let U=this.aEndAngle-this.aStartAngle;const Y=Math.abs(U)j;)U-=j;U0?0:(Math.floor(Math.abs(X)/U)+1)*U:$===0&&X===U-1&&(X=U-2,$=1);let t2,n2;this.closed||X>0?t2=j[(X-1)%U]:(rp.subVectors(j[0],j[1]).add(j[0]),t2=rp);const s2=j[X%U],m=j[(X+1)%U];if(this.closed||X+2j.length-2?j.length-1:Y+1],s2=j[Y>j.length-3?j.length-1:Y+2];return D.set(CW(X,$.x,t2.x,n2.x,s2.x),CW(X,$.y,t2.y,n2.y,s2.y)),D}copy(g){super.copy(g),this.points=[];for(let S=0,D=g.points.length;S=D){const Y=j[U]-D,X=this.curves[U],$=X.getLength(),t2=$===0?0:1-Y/$;return X.getPointAt(t2,S)}U++}return null}getLength(){const g=this.getCurveLengths();return g[g.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const g=[];let S=0;for(let D=0,j=this.curves.length;D1&&!S[S.length-1].equals(S[0])&&S.push(S[0]),S}copy(g){super.copy(g),this.curves=[];for(let S=0,D=g.curves.length;S0){const s2=t2.getPoint(0);s2.equals(this.currentPoint)||this.lineTo(s2.x,s2.y)}this.curves.push(t2);const n2=t2.getPoint(1);return this.currentPoint.copy(n2),this}copy(g){return super.copy(g),this.currentPoint.copy(g.currentPoint),this}toJSON(){const g=super.toJSON();return g.currentPoint=this.currentPoint.toArray(),g}fromJSON(g){return super.fromJSON(g),this.currentPoint.fromArray(g.currentPoint),this}}class j6 extends xr{constructor(g=[new _e(0,-.5),new _e(.5,0),new _e(0,.5)],S=12,D=0,j=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:g,segments:S,phiStart:D,phiLength:j},S=Math.floor(S),j=qn(j,0,Math.PI*2);const U=[],Y=[],X=[],$=[],t2=[],n2=1/S,s2=new L2,m=new _e,f2=new L2,a2=new L2,A2=new L2;let p2=0,o2=0;for(let x2=0;x2<=g.length-1;x2++)switch(x2){case 0:p2=g[x2+1].x-g[x2].x,o2=g[x2+1].y-g[x2].y,f2.x=o2*1,f2.y=-p2,f2.z=o2*0,A2.copy(f2),f2.normalize(),$.push(f2.x,f2.y,f2.z);break;case g.length-1:$.push(A2.x,A2.y,A2.z);break;default:p2=g[x2+1].x-g[x2].x,o2=g[x2+1].y-g[x2].y,f2.x=o2*1,f2.y=-p2,f2.z=o2*0,a2.copy(f2),f2.x+=A2.x,f2.y+=A2.y,f2.z+=A2.z,f2.normalize(),$.push(f2.x,f2.y,f2.z),A2.copy(a2)}for(let x2=0;x2<=S;x2++){const d2=D+x2*n2*j,P2=Math.sin(d2),b2=Math.cos(d2);for(let F2=0;F2<=g.length-1;F2++){s2.x=g[F2].x*P2,s2.y=g[F2].y,s2.z=g[F2].x*b2,Y.push(s2.x,s2.y,s2.z),m.x=x2/S,m.y=F2/(g.length-1),X.push(m.x,m.y);const j2=$[3*F2+0]*P2,J2=$[3*F2+1],B2=$[3*F2+0]*b2;t2.push(j2,J2,B2)}}for(let x2=0;x20&&d2(!0),S>0&&d2(!1)),this.setIndex(n2),this.setAttribute("position",new kn(s2,3)),this.setAttribute("normal",new kn(m,3)),this.setAttribute("uv",new kn(f2,2));function x2(){const P2=new L2,b2=new L2;let F2=0;const j2=(S-g)/D;for(let J2=0;J2<=U;J2++){const B2=[],T2=J2/U,ht=T2*(S-g)+g;for(let St=0;St<=j;St++){const q2=St/j,tt=q2*$+X,it=Math.sin(tt),Ct=Math.cos(tt);b2.x=ht*it,b2.y=-T2*D+p2,b2.z=ht*Ct,s2.push(b2.x,b2.y,b2.z),P2.set(it,j2,Ct).normalize(),m.push(P2.x,P2.y,P2.z),f2.push(q2,1-T2),B2.push(a2++)}A2.push(B2)}for(let J2=0;J20)&&f2.push(d2,P2,F2),(o2!==D-1||$"u"?Date:performance).now()}class RW extends j82{constructor(g=10,S=10,D=4473924,j=8947848){D=new f0(D),j=new f0(j);const U=S/2,Y=g/S,X=g/2,$=[],t2=[];for(let m=0,f2=0,a2=-X;m<=S;m++,a2+=Y){$.push(-X,0,a2,X,0,a2),$.push(a2,0,-X,a2,0,X);const A2=m===U?D:j;A2.toArray(t2,f2),f2+=3,A2.toArray(t2,f2),f2+=3,A2.toArray(t2,f2),f2+=3,A2.toArray(t2,f2),f2+=3}const n2=new xr;n2.setAttribute("position",new kn($,3)),n2.setAttribute("color",new kn(t2,3));const s2=new BH({vertexColors:!0,toneMapped:!1});super(n2,s2),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:E6}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=E6);const u62=.4,l62=2.5;class v4{constructor(g,S,D=1,j=1,U=.5,Y=16777215){wt(this,"position");wt(this,"size");wt(this,"mass");wt(this,"friction");wt(this,"color");wt(this,"id");wt(this,"scalingFactor",1);wt(this,"isPhysicsEnabled",!1);wt(this,"isDestructible",!1);wt(this,"mesh",new yi);wt(this,"rigidBody");this.position=g.clone(),this.size=D,this.mass=j,this.friction=U,this.color=Y,this.id=S}addPhysics(g){return this.isPhysicsEnabled?!1:(this.rigidBody=g,this.isPhysicsEnabled=!0,!0)}isAffectedByPhysics(){return this.isPhysicsEnabled}getFriction(){return this.friction}update(){!this.isAffectedByPhysics()||this.rigidBody===void 0||(M42(this.mesh,this.rigidBody),this.position.copy(this.mesh.position))}getRigidBody(){return this.rigidBody}setPosition(g){if(this.position.copy(g),this.mesh.position.copy(g),this.isAffectedByPhysics())throw"setPosition: objects with enabled physics cannot be repositioned"}getPosition(){return this.position.clone()}setColor(g){this.color=g,this.mesh.material.color.setHex(g)}getColor(){return this.color}getMesh(){return this.mesh}translateX(g){this.position.add(new L2(g,0,0)),this.mesh.translateX(g)}translateY(g){this.position.add(new L2(0,g,0)),this.mesh.translateY(g)}translateZ(g){this.position.add(new L2(0,0,g)),this.mesh.translateZ(g)}scale(g){this.scalingFactor+g>l62||this.scalingFactor+g(F[F.Box=0]="Box",F[F.HealthCheck=1]="HealthCheck",F[F.DeletetionRay=2]="DeletetionRay",F))(Uu||{});function m62(F){return(F+1)%(Object.keys(Uu).length/2)}function a62(F){return(F-1>=0?F-1:Object.keys(Uu).length/2-1)%(Object.keys(Uu).length/2)}function d6(F,g){const S=F.getPosition(),D=g.generateId();switch(F.getPayloadType()){case 0:{const j=new DW(S,D);return g.add(j),new LW(j)}case 1:{const j=new _4(S,D);return g.add(j),new A62(j)}case 2:{const j=new c4(F.getIndicatorPosition(),D,16711680,()=>g.getCameraPosition());return g.add(j),new d62(j)}default:{const j=new DW(S,D);return g.add(j),new LW(j)}}}class LW{constructor(g){wt(this,"payload");this.payload=g}activate(g){let S=zW(this.payload);this.payload.addPhysics(S),g.addPhysicsObject(S)}isPermanent(){return!0}getRepresentation(){return this.payload}}class A62{constructor(g){wt(this,"payload");this.payload=g}activate(g){g.startEarthquake(),g.remove(this.payload),this.payload.delete()}isPermanent(){return!1}getRepresentation(){return this.payload}}class d62{constructor(g){wt(this,"payload");this.payload=g}activate(g){let S=this.payload.getPosition();S.setY(-100);let D=g.rayHitObject(this.payload.getPosition(),S);D!==void 0&&D.getIsDestructible()&&(g.remove(D),D.delete()),g.remove(this.payload),this.payload.delete()}isPermanent(){return!1}getRepresentation(){return this.payload}}class W6{constructor(g,S){wt(this,"duration");wt(this,"startTime");wt(this,"remainingMs");wt(this,"isTimerRunning",!1);wt(this,"events",{});wt(this,"callbackFn");this.duration=g,this.remainingMs=g,this.startTime=new Date().getTime(),this.callbackFn=S}update(){this.isTimerRunning&&(this.remainingMs=this.remainingMs-(new Date().getTime()-this.startTime),Object.keys(this.events).forEach(g=>{let S=Number.parseInt(g);S{D(),S()}}else this.events[g]=S}getRemaining(){return this.remainingMs}getElapsed(){return this.duration-this.remainingMs}start(){this.startTime=new Date().getTime(),this.isTimerRunning=!0}isRunning(){return this.isTimerRunning}pause(){this.isTimerRunning=!1}}const $1=5,op=10,ji=class ji extends v4{constructor(S,D,j,U){super(S,U,2*$1,0,0,D);wt(this,"rayEnvironment");wt(this,"currentScore",0);wt(this,"material");wt(this,"heightScaling",1);this.rayEnvironment=j,this.material=new Vu({color:D,transparent:!0,opacity:.7,side:D42,alphaMap:ji.alpha}),this.mesh=new yi(ji.geometry,this.material),this.mesh.castShadow=!0,this.mesh.receiveShadow=!0,this.mesh.position.copy(this.position)}static init(){ji.geometry=new G6($1,$1,op,32,32,!0),ji.alpha=new Fu().load("area.png"),ji.alpha.magFilter=gn,ji.alpha.wrapS=Qr,ji.alpha.repeat.y=1,ji.alpha.repeat.x=3}delete(){this.material.dispose()}static cleanUp(){ji.geometry.dispose(),ji.alpha.dispose()}isAffectedByPhysics(){return!1}static staticUpdate(){}update(){this.heightScaling=Math.sin(new Date().getTime()*.001)*.3+1,this.mesh.position.set(this.position.x,this.position.y+op*this.heightScaling/2,this.position.z),this.mesh.scale.set(1,this.heightScaling,1);const S=1e3;let D=[$1,0,-$1],j=[];for(let Y=0;YY>=0&&Y<=S));U<0||U>S?this.currentScore=0:this.currentScore=S-U}setPosition(S){this.position.copy(S),this.mesh.position.set(this.position.x,this.position.y+op*this.heightScaling/2,this.position.z)}addPhysics(){return!1}getAabb(){return new L2($1*2,op,$1*2)}getHighscore(){return Math.round(this.currentScore)}getIsDestructible(){return!1}};wt(ji,"geometry"),wt(ji,"alpha");let Lu=ji;const y62=.005;class g62{constructor(g,S,D){wt(this,"startPosition");wt(this,"endPosition");wt(this,"timer");wt(this,"durationMs");wt(this,"current",new L2);this.startPosition=g,this.endPosition=S,this.durationMs=D,this.timer=new W6(D,()=>{})}start(){this.timer.start()}pause(){this.timer.pause()}isRunning(){return this.timer.isRunning()}getPosition(){return this.timer.update(),this.current.lerpVectors(this.startPosition,this.endPosition,this.timer.getElapsed()/this.durationMs),this.current.clone()}translate(g){this.startPosition.add(g),this.endPosition.add(g)}isTowards(g){return this.endPosition.distanceTo(g){const X=Y.getRepresentation();X.scale(S),X.isAffectedByPhysics()&&D(X.getRigidBody())}),(j=this.payload)==null||j.getRepresentation().scale(S),(U=this.payload)!=null&&U.getRepresentation().isAffectedByPhysics()&&D(this.payload.getRepresentation().getRigidBody())}translateX(S){var D;this.position.x+S>S62||this.position.x+Sw62||this.position.z+Sthis.stop()),this.ui=D(this.timer,()=>Object.values(this.highscores),E62,T62),this.playerConstructor=g,_4.init(),c4.init(),Lu.init(),Nu.init()}triggerHealtCheck(){this.world.startEarthquake(),this.ui.showPopup("Health Check!")}triggerDisruption(){this.world.startRotation(),this.ui.showPopup("Disruption!")}start(){this.timer.start()}stop(){this.ui.showGameOverScreen(Object.values(this.highscores).sort((g,S)=>g.getHighscore()-S.getHighscore())[0]),this.timer.pause()}getIsRunning(){return this.timer.isRunning()}isNewObjectMutable(){return Math.random()0?D.setPayloadType(m62(D.getPayloadType())):D.setPayloadType(a62(D.getPayloadType()));let U=d6(D,this.world);D.setPayload(U,this.isNewObjectMutable())}}hasPlayer(g){return Object.keys(this.players).includes(g)}getPlayer(g){return this.players[g]}activatePayload(g){if(this.getIsRunning()&&g!=""&&Object.keys(this.players).includes(g)){const S=this.players[g];if(S.getIsLocked())return;const D=S.releasePayload();D==null||D.activate(this.world),S.lock(),this.cooldownUntil[g]=new Date().getTime()+D62}}updateCooldowns(){const g=new Date().getTime();Object.keys(this.cooldownUntil).forEach(S=>{if(this.cooldownUntil[S]<=g&&this.players[S].getIsLocked()){this.players[S].unlock();const D=d6(this.players[S],this.world);this.players[S].setPayload(D,this.isNewObjectMutable())}})}update(){_4.staticUpdate(),c4.staticUpdate(),this.updateCooldowns(),this.world.update(),this.timer.update()}cleanUp(){_4.cleanup(),c4.cleanUp(),Lu.cleanUp(),Nu.cleanUp()}render(){this.world.render(),this.ui.render()}scalePlayer(g,S){this.getIsRunning()&&g!=""&&Object.keys(this.players).includes(g)&&this.players[g].scalePayload(S,D=>this.world.updateRigidBody(D))}debugRotation(){this.world.startRotation()}}const b62=3,F62=150,L62=15;class j62 extends v4{constructor(S,D,j=150){super(S,D,j,F62,b62);wt(this,"grid",new RW);const U=new zu(this.size,this.size);U.rotateX(-Math.PI/2);const Y=new Vu({color:this.color,opacity:1}),X=new yi(U,Y);X.position.copy(this.position),X.receiveShadow=!0,this.grid=new RW(this.size,L62),this.grid.position.copy(this.position),this.grid.material.transparent=!0,this.mesh=X,this.mesh.children.push(this.grid)}delete(){this.grid.dispose(),super.delete()}getIsDestructible(){return!1}getAabb(){return new L2(this.size,0,this.size)}}class O62{constructor(g,S){wt(this,"lastUpdateElapsed");wt(this,"rotationUnit");wt(this,"timer");this.rotationUnit=g/S,this.lastUpdateElapsed=0,this.timer=new W6(S,()=>{})}start(){this.timer.start()}getIsRunning(){return this.timer.isRunning()}getRotationStep(){if(!this.timer.isRunning())return 0;this.timer.update();let g=this.timer.getElapsed();const S=(g-this.lastUpdateElapsed)*this.rotationUnit;return this.lastUpdateElapsed=g,S}}const g6=150,G62=.1,U62=5,N62=500,W62=1e4,H62=70,z62=1,V62=new L2(0,15,150),Q62=1e3,Y62=-10,X62=10,q62=100,Z62=1e3,J62=-100,GW=10,K62=12578030,UW=0,NW=2048;class $62{constructor(g){wt(this,"camera");wt(this,"scene");wt(this,"light",new EW);wt(this,"renderer");wt(this,"physicsUniverse",{});wt(this,"bedrock");wt(this,"clock");wt(this,"objects",{});wt(this,"players",[]);wt(this,"objectCounter",0);wt(this,"currentId",0);wt(this,"sceneRotationMovement");this.camera=new rr(H62,window.innerWidth/window.innerHeight,z62,W62),this.scene=new F82,this.renderer=new vH({antialias:!0}),this.clock=new s62,this.initGraphicsUniverse(),this.initPhysicsUniverse(),this.initBedrock(g)}getCameraPosition(){let g=new L2;return this.camera.getWorldPosition(g),g}generateId(){let g=this.currentId;return this.currentId++,g}initBedrock(g){this.bedrock=new j62(new L2(0,g,0),this.generateId(),g6),this.bedrock.addPhysics(zW(this.bedrock)),this.add(this.bedrock);const S=g6/2,D=g6/2-U62,j=[-S,-S,+S,+S,+D,-D,+D,-D],U=[-D,+D,-D,+D,-S,-S,+S,+S],Y=new re.Ammo.btVector3(1,0,1),X=new re.Ammo.btVector3(0,0,0),n2=[0,2];for(let s2=0;s2{f2.enableSpring(a2,!0),f2.setStiffness(a2,N62),f2.setDamping(a2,G62)}),f2.setEquilibriumPoint(),this.physicsUniverse.addConstraint(f2,!1)}re.Ammo.destroy(Y),re.Ammo.destroy(X)}onWindowResize(){this.camera.aspect=window.innerWidth/window.innerHeight,this.camera.updateProjectionMatrix(),this.renderer.setSize(window.innerWidth,window.innerHeight)}initGraphicsUniverse(){this.camera.position.copy(V62),this.scene.background=new f0(K62),this.scene.add(new o62(16777215)),this.light=new EW(16777215,4.5),this.light.position.set(10,500,5),this.light.angle=Math.PI*.2,this.light.decay=0,this.light.castShadow=!0,this.light.shadow.camera.near=300,this.light.shadow.camera.far=600,this.light.shadow.bias=-222e-6,this.light.shadow.mapSize.width=NW,this.light.shadow.mapSize.height=NW,this.scene.add(this.light),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(window.innerWidth-UW,window.innerHeight-UW),this.renderer.shadowMap.enabled=!0,document.body.appendChild(this.renderer.domElement),window.addEventListener("resize",()=>this.onWindowResize())}initPhysicsUniverse(){let g=new re.Ammo.btDefaultCollisionConfiguration,S=new re.Ammo.btCollisionDispatcher(g),D=new re.Ammo.btDbvtBroadphase,j=new re.Ammo.btSequentialImpulseConstraintSolver;this.physicsUniverse=new re.Ammo.btDiscreteDynamicsWorld(S,D,j,g),re.auxVector3.setValue(0,Y62,0),this.physicsUniverse.setGravity(re.auxVector3)}startEarthquake(){var D;let g=Q62+this.objectCounter*50,S=(D=this.bedrock)==null?void 0:D.getRigidBody();S!==void 0&&(S.activate(),S.applyCentralImpulse(new re.Ammo.btVector3(g,0,0)),S.applyCentralImpulse(new re.Ammo.btVector3(0,0,g)))}update(){this.physicsUniverse.stepSimulation(this.clock.getDelta(),X62),Object.values(this.objects).forEach(g=>{g.update()}),this.sceneRotationMovement!==void 0&&this.sceneRotationMovement.getIsRunning()&&this.scene.rotateY(this.sceneRotationMovement.getRotationStep()),this.adjustPlayerHeights()}render(){this.renderer.render(this.scene,this.camera)}startRotation(){this.sceneRotationMovement=new O62(1.57,1e3),this.sceneRotationMovement.start()}adjustPlayerHeights(){let g=new re.Ammo.btVector3(0,0,0),S=new re.Ammo.btVector3(0,0,0);this.players.forEach(D=>{let U=D.getPointsForHeightTest().map(X=>{g.setValue(X.x,Z62,X.z),S.setValue(X.x,J62,X.z);let $=new re.Ammo.ClosestRayResultCallback(g,S);this.physicsUniverse.rayTest(g,S,$);let t2=0;return $.hasHit()&&(t2=$.get_m_hitPointWorld().y()+GW),re.Ammo.destroy($),t2}),Y=D.getPosition();D.moveToTarget(new L2(Y.x,Math.max(...U),Y.z),q62)}),re.Ammo.destroy(g),re.Ammo.destroy(S)}rayDistance(g,S){let D=-1,j=new re.Ammo.btVector3(g.x,g.y,g.z),U=new re.Ammo.btVector3(S.x,S.y,S.z),Y=new re.Ammo.ClosestRayResultCallback(j,U);return this.physicsUniverse.rayTest(j,U,Y),Y.hasHit()&&(D=g.distanceTo(new L2(Y.get_m_hitPointWorld().x(),Y.get_m_hitPointWorld().y(),Y.get_m_hitPointWorld().z()))),re.Ammo.destroy(j),re.Ammo.destroy(U),re.Ammo.destroy(Y),D}rayHitObject(g,S){let D,j=new re.Ammo.btVector3(g.x,g.y,g.z),U=new re.Ammo.btVector3(S.x,S.y,S.z),Y=new re.Ammo.ClosestRayResultCallback(j,U);if(this.physicsUniverse.rayTest(j,U,Y),Y.hasHit()){let X=Y.get_m_collisionObject();D=this.objects[X.getUserIndex()]}return re.Ammo.destroy(j),re.Ammo.destroy(U),re.Ammo.destroy(Y),D}updateRigidBody(g){this.physicsUniverse.removeRigidBody(g),this.physicsUniverse.addRigidBody(g)}add(g){this.scene.add(g.getMesh()),g.getMesh().children.forEach(S=>this.scene.add(S)),this.objects[String(g.getId())]=g,g.isAffectedByPhysics()&&this.addPhysicsObject(g.getRigidBody())}remove(g){this.scene.remove(g.getMesh()),g.getMesh().children.forEach(S=>this.scene.remove(S)),this.players.forEach(S=>{S.removePotentialChild(String(g.getId()))}),delete this.objects[String(g.getId())],g.isAffectedByPhysics()&&(this.objectCounter--,this.physicsUniverse.removeRigidBody(g.getRigidBody()))}addPhysicsObject(g){this.objectCounter++,this.physicsUniverse.addRigidBody(g)}addPlayer(g){this.players.push(g)}rotateX(g){this.scene.rotateX(g)}rotateY(g){this.scene.rotateY(g)}rotateZ(g){this.scene.rotateZ(g)}getPlayerOffset(){return GW}}const tc2="panel";class mp{constructor(g){wt(this,"target");wt(this,"isHidden",!0);this.target=document.createElement("div"),this.target.id=g,this.target.classList.add(tc2)}show(){this.isHidden&&document.body.append(this.target),this.isHidden=!1}hide(){this.isHidden||document.body.removeChild(this.target),this.isHidden=!0}render(){}}const ec2="counter";class nc2 extends mp{constructor(S,D){super(S);wt(this,"timeSupplier");this.timeSupplier=D,this.target.classList.add(ec2)}pad(S,D){let j=S.toString();for(;j.lengthU.getHighscore()-j.getHighscore()),S.forEach(j=>{let U=document.createElement("li");U.innerText=Math.round(j.getHighscore()).toString(),D.append(U)}),this.target.replaceChildren(D),this.target.insertBefore(this.heading,D)}}const uc2="overlay";class lc2 extends mp{constructor(S,D,j){super(S);wt(this,"message","");wt(this,"timer");wt(this,"visibleMs");this.timer=D,this.visibleMs=j,this.target.classList.add(uc2)}setMessage(S){this.message=S}show(){super.show(),this.timer.on(this.timer.getElapsed()+this.visibleMs,()=>{this.hide()})}render(){this.target.innerHTML=this.message}}class fc2{constructor(g){wt(this,"panels");wt(this,"renderInterval");wt(this,"lastRender");this.lastRender=new Date().getTime(),this.panels=[],this.renderInterval=g}render(){new Date().getTime()<=this.lastRender+this.renderInterval||(this.panels.forEach(g=>g.render()),this.lastRender=new Date().getTime())}add(g){this.panels.push(g)}}class pc2{constructor(g,S,D,j){wt(this,"timer");wt(this,"panels");wt(this,"overlay");this.timer=g,this.panels=new fc2(D);let U=new sc2("highscore",S);U.show(),this.panels.add(U);let Y=new nc2("countdown",()=>this.timer.getRemaining());Y.show(),this.panels.add(Y),this.overlay=new lc2("overlay",this.timer,j),this.panels.add(this.overlay)}render(){this.panels.render()}showGameOverScreen(g){let S=new rc2("game-over",()=>g);S.show(),this.panels.add(S)}showPopup(g){this.overlay.setMessage(g),this.overlay.show()}}const _c2=443,cc2="wss",hc2="42.scytec.de",sp=new v42(B42.connect(`${cc2}://${hc2}:${_c2}`));let Xn;(async()=>(re.Ammo=await HW.bind(window)(),re.initAuxObjects(),mc2()))();function mc2(){Xn=new I62((S,D,j,U,Y)=>new Nu(new L2(S,D,j),U,Y),S=>new $62(S),(S,D,j,U)=>new pc2(S,D,j,U)),sp.on("message",(S,D)=>{const j=D.toString(),[U,Y]=sp.parseTopic(S);switch(U){case Nr.Init:{if(Y!=""&&Xn.isPlayerAddable()){let $=Xn.addPlayer(Y).toString(16);for(;$.length<6;)$=`0${$}`;sp.publishClientSpecific(Nr.ColorResponse,Y,`#${$}`),Xn.getIsRunning()&&sp.publishClientSpecific(Nr.Start,Y,"")}break}case Nr.XMovement:{Xn.hasPlayer(Y)&&(Xn.getPlayer(Y).translateX(parseFloat(j)/10),console.log(new Date,j));break}case Nr.YMovement:{Xn.hasPlayer(Y);break}case Nr.ZMovement:{Xn.hasPlayer(Y)&&(Xn.getPlayer(Y).translateZ(parseFloat(j)/10),console.log(new Date,j));break}case Nr.Drop:{Xn.activatePayload(Y);break}case Nr.Scale:{Xn.scalePlayer(Y,parseFloat(j));break}case Nr.ColorResponse:break;case Nr.Start:{Xn.start();break}case Nr.RoatetPayload:{Xn.switchPlayerPayload(Y,parseInt(j));break}default:console.warn(`topic ${S} undefined`)}});function F(){document.body.addEventListener("keydown",S=>{switch(S.key){case"ArrowLeft":Xn.debugRotation();break;case"ArrowRight":Xn.triggerDisruption();break}})}function g(){requestAnimationFrame(g),Xn.update(),Xn.render()}F(),g()} diff --git a/controller.html b/controller.html index 5be5ab7..4e67624 100644 --- a/controller.html +++ b/controller.html @@ -5,7 +5,7 @@ Vite + TS - + diff --git a/index.html b/index.html index 31c50d1..2b2a1aa 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ Vite + TS - +