import"./aframe-forcegraph-component-B3vzsuem.js";import{i as lc,h as mr}from"./Paired-C4wB-ooD.js";import{p as uc,c as dc}from"./polished.esm-BeKV07fA.js";import"./three.module-Unazwo7z.js";import"./data-bind-mapper-D9QKwI5o.js";import"./_commonjsHelpers-Cpj98o6Y.js";const yr=.1;AFRAME.registerComponent("checkpoint-controls",{schema:{enabled:{default:!0},mode:{default:"teleport",oneOf:["teleport","animate"]},animateSpeed:{default:3}},init:function(){this.active=!0,this.checkpoint=null,this.isNavMeshConstrained=!1,this.offset=new THREE.Vector3,this.position=new THREE.Vector3,this.targetPosition=new THREE.Vector3},play:function(){this.active=!0},pause:function(){this.active=!1},setCheckpoint:function(r){const t=this.el;if(this.active&&this.checkpoint!==r){if(this.checkpoint&&t.emit("navigation-end",{checkpoint:this.checkpoint}),this.checkpoint=r,this.sync(),this.position.distanceTo(this.targetPosition)xe||Math.abs(i)>xe},getVelocityDelta:function(){const r=this._dpadVector,t=this._moveVector;this.getDpad(r),this.getJoystick(ce.MOVEMENT,t);const e=r.x||t.x,i=r.y||t.y,n=new THREE.Vector3;return Math.abs(e)>xe&&(n.x+=e),Math.abs(i)>xe&&(n.z+=i),n},isRotationActive:function(){if(!this.data.enabled||!this.isConnected())return!1;const r=this._lookVector;return this.getJoystick(ce.ROTATION,r),Math.abs(r.x)>xe||Math.abs(r.y)>xe},updateRotation:function(r){if(!this.isRotationActive())return;const t=this.data,e=this.yaw,i=this.pitch;e.rotation.y=this.el.object3D.rotation.y,i.rotation.x=this.el.object3D.rotation.x;const n=this._lookVector;this.getJoystick(ce.ROTATION,n),Math.abs(n.x)<=xe&&(n.x=0),Math.abs(n.y)<=xe&&(n.y=0),n.multiplyScalar(t.rotationSensitivity*r/1e3),e.rotation.y-=n.x,i.rotation.x-=n.y,i.rotation.x=Math.max(-Math.PI/2,Math.min(Math.PI/2,i.rotation.x)),this.el.object3D.rotation.set(i.rotation.x,e.rotation.y,0)},updateButtonState:function(){const r=this.getGamepad(ae.RIGHT);if(this.data.enabled&&r)for(var t=0;t1?ae.RIGHT:ae.LEFT).axes[r]},getJoystick:function(r,t){const e=this.getGamepad(r===ce.MOVEMENT?ae.LEFT:ae.RIGHT);if(!e)return t.set(0,0);if(e.mapping==="xr-standard")switch(r){case ce.MOVEMENT:return t.set(e.axes[2],e.axes[3]);case ce.ROTATION:return t.set(e.axes[2],0)}else switch(r){case ce.MOVEMENT:return t.set(e.axes[0],e.axes[1]);case ce.ROTATION:return t.set(e.axes[2],e.axes[3])}throw new Error('Unexpected joystick index "%d".',r)},getDpad:function(r){const t=this.getGamepad(ae.LEFT);return!t||!t.buttons[je.DPAD_RIGHT]?r.set(0,0):r.set((t.buttons[je.DPAD_RIGHT].pressed?1:0)+(t.buttons[je.DPAD_LEFT].pressed?-1:0),(t.buttons[je.DPAD_UP].pressed?-1:0)+(t.buttons[je.DPAD_DOWN].pressed?1:0))},isConnected:function(){const r=this.getGamepad(ae.LEFT);return!!(r&&r.connected)},getID:function(){return this.getGamepad(ae.LEFT).id}});(function(r){var t="KeyboardEvent"in r;t||(r.KeyboardEvent=function(){throw TypeError("Illegal constructor")}),"DOM_KEY_LOCATION_STANDARD"in r.KeyboardEvent||(r.KeyboardEvent.DOM_KEY_LOCATION_STANDARD=0),"DOM_KEY_LOCATION_LEFT"in r.KeyboardEvent||(r.KeyboardEvent.DOM_KEY_LOCATION_LEFT=1),"DOM_KEY_LOCATION_RIGHT"in r.KeyboardEvent||(r.KeyboardEvent.DOM_KEY_LOCATION_RIGHT=2),"DOM_KEY_LOCATION_NUMPAD"in r.KeyboardEvent||(r.KeyboardEvent.DOM_KEY_LOCATION_NUMPAD=3);var e=window.KeyboardEvent.DOM_KEY_LOCATION_STANDARD,i=window.KeyboardEvent.DOM_KEY_LOCATION_LEFT,n=window.KeyboardEvent.DOM_KEY_LOCATION_RIGHT,s=window.KeyboardEvent.DOM_KEY_LOCATION_NUMPAD;function o(_,z){return String(_).indexOf(z)!==-1}var a=function(){return o(navigator.platform,"Win")?"win":o(navigator.platform,"Mac")?"mac":o(navigator.platform,"CrOS")?"cros":o(navigator.platform,"Linux")?"linux":o(navigator.userAgent,"iPad")||o(navigator.platform,"iPod")||o(navigator.platform,"iPhone")?"ios":""}(),c=function(){return o(navigator.userAgent,"Chrome/")?"chrome":o(navigator.vendor,"Apple")?"safari":o(navigator.userAgent,"MSIE")?"ie":o(navigator.userAgent,"Gecko/")?"moz":o(navigator.userAgent,"Opera/")?"opera":""}(),h=c+"-"+a;function l(_,z,F){(h===z||c===z||a===z)&&Object.keys(F).forEach(function(R){_[R]=F[R]})}function u(_,z){var F={};return Object.keys(_).forEach(function(R){var L=_[R];z in L&&(F[L[z]]=L)}),F}var d={3:{code:"Cancel"},6:{code:"Help"},8:{code:"Backspace"},9:{code:"Tab"},12:{code:"Clear"},13:{code:"Enter"},16:{code:"Shift"},17:{code:"Control"},18:{code:"Alt"},19:{code:"Pause"},20:{code:"CapsLock"},21:{code:"KanaMode"},22:{code:"HangulMode"},23:{code:"JunjaMode"},24:{code:"FinalMode"},25:{code:"KanjiMode"},27:{code:"Escape"},28:{code:"Convert"},29:{code:"NonConvert"},30:{code:"Accept"},31:{code:"ModeChange"},32:{code:"Space"},33:{code:"PageUp"},34:{code:"PageDown"},35:{code:"End"},36:{code:"Home"},37:{code:"ArrowLeft"},38:{code:"ArrowUp"},39:{code:"ArrowRight"},40:{code:"ArrowDown"},41:{code:"Select"},42:{code:"Print"},43:{code:"Execute"},44:{code:"PrintScreen"},45:{code:"Insert"},46:{code:"Delete"},47:{code:"Help"},48:{code:"Digit0",keyCap:"0"},49:{code:"Digit1",keyCap:"1"},50:{code:"Digit2",keyCap:"2"},51:{code:"Digit3",keyCap:"3"},52:{code:"Digit4",keyCap:"4"},53:{code:"Digit5",keyCap:"5"},54:{code:"Digit6",keyCap:"6"},55:{code:"Digit7",keyCap:"7"},56:{code:"Digit8",keyCap:"8"},57:{code:"Digit9",keyCap:"9"},65:{code:"KeyA",keyCap:"a"},66:{code:"KeyB",keyCap:"b"},67:{code:"KeyC",keyCap:"c"},68:{code:"KeyD",keyCap:"d"},69:{code:"KeyE",keyCap:"e"},70:{code:"KeyF",keyCap:"f"},71:{code:"KeyG",keyCap:"g"},72:{code:"KeyH",keyCap:"h"},73:{code:"KeyI",keyCap:"i"},74:{code:"KeyJ",keyCap:"j"},75:{code:"KeyK",keyCap:"k"},76:{code:"KeyL",keyCap:"l"},77:{code:"KeyM",keyCap:"m"},78:{code:"KeyN",keyCap:"n"},79:{code:"KeyO",keyCap:"o"},80:{code:"KeyP",keyCap:"p"},81:{code:"KeyQ",keyCap:"q"},82:{code:"KeyR",keyCap:"r"},83:{code:"KeyS",keyCap:"s"},84:{code:"KeyT",keyCap:"t"},85:{code:"KeyU",keyCap:"u"},86:{code:"KeyV",keyCap:"v"},87:{code:"KeyW",keyCap:"w"},88:{code:"KeyX",keyCap:"x"},89:{code:"KeyY",keyCap:"y"},90:{code:"KeyZ",keyCap:"z"},91:{code:"OSLeft",location:i},92:{code:"OSRight",location:n},93:{code:"ContextMenu"},95:{code:"Standby"},96:{code:"Numpad0",keyCap:"0",location:s},97:{code:"Numpad1",keyCap:"1",location:s},98:{code:"Numpad2",keyCap:"2",location:s},99:{code:"Numpad3",keyCap:"3",location:s},100:{code:"Numpad4",keyCap:"4",location:s},101:{code:"Numpad5",keyCap:"5",location:s},102:{code:"Numpad6",keyCap:"6",location:s},103:{code:"Numpad7",keyCap:"7",location:s},104:{code:"Numpad8",keyCap:"8",location:s},105:{code:"Numpad9",keyCap:"9",location:s},106:{code:"NumpadMultiply",keyCap:"*",location:s},107:{code:"NumpadAdd",keyCap:"+",location:s},108:{code:"NumpadComma",keyCap:",",location:s},109:{code:"NumpadSubtract",keyCap:"-",location:s},110:{code:"NumpadDecimal",keyCap:".",location:s},111:{code:"NumpadDivide",keyCap:"/",location:s},112:{code:"F1"},113:{code:"F2"},114:{code:"F3"},115:{code:"F4"},116:{code:"F5"},117:{code:"F6"},118:{code:"F7"},119:{code:"F8"},120:{code:"F9"},121:{code:"F10"},122:{code:"F11"},123:{code:"F12"},124:{code:"F13"},125:{code:"F14"},126:{code:"F15"},127:{code:"F16"},128:{code:"F17"},129:{code:"F18"},130:{code:"F19"},131:{code:"F20"},132:{code:"F21"},133:{code:"F22"},134:{code:"F23"},135:{code:"F24"},144:{code:"NumLock",location:s},145:{code:"ScrollLock"},160:{code:"ShiftLeft",location:i},161:{code:"ShiftRight",location:n},162:{code:"ControlLeft",location:i},163:{code:"ControlRight",location:n},164:{code:"AltLeft",location:i},165:{code:"AltRight",location:n},166:{code:"BrowserBack"},167:{code:"BrowserForward"},168:{code:"BrowserRefresh"},169:{code:"BrowserStop"},170:{code:"BrowserSearch"},171:{code:"BrowserFavorites"},172:{code:"BrowserHome"},173:{code:"VolumeMute"},174:{code:"VolumeDown"},175:{code:"VolumeUp"},176:{code:"MediaTrackNext"},177:{code:"MediaTrackPrevious"},178:{code:"MediaStop"},179:{code:"MediaPlayPause"},180:{code:"LaunchMail"},181:{code:"MediaSelect"},182:{code:"LaunchApp1"},183:{code:"LaunchApp2"},186:{code:"Semicolon",keyCap:";"},187:{code:"Equal",keyCap:"="},188:{code:"Comma",keyCap:","},189:{code:"Minus",keyCap:"-"},190:{code:"Period",keyCap:"."},191:{code:"Slash",keyCap:"/"},192:{code:"Backquote",keyCap:"`"},219:{code:"BracketLeft",keyCap:"["},220:{code:"Backslash",keyCap:"\\"},221:{code:"BracketRight",keyCap:"]"},222:{code:"Quote",keyCap:"'"},226:{code:"IntlBackslash",keyCap:"\\"},229:{code:"Process"},246:{code:"Attn"},247:{code:"CrSel"},248:{code:"ExSel"},249:{code:"EraseEof"},250:{code:"Play"},251:{code:"ZoomToggle"},254:{code:"Clear"}};l(d,"moz",{59:{code:"Semicolon",keyCap:";"},61:{code:"Equal",keyCap:"="},107:{code:"Equal",keyCap:"="},109:{code:"Minus",keyCap:"-"},187:{code:"NumpadAdd",keyCap:"+",location:s},189:{code:"NumpadSubtract",keyCap:"-",location:s}}),l(d,"moz-mac",{12:{code:"NumLock",location:s},173:{code:"Minus",keyCap:"-"}}),l(d,"moz-win",{173:{code:"Minus",keyCap:"-"}}),l(d,"chrome-mac",{93:{code:"OSRight",location:n}}),l(d,"safari",{3:{code:"Enter"},25:{code:"Tab"}}),l(d,"ios",{10:{code:"Enter",location:e}}),l(d,"safari-mac",{91:{code:"OSLeft",location:i},93:{code:"OSRight",location:n},229:{code:"KeyQ",keyCap:"Q"}});var p={};a==="cros"&&(p["U+00A0"]={code:"ShiftLeft",location:i},p["U+00A1"]={code:"ShiftRight",location:n},p["U+00A2"]={code:"ControlLeft",location:i},p["U+00A3"]={code:"ControlRight",location:n},p["U+00A4"]={code:"AltLeft",location:i},p["U+00A5"]={code:"AltRight",location:n}),h==="chrome-mac"&&(p["U+0010"]={code:"ContextMenu"}),h==="safari-mac"&&(p["U+0010"]={code:"ContextMenu"}),a==="ios"&&(p["U+0010"]={code:"Function"},p["U+001C"]={code:"ArrowLeft"},p["U+001D"]={code:"ArrowRight"},p["U+001E"]={code:"ArrowUp"},p["U+001F"]={code:"ArrowDown"},p["U+0001"]={code:"Home"},p["U+0004"]={code:"End"},p["U+000B"]={code:"PageUp"},p["U+000C"]={code:"PageDown"});var y=[];y[i]={16:{code:"ShiftLeft",location:i},17:{code:"ControlLeft",location:i},18:{code:"AltLeft",location:i}},y[n]={16:{code:"ShiftRight",location:n},17:{code:"ControlRight",location:n},18:{code:"AltRight",location:n}},y[s]={13:{code:"NumpadEnter",location:s}},l(y[s],"moz",{109:{code:"NumpadSubtract",location:s},107:{code:"NumpadAdd",location:s}}),l(y[i],"moz-mac",{224:{code:"OSLeft",location:i}}),l(y[n],"moz-mac",{224:{code:"OSRight",location:n}}),l(y[n],"moz-win",{91:{code:"OSRight",location:n}}),l(y[n],"mac",{93:{code:"OSRight",location:n}}),l(y[s],"chrome-mac",{12:{code:"NumLock",location:s}}),l(y[s],"safari-mac",{12:{code:"NumLock",location:s},187:{code:"NumpadAdd",location:s},189:{code:"NumpadSubtract",location:s},190:{code:"NumpadDecimal",location:s},191:{code:"NumpadDivide",location:s}});var w={ShiftLeft:{key:"Shift"},ShiftRight:{key:"Shift"},ControlLeft:{key:"Control"},ControlRight:{key:"Control"},AltLeft:{key:"Alt"},AltRight:{key:"Alt"},OSLeft:{key:"OS"},OSRight:{key:"OS"},NumpadEnter:{key:"Enter"},Space:{key:" "},Digit0:{key:"0",shiftKey:")"},Digit1:{key:"1",shiftKey:"!"},Digit2:{key:"2",shiftKey:"@"},Digit3:{key:"3",shiftKey:"#"},Digit4:{key:"4",shiftKey:"$"},Digit5:{key:"5",shiftKey:"%"},Digit6:{key:"6",shiftKey:"^"},Digit7:{key:"7",shiftKey:"&"},Digit8:{key:"8",shiftKey:"*"},Digit9:{key:"9",shiftKey:"("},KeyA:{key:"a",shiftKey:"A"},KeyB:{key:"b",shiftKey:"B"},KeyC:{key:"c",shiftKey:"C"},KeyD:{key:"d",shiftKey:"D"},KeyE:{key:"e",shiftKey:"E"},KeyF:{key:"f",shiftKey:"F"},KeyG:{key:"g",shiftKey:"G"},KeyH:{key:"h",shiftKey:"H"},KeyI:{key:"i",shiftKey:"I"},KeyJ:{key:"j",shiftKey:"J"},KeyK:{key:"k",shiftKey:"K"},KeyL:{key:"l",shiftKey:"L"},KeyM:{key:"m",shiftKey:"M"},KeyN:{key:"n",shiftKey:"N"},KeyO:{key:"o",shiftKey:"O"},KeyP:{key:"p",shiftKey:"P"},KeyQ:{key:"q",shiftKey:"Q"},KeyR:{key:"r",shiftKey:"R"},KeyS:{key:"s",shiftKey:"S"},KeyT:{key:"t",shiftKey:"T"},KeyU:{key:"u",shiftKey:"U"},KeyV:{key:"v",shiftKey:"V"},KeyW:{key:"w",shiftKey:"W"},KeyX:{key:"x",shiftKey:"X"},KeyY:{key:"y",shiftKey:"Y"},KeyZ:{key:"z",shiftKey:"Z"},Numpad0:{key:"0"},Numpad1:{key:"1"},Numpad2:{key:"2"},Numpad3:{key:"3"},Numpad4:{key:"4"},Numpad5:{key:"5"},Numpad6:{key:"6"},Numpad7:{key:"7"},Numpad8:{key:"8"},Numpad9:{key:"9"},NumpadMultiply:{key:"*"},NumpadAdd:{key:"+"},NumpadComma:{key:","},NumpadSubtract:{key:"-"},NumpadDecimal:{key:"."},NumpadDivide:{key:"/"},Semicolon:{key:";",shiftKey:":"},Equal:{key:"=",shiftKey:"+"},Comma:{key:",",shiftKey:"<"},Minus:{key:"-",shiftKey:"_"},Period:{key:".",shiftKey:">"},Slash:{key:"/",shiftKey:"?"},Backquote:{key:"`",shiftKey:"~"},BracketLeft:{key:"[",shiftKey:"{"},Backslash:{key:"\\",shiftKey:"|"},BracketRight:{key:"]",shiftKey:"}"},Quote:{key:"'",shiftKey:'"'},IntlBackslash:{key:"\\",shiftKey:"|"}};l(w,"mac",{OSLeft:{key:"Meta"},OSRight:{key:"Meta"}});var v={Esc:"Escape",Nonconvert:"NonConvert",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Menu:"ContextMenu",MediaNextTrack:"MediaTrackNext",MediaPreviousTrack:"MediaTrackPrevious",SelectMedia:"MediaSelect",HalfWidth:"Hankaku",FullWidth:"Zenkaku",RomanCharacters:"Romaji",Crsel:"CrSel",Exsel:"ExSel",Zoom:"ZoomToggle"},k=u(d,"code");try{var C=t&&"location"in new KeyboardEvent("")}catch{}function A(_){var z="keyCode"in _?_.keyCode:"which"in _?_.which:0,F=function(){if(C||"keyLocation"in _){var L=C?_.location:_.keyLocation;if(L&&z in y[L])return y[L][z]}return"keyIdentifier"in _&&_.keyIdentifier in p?p[_.keyIdentifier]:z in d?d[z]:null}();if(!F)return null;var R=function(){var L=w[F.code];return L?_.shiftKey&&"shiftKey"in L?L.shiftKey:L.key:F.code}();return{code:F.code,key:R,location:F.location,keyCap:F.keyCap}}function T(_,z){if(_=String(_),!k.hasOwnProperty(_))return"Undefined";if(z&&String(z).toLowerCase()!=="en-us")throw Error("Unsupported locale");var F=k[_];return F.keyCap||F.code||"Undefined"}"KeyboardEvent"in r&&"defineProperty"in Object&&function(){function _(F,R,L){R in F||Object.defineProperty(F,R,L)}if(_(KeyboardEvent.prototype,"code",{get:function(){var F=A(this);return F?F.code:""}}),"key"in KeyboardEvent.prototype){var z=Object.getOwnPropertyDescriptor(KeyboardEvent.prototype,"key");Object.defineProperty(KeyboardEvent.prototype,"key",{get:function(){var F=z.get.call(this);return v.hasOwnProperty(F)?v[F]:F}})}_(KeyboardEvent.prototype,"key",{get:function(){var F=A(this);return F&&"key"in F?F.key:"Unidentified"}}),_(KeyboardEvent.prototype,"location",{get:function(){var F=A(this);return F&&"location"in F?F.location:e}}),_(KeyboardEvent.prototype,"locale",{get:function(){return""}})}(),"queryKeyCap"in r.KeyboardEvent||(r.KeyboardEvent.queryKeyCap=T),r.identifyKey=function(_){if(!("code"in _)){var z=A(_);_.code=z?z.code:"",_.key=z&&"key"in z?z.key:"Unidentified",_.location="location"in _?_.location:"keyLocation"in _?_.keyLocation:z&&"location"in z?z.location:e,_.locale=""}}})(window);const pc="__keyboard-controls-proxy",fc=window.KeyboardEvent;AFRAME.registerComponent("keyboard-controls",{schema:{enabled:{default:!0},debug:{default:!1}},init:function(){this.dVelocity=new THREE.Vector3,this.localKeys={},this.listeners={keydown:this.onKeyDown.bind(this),keyup:this.onKeyUp.bind(this),blur:this.onBlur.bind(this),onContextMenu:this.onContextMenu.bind(this)}},isVelocityActive:function(){return this.data.enabled&&!!Object.keys(this.getKeys()).length},getVelocityDelta:function(){const r=this.data,t=this.getKeys();return this.dVelocity.set(0,0,0),r.enabled&&((t.KeyW||t.ArrowUp)&&(this.dVelocity.z-=1),(t.KeyA||t.ArrowLeft)&&(this.dVelocity.x-=1),(t.KeyS||t.ArrowDown)&&(this.dVelocity.z+=1),(t.KeyD||t.ArrowRight)&&(this.dVelocity.x+=1),t.ShiftLeft&&(this.dVelocity=this.dVelocity.multiplyScalar(2))),this.dVelocity.clone()},play:function(){this.attachEventListeners()},pause:function(){this.removeEventListeners()},attachEventListeners:function(){window.addEventListener("contextmenu",this.listeners.onContextMenu,!1),window.addEventListener("keydown",this.listeners.keydown,!1),window.addEventListener("keyup",this.listeners.keyup,!1),window.addEventListener("blur",this.listeners.blur,!1)},onContextMenu:function(){for(const r in this.localKeys)this.localKeys.hasOwnProperty(r)&&delete this.localKeys[r]},removeEventListeners:function(){window.removeEventListener("keydown",this.listeners.keydown),window.removeEventListener("keyup",this.listeners.keyup),window.removeEventListener("blur",this.listeners.blur)},onKeyDown:function(r){AFRAME.utils.shouldCaptureKeyEvent(r)&&(this.localKeys[r.code]=!0,this.emit(r))},onKeyUp:function(r){AFRAME.utils.shouldCaptureKeyEvent(r)&&(delete this.localKeys[r.code],this.emit(r))},onBlur:function(){for(const r in this.localKeys)this.localKeys.hasOwnProperty(r)&&delete this.localKeys[r]},emit:function(r){pc in r&&this.el.emit(r.type,r),this.el.emit(r.type+":"+r.code,new fc(r.type,r)),this.data.debug&&console.log(r.type+":"+r.code)},isPressed:function(r){return r in this.getKeys()},getKeys:function(){return this.isProxied()?this.el.sceneEl.components["proxy-controls"].getKeyboard():this.localKeys},isProxied:function(){const r=this.el.sceneEl.components["proxy-controls"];return r&&r.isConnected()}});AFRAME.registerComponent("touch-controls",{schema:{enabled:{default:!0},reverseEnabled:{default:!0}},init:function(){this.dVelocity=new THREE.Vector3,this.bindMethods(),this.direction=0},play:function(){this.addEventListeners()},pause:function(){this.removeEventListeners(),this.dVelocity.set(0,0,0)},remove:function(){this.pause()},addEventListeners:function(){const r=this.el.sceneEl,t=r.canvas;if(!t){r.addEventListener("render-target-loaded",this.addEventListeners.bind(this));return}t.addEventListener("touchstart",this.onTouchStart,{passive:!0}),t.addEventListener("touchend",this.onTouchEnd,{passive:!0});const e=r.getAttribute("vr-mode-ui");e&&e.cardboardModeEnabled&&r.addEventListener("enter-vr",this.onEnterVR)},removeEventListeners:function(){const r=this.el.sceneEl&&this.el.sceneEl.canvas;r&&(r.removeEventListener("touchstart",this.onTouchStart),r.removeEventListener("touchend",this.onTouchEnd),this.el.sceneEl.removeEventListener("enter-vr",this.onEnterVR))},isVelocityActive:function(){return this.data.enabled&&!!this.direction},getVelocityDelta:function(){return this.dVelocity.z=this.direction,this.dVelocity.clone()},bindMethods:function(){this.onTouchStart=this.onTouchStart.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this),this.onEnterVR=this.onEnterVR.bind(this)},onTouchStart:function(r){this.direction=-1,this.data.reverseEnabled&&r.touches&&r.touches.length===2&&(this.direction=1),r.preventDefault()},onTouchEnd:function(r){this.direction=0,r.preventDefault()},onEnterVR:function(){const r=this.el.sceneEl.xrSession;r&&(r.addEventListener("selectstart",this.onTouchStart),r.addEventListener("selectend",this.onTouchEnd))}});const Vn="-controls",mc=.2,yc=1e-5,gc="moved";AFRAME.registerComponent("movement-controls",{dependencies:["rotation"],schema:{enabled:{default:!0},controls:{default:["gamepad","trackpad","keyboard","touch"]},speed:{default:.3,min:0},fly:{default:!1},constrainToNavMesh:{default:!1},camera:{default:"[movement-controls] [camera]",type:"selector"}},init:function(){const r=this.el;this.data.camera||(this.data.camera=r.querySelector("[camera]")),this.velocityCtrl=null,this.velocity=new THREE.Vector3,this.heading=new THREE.Quaternion,this.eventDetail={},this.navGroup=null,this.navNode=null,r.sceneEl.hasLoaded?this.injectControls():r.sceneEl.addEventListener("loaded",this.injectControls.bind(this))},update:function(r){const t=this.el,e=this.data,i=t.sceneEl.systems.nav;if(t.sceneEl.hasLoaded&&this.injectControls(),i&&e.constrainToNavMesh!==r.constrainToNavMesh&&(e.constrainToNavMesh?i.addAgent(this):i.removeAgent(this)),e.enabled!==r.enabled)for(let n=0;nmc?h.set(0,0,0):this.updateVelocity(s),a.constrainToNavMesh&&(!c&&l||c.isNavMeshConstrained!==!1)){if(h.lengthSq()0){let i=0,n=0;t.enableNegX&&e[0]this.startingAxisData[0]&&(i=1),t.enablePosZ&&e[1]>this.startingAxisData[1]&&(n=-1),t.enableNegZ&&e[1]s?(this.zVel=0,this.xVel=i,this.isMoving=!0):(this.xVel=0,this.zVel=n,this.isMoving=!0)}},handleTouchAxis:function(r){const t=this.data,e=r.detail.axis;let i=0,n=0;t.enableNegX&&e[0]<0&&(i=-1),t.enablePosX&&e[0]>0&&(i=1),t.enablePosZ&&e[1]>0&&(n=-1),t.enableNegZ&&e[1]<0&&(n=1),Math.abs(e[0])>Math.abs(e[1])?(this.zVel=0,this.xVel=i):(this.xVel=0,this.zVel=n)}});const mn=(r,t)=>{const e=t.x-r.x,i=t.y-r.y;return Math.sqrt(e*e+i*i)},xc=(r,t)=>{const e=t.x-r.x,i=t.y-r.y;return wc(Math.atan2(i,e))},bc=(r,t,e)=>{const i={x:0,y:0};return e=ws(e),i.x=r.x-t*Math.cos(e),i.y=r.y-t*Math.sin(e),i},ws=r=>r*(Math.PI/180),wc=r=>r*(180/Math.PI),vc=r=>isNaN(r.buttons)?r.pressure!==0:r.buttons!==0,jn=new Map,gr=r=>{jn.has(r)&&clearTimeout(jn.get(r)),jn.set(r,setTimeout(r,100))},gn=(r,t,e)=>{const i=t.split(/[ ,]+/g);let n;for(let s=0;s{const i=t.split(/[ ,]+/g);let n;for(let s=0;s(r.preventDefault(),r.type.match(/^touch/)?r.changedTouches:r),br=()=>{const r=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,t=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:r,y:t}},wr=(r,t)=>{t.top||t.right||t.bottom||t.left?(r.style.top=t.top,r.style.right=t.right,r.style.bottom=t.bottom,r.style.left=t.left):(r.style.left=t.x+"px",r.style.top=t.y+"px")},zs=(r,t,e)=>{const i=Co(r);for(let n in i)if(i.hasOwnProperty(n))if(typeof t=="string")i[n]=t+" "+e;else{let s="";for(let o=0,a=t.length;o{const e=Co(r);for(let i in e)e.hasOwnProperty(i)&&(e[i]=t);return e},Co=r=>{const t={};return t[r]="",["webkit","Moz","o"].forEach(function(i){t[i+r.charAt(0).toUpperCase()+r.slice(1)]=""}),t},Un=(r,t)=>{for(let e in t)t.hasOwnProperty(e)&&(r[e]=t[e]);return r},kc=(r,t)=>{const e={};for(let i in r)r.hasOwnProperty(i)&&t.hasOwnProperty(i)?e[i]=t[i]:r.hasOwnProperty(i)&&(e[i]=r[i]);return e},vs=(r,t)=>{if(r.length)for(let e=0,i=r.length;e({x:Math.min(Math.max(r.x,t.x-e),t.x+e),y:Math.min(Math.max(r.y,t.y-e),t.y+e)});var Ec="ontouchstart"in window,Tc=!!window.PointerEvent,_c=!!window.MSPointerEvent,di={touch:{start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},mouse:{start:"mousedown",move:"mousemove",end:"mouseup"},pointer:{start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"},MSPointer:{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}},si,_i={};Tc?si=di.pointer:_c?si=di.MSPointer:Ec?(si=di.touch,_i=di.mouse):si=di.mouse;function ye(){}ye.prototype.on=function(r,t){var e=this,i=r.split(/[ ,]+/g),n;e._handlers_=e._handlers_||{};for(var s=0;s=0&&e._handlers_[r].splice(e._handlers_[r].indexOf(t),1),e};ye.prototype.trigger=function(r,t){var e=this,i=r.split(/[ ,]+/g),n;e._handlers_=e._handlers_||{};for(var s=0;se&&t-e&&t<=e&&!r.lockY?n="left":t>-e*3&&t<=-e&&!r.lockX?n="down":r.lockY||(n="right"),r.lockY||(t>-i&&t0?o="up":o="down"),r.force>this.options.threshold){var a={},c;for(c in this.direction)this.direction.hasOwnProperty(c)&&(a[c]=this.direction[c]);var h={};this.direction={x:s,y:o,angle:n},r.direction=this.direction;for(c in a)a[c]===this.direction[c]&&(h[c]=!0);if(h.x&&h.y&&h.angle)return r;(!h.x||!h.y)&&this.trigger("plain",r),h.x||this.trigger("plain:"+s,r),h.y||this.trigger("plain:"+o,r),h.angle||this.trigger("dir dir:"+n,r)}else this.resetDirection();return r};function vt(r,t){var e=this;e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.pressureIntervals={},e.manager=r,e.id=vt.id,vt.id+=1,e.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:.5,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},e.config(t),(e.options.mode==="static"||e.options.mode==="semi")&&(e.options.multitouch=!1),e.options.multitouch||(e.options.maxNumberOfNipples=1);const i=getComputedStyle(e.options.zone.parentElement);return i&&i.display==="flex"&&(e.parentIsFlex=!0),e.updateBox(),e.prepareNipples(),e.bindings(),e.begin(),e.nipples}vt.prototype=new ye;vt.constructor=vt;vt.id=0;vt.prototype.prepareNipples=function(){var r=this,t=r.nipples;t.on=r.on.bind(r),t.off=r.off.bind(r),t.options=r.options,t.destroy=r.destroy.bind(r),t.ids=r.ids,t.id=r.id,t.processOnMove=r.processOnMove.bind(r),t.processOnEnd=r.processOnEnd.bind(r),t.get=function(e){if(e===void 0)return t[0];for(var i=0,n=t.length;i