UNPKG

3d-force-graph-vr

Version:

UI component for a 3D force-directed graph in VR

2 lines 315 kB
// Version 3.1.1 3d-force-graph-vr - https://github.com/vasturiano/3d-force-graph-vr !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("three")):"function"==typeof define&&define.amd?define(["three"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).ForceGraphVR=t(e.THREE)}(this,function(e){"use strict";function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function n(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function o(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?r(Object(o),!0).forEach(function(t){n(e,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):r(Object(o)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))})}return e}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,s=[],c=!0,l=!1;try{if(i=(n=n.call(e)).next,0===t);else for(;!(c=(r=i.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(l)throw o}}return s}}(e,t)||s(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||s(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}function c(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function l(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if("function"==typeof t){var n=function e(){var n=!1;try{n=this instanceof e}catch{}return n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}),n}!function(e,t){void 0===t&&(t={});var n=t.insertAt;if("undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}(".graph-nav-info {\n position: absolute;\n bottom: 5px;\n width: 100%;\n text-align: center;\n color: slategrey;\n opacity: 0.7;\n font-size: 10px;\n font-family: Sans-serif;\n z-index: 1000;\n}");var u,d,h,f,p,g,m,y={};function v(){return h?d:(h=1,d=Object.assign(function(){},{FACE_1:0,FACE_2:1,FACE_3:2,FACE_4:3,L_SHOULDER_1:4,R_SHOULDER_1:5,L_SHOULDER_2:6,R_SHOULDER_2:7,SELECT:8,START:9,DPAD_UP:12,DPAD_DOWN:13,DPAD_LEFT:14,DPAD_RIGHT:15,VENDOR:16}))}function b(){if(m)return g;m=1;const e=v(),t=(p||(p=1,f=function(e,t,n){this.type=e,this.index=t,this.pressed=n.pressed,this.value=n.value}),f),n=.2,r="left",o="right",i=1,a=2;return g=AFRAME.registerComponent("gamepad-controls",{GamepadButton:e,schema:{enabled:{default:!0},rotationSensitivity:{default:2}},init:function(){const e=this.el.sceneEl;this.system=e.systems["tracked-controls"]||e.systems["tracked-controls-webxr"]||{controllers:[]},this.prevTime=window.performance.now(),this.buttons={};const t=this.el.object3D.rotation;this.pitch=new THREE.Object3D,this.pitch.rotation.x=t.x,this.yaw=new THREE.Object3D,this.yaw.position.y=10,this.yaw.rotation.y=t.y,this.yaw.add(this.pitch),this._lookVector=new THREE.Vector2,this._moveVector=new THREE.Vector2,this._dpadVector=new THREE.Vector2,e.addBehavior(this)},update:function(){this.tick()},tick:function(e,t){this.updateButtonState(),this.updateRotation(t)},remove:function(){},isVelocityActive:function(){if(!this.data.enabled||!this.isConnected())return!1;const e=this._dpadVector,t=this._moveVector;this.getDpad(e),this.getJoystick(i,t);const r=e.x||t.x,o=e.y||t.y;return Math.abs(r)>n||Math.abs(o)>n},getVelocityDelta:function(){const e=this._dpadVector,t=this._moveVector;this.getDpad(e),this.getJoystick(i,t);const r=e.x||t.x,o=e.y||t.y,a=new THREE.Vector3;return Math.abs(r)>n&&(a.x+=r),Math.abs(o)>n&&(a.z+=o),a},isRotationActive:function(){if(!this.data.enabled||!this.isConnected())return!1;const e=this._lookVector;return this.getJoystick(a,e),Math.abs(e.x)>n||Math.abs(e.y)>n},updateRotation:function(e){if(!this.isRotationActive())return;const t=this.data,r=this.yaw,o=this.pitch;r.rotation.y=this.el.object3D.rotation.y,o.rotation.x=this.el.object3D.rotation.x;const i=this._lookVector;this.getJoystick(a,i),Math.abs(i.x)<=n&&(i.x=0),Math.abs(i.y)<=n&&(i.y=0),i.multiplyScalar(t.rotationSensitivity*e/1e3),r.rotation.y-=i.x,o.rotation.x-=i.y,o.rotation.x=Math.max(-Math.PI/2,Math.min(Math.PI/2,o.rotation.x)),this.el.object3D.rotation.set(o.rotation.x,r.rotation.y,0)},updateButtonState:function(){const e=this.getGamepad(o);if(this.data.enabled&&e)for(var n=0;n<e.buttons.length;n++)e.buttons[n].pressed&&!this.buttons[n]?this.emit(new t("gamepadbuttondown",n,e.buttons[n])):!e.buttons[n].pressed&&this.buttons[n]&&this.emit(new t("gamepadbuttonup",n,e.buttons[n])),this.buttons[n]=e.buttons[n].pressed;else for(const e in this.buttons)this.buttons[e]=!1},emit:function(e){this.el.emit(e.type,e),this.el.emit(e.type+":"+e.index,new t(e.type,e.index,e))},getGamepad:function(){const e=[],t=[];return function(n){const r=this.el.sceneEl.components["proxy-controls"],o=r&&r.isConnected()&&r.getGamepad(0);if(o)return o;e.length=0;for(let t=0;t<this.system.controllers.length;t++){const r=this.system.controllers[t],o=r?r.gamepad:null;if(e.push(o),o&&r.handedness===n)return o}const i=navigator.getGamepads?navigator.getGamepads():t;for(let e=0;e<i.length;e++){const t=i[e];if(t&&t.hand===n)return t}return e[0]||i[0]}}(),getButton:function(e){return this.getGamepad(o).buttons[e]},getAxis:function(e){return this.getGamepad(e>1?o:r).axes[e]},getJoystick:function(e,t){const n=this.getGamepad(e===i?r:o);if(!n)return t.set(0,0);if("xr-standard"===n.mapping)switch(e){case i:return t.set(n.axes[2],n.axes[3]);case a:return t.set(n.axes[2],0)}else switch(e){case i:return t.set(n.axes[0],n.axes[1]);case a:return t.set(n.axes[2],n.axes[3])}throw new Error('Unexpected joystick index "%d".',e)},getDpad:function(t){const n=this.getGamepad(r);return n&&n.buttons[e.DPAD_RIGHT]?t.set((n.buttons[e.DPAD_RIGHT].pressed?1:0)+(n.buttons[e.DPAD_LEFT].pressed?-1:0),(n.buttons[e.DPAD_UP].pressed?-1:0)+(n.buttons[e.DPAD_DOWN].pressed?1:0)):t.set(0,0)},isConnected:function(){const e=this.getGamepad(r);return!(!e||!e.connected)},getID:function(){return this.getGamepad(r).id}}),g}var w,x,k,E,_,A,M,T={};function C(){return w||(w=1,function(e){var t="KeyboardEvent"in e;t||(e.KeyboardEvent=function(){throw TypeError("Illegal constructor")}),"DOM_KEY_LOCATION_STANDARD"in e.KeyboardEvent||(e.KeyboardEvent.DOM_KEY_LOCATION_STANDARD=0),"DOM_KEY_LOCATION_LEFT"in e.KeyboardEvent||(e.KeyboardEvent.DOM_KEY_LOCATION_LEFT=1),"DOM_KEY_LOCATION_RIGHT"in e.KeyboardEvent||(e.KeyboardEvent.DOM_KEY_LOCATION_RIGHT=2),"DOM_KEY_LOCATION_NUMPAD"in e.KeyboardEvent||(e.KeyboardEvent.DOM_KEY_LOCATION_NUMPAD=3);var n=window.KeyboardEvent.DOM_KEY_LOCATION_STANDARD,r=window.KeyboardEvent.DOM_KEY_LOCATION_LEFT,o=window.KeyboardEvent.DOM_KEY_LOCATION_RIGHT,i=window.KeyboardEvent.DOM_KEY_LOCATION_NUMPAD;function a(e,t){return-1!==String(e).indexOf(t)}var s=a(navigator.platform,"Win")?"win":a(navigator.platform,"Mac")?"mac":a(navigator.platform,"CrOS")?"cros":a(navigator.platform,"Linux")?"linux":a(navigator.userAgent,"iPad")||a(navigator.platform,"iPod")||a(navigator.platform,"iPhone")?"ios":"",c=a(navigator.userAgent,"Chrome/")?"chrome":a(navigator.vendor,"Apple")?"safari":a(navigator.userAgent,"MSIE")?"ie":a(navigator.userAgent,"Gecko/")?"moz":a(navigator.userAgent,"Opera/")?"opera":"",l=c+"-"+s;function u(e,t,n){l!==t&&c!==t&&s!==t||Object.keys(n).forEach(function(t){e[t]=n[t]})}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:r},92:{code:"OSRight",location:o},93:{code:"ContextMenu"},95:{code:"Standby"},96:{code:"Numpad0",keyCap:"0",location:i},97:{code:"Numpad1",keyCap:"1",location:i},98:{code:"Numpad2",keyCap:"2",location:i},99:{code:"Numpad3",keyCap:"3",location:i},100:{code:"Numpad4",keyCap:"4",location:i},101:{code:"Numpad5",keyCap:"5",location:i},102:{code:"Numpad6",keyCap:"6",location:i},103:{code:"Numpad7",keyCap:"7",location:i},104:{code:"Numpad8",keyCap:"8",location:i},105:{code:"Numpad9",keyCap:"9",location:i},106:{code:"NumpadMultiply",keyCap:"*",location:i},107:{code:"NumpadAdd",keyCap:"+",location:i},108:{code:"NumpadComma",keyCap:",",location:i},109:{code:"NumpadSubtract",keyCap:"-",location:i},110:{code:"NumpadDecimal",keyCap:".",location:i},111:{code:"NumpadDivide",keyCap:"/",location:i},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:i},145:{code:"ScrollLock"},160:{code:"ShiftLeft",location:r},161:{code:"ShiftRight",location:o},162:{code:"ControlLeft",location:r},163:{code:"ControlRight",location:o},164:{code:"AltLeft",location:r},165:{code:"AltRight",location:o},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"}};u(d,"moz",{59:{code:"Semicolon",keyCap:";"},61:{code:"Equal",keyCap:"="},107:{code:"Equal",keyCap:"="},109:{code:"Minus",keyCap:"-"},187:{code:"NumpadAdd",keyCap:"+",location:i},189:{code:"NumpadSubtract",keyCap:"-",location:i}}),u(d,"moz-mac",{12:{code:"NumLock",location:i},173:{code:"Minus",keyCap:"-"}}),u(d,"moz-win",{173:{code:"Minus",keyCap:"-"}}),u(d,"chrome-mac",{93:{code:"OSRight",location:o}}),u(d,"safari",{3:{code:"Enter"},25:{code:"Tab"}}),u(d,"ios",{10:{code:"Enter",location:n}}),u(d,"safari-mac",{91:{code:"OSLeft",location:r},93:{code:"OSRight",location:o},229:{code:"KeyQ",keyCap:"Q"}});var h={};"cros"===s&&(h["U+00A0"]={code:"ShiftLeft",location:r},h["U+00A1"]={code:"ShiftRight",location:o},h["U+00A2"]={code:"ControlLeft",location:r},h["U+00A3"]={code:"ControlRight",location:o},h["U+00A4"]={code:"AltLeft",location:r},h["U+00A5"]={code:"AltRight",location:o}),"chrome-mac"===l&&(h["U+0010"]={code:"ContextMenu"}),"safari-mac"===l&&(h["U+0010"]={code:"ContextMenu"}),"ios"===s&&(h["U+0010"]={code:"Function"},h["U+001C"]={code:"ArrowLeft"},h["U+001D"]={code:"ArrowRight"},h["U+001E"]={code:"ArrowUp"},h["U+001F"]={code:"ArrowDown"},h["U+0001"]={code:"Home"},h["U+0004"]={code:"End"},h["U+000B"]={code:"PageUp"},h["U+000C"]={code:"PageDown"});var f=[];f[r]={16:{code:"ShiftLeft",location:r},17:{code:"ControlLeft",location:r},18:{code:"AltLeft",location:r}},f[o]={16:{code:"ShiftRight",location:o},17:{code:"ControlRight",location:o},18:{code:"AltRight",location:o}},f[i]={13:{code:"NumpadEnter",location:i}},u(f[i],"moz",{109:{code:"NumpadSubtract",location:i},107:{code:"NumpadAdd",location:i}}),u(f[r],"moz-mac",{224:{code:"OSLeft",location:r}}),u(f[o],"moz-mac",{224:{code:"OSRight",location:o}}),u(f[o],"moz-win",{91:{code:"OSRight",location:o}}),u(f[o],"mac",{93:{code:"OSRight",location:o}}),u(f[i],"chrome-mac",{12:{code:"NumLock",location:i}}),u(f[i],"safari-mac",{12:{code:"NumLock",location:i},187:{code:"NumpadAdd",location:i},189:{code:"NumpadSubtract",location:i},190:{code:"NumpadDecimal",location:i},191:{code:"NumpadDivide",location:i}});var p={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:"|"}};u(p,"mac",{OSLeft:{key:"Meta"},OSRight:{key:"Meta"}});var g,m,y,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"},b=(g=d,m="code",y={},Object.keys(g).forEach(function(e){var t=g[e];m in t&&(y[t[m]]=t)}),y);try{var w=t&&"location"in new KeyboardEvent("")}catch(e){}function x(e){var t="keyCode"in e?e.keyCode:"which"in e?e.which:0,n=function(){if(w||"keyLocation"in e){var n=w?e.location:e.keyLocation;if(n&&t in f[n])return f[n][t]}return"keyIdentifier"in e&&e.keyIdentifier in h?h[e.keyIdentifier]:t in d?d[t]:null}();if(!n)return null;var r,o=(r=p[n.code])?e.shiftKey&&"shiftKey"in r?r.shiftKey:r.key:n.code;return{code:n.code,key:o,location:n.location,keyCap:n.keyCap}}"KeyboardEvent"in e&&"defineProperty"in Object&&function(){function e(e,t,n){t in e||Object.defineProperty(e,t,n)}if(e(KeyboardEvent.prototype,"code",{get:function(){var e=x(this);return e?e.code:""}}),"key"in KeyboardEvent.prototype){var t=Object.getOwnPropertyDescriptor(KeyboardEvent.prototype,"key");Object.defineProperty(KeyboardEvent.prototype,"key",{get:function(){var e=t.get.call(this);return v.hasOwnProperty(e)?v[e]:e}})}e(KeyboardEvent.prototype,"key",{get:function(){var e=x(this);return e&&"key"in e?e.key:"Unidentified"}}),e(KeyboardEvent.prototype,"location",{get:function(){var e=x(this);return e&&"location"in e?e.location:n}}),e(KeyboardEvent.prototype,"locale",{get:function(){return""}})}(),"queryKeyCap"in e.KeyboardEvent||(e.KeyboardEvent.queryKeyCap=function(e,t){if(e=String(e),!b.hasOwnProperty(e))return"Undefined";if(t&&"en-us"!==String(t).toLowerCase())throw Error("Unsupported locale");var n=b[e];return n.keyCap||n.code||"Undefined"}),e.identifyKey=function(e){if(!("code"in e)){var t=x(e);e.code=t?t.code:"",e.key=t&&"key"in t?t.key:"Unidentified",e.location="location"in e?e.location:"keyLocation"in e?e.keyLocation:t&&"location"in t?t.location:n,e.locale=""}}}(window)),T}const N=(e,t)=>{const n=t.x-e.x,r=t.y-e.y;return Math.sqrt(n*n+r*r)},O=e=>e*(Math.PI/180),D=e=>e*(180/Math.PI),P=new Map,S=e=>{P.has(e)&&clearTimeout(P.get(e)),P.set(e,setTimeout(e,100))},L=(e,t,n)=>{const r=t.split(/[ ,]+/g);let o;for(let t=0;t<r.length;t+=1)o=r[t],e.addEventListener?e.addEventListener(o,n,!1):e.attachEvent&&e.attachEvent(o,n)},I=(e,t,n)=>{const r=t.split(/[ ,]+/g);let o;for(let t=0;t<r.length;t+=1)o=r[t],e.removeEventListener?e.removeEventListener(o,n):e.detachEvent&&e.detachEvent(o,n)},j=e=>(e.preventDefault(),e.type.match(/^touch/)?e.changedTouches:e),R=()=>({x:void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,y:void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop}),F=(e,t)=>{t.top||t.right||t.bottom||t.left?(e.style.top=t.top,e.style.right=t.right,e.style.bottom=t.bottom,e.style.left=t.left):(e.style.left=t.x+"px",e.style.top=t.y+"px")},B=(e,t,n)=>{const r=z(e);for(let e in r)if(r.hasOwnProperty(e))if("string"==typeof t)r[e]=t+" "+n;else{let o="";for(let e=0,r=t.length;e<r;e+=1)o+=t[e]+" "+n+", ";r[e]=o.slice(0,-2)}return r},z=e=>{const t={};t[e]="";return["webkit","Moz","o"].forEach(function(n){t[n+e.charAt(0).toUpperCase()+e.slice(1)]=""}),t},V=(e,t)=>{for(let n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},U=(e,t)=>{if(e.length)for(let n=0,r=e.length;n<r;n+=1)t(e[n]);else t(e)};var G,H=!!("ontouchstart"in window),K=!!window.PointerEvent,q=!!window.MSPointerEvent,$={start:"mousedown",move:"mousemove",end:"mouseup"},W={};function X(){}function J(e,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=e,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:.5,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(t),"dynamic"===this.options.mode&&(this.options.restOpacity=0),this.id=J.id,J.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),setPosition:this.setPosition.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}function Z(e,t){var n=this;n.nipples=[],n.idles=[],n.actives=[],n.ids=[],n.pressureIntervals={},n.manager=e,n.id=Z.id,Z.id+=1,n.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},n.config(t),"static"!==n.options.mode&&"semi"!==n.options.mode||(n.options.multitouch=!1),n.options.multitouch||(n.options.maxNumberOfNipples=1);const r=getComputedStyle(n.options.zone.parentElement);return r&&"flex"===r.display&&(n.parentIsFlex=!0),n.updateBox(),n.prepareNipples(),n.bindings(),n.begin(),n.nipples}function Y(e){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=R(),t.config(e),t.prepareCollections();var n=function(){var e;t.collections.forEach(function(n){n.forEach(function(n){e=n.el.getBoundingClientRect(),n.position={x:t.scroll.x+e.left,y:t.scroll.y+e.top}})})};L(window,"resize",function(){S(n)});var r=function(){t.scroll=R()};return L(window,"scroll",function(){S(r)}),t.collections}K?G={start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"}:q?G={start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:H?(G={start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},W=$):G=$,X.prototype.on=function(e,t){var n,r=this,o=e.split(/[ ,]+/g);r._handlers_=r._handlers_||{};for(var i=0;i<o.length;i+=1)n=o[i],r._handlers_[n]=r._handlers_[n]||[],r._handlers_[n].push(t);return r},X.prototype.off=function(e,t){var n=this;return n._handlers_=n._handlers_||{},void 0===e?n._handlers_={}:void 0===t?n._handlers_[e]=null:n._handlers_[e]&&n._handlers_[e].indexOf(t)>=0&&n._handlers_[e].splice(n._handlers_[e].indexOf(t),1),n},X.prototype.trigger=function(e,t){var n,r=this,o=e.split(/[ ,]+/g);r._handlers_=r._handlers_||{};for(var i=0;i<o.length;i+=1)n=o[i],r._handlers_[n]&&r._handlers_[n].length&&r._handlers_[n].forEach(function(e){e.call(r,{type:n,target:r},t)})},X.prototype.config=function(e){var t=this;t.options=t.defaults||{},e&&(t.options=((e,t)=>{const n={};for(let r in e)e.hasOwnProperty(r)&&t.hasOwnProperty(r)?n[r]=t[r]:e.hasOwnProperty(r)&&(n[r]=e[r]);return n})(t.options,e))},X.prototype.bindEvt=function(e,t){var n=this;return n._domHandlers_=n._domHandlers_||{},n._domHandlers_[t]=function(){"function"==typeof n["on"+t]?n["on"+t].apply(n,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},L(e,G[t],n._domHandlers_[t]),W[t]&&L(e,W[t],n._domHandlers_[t]),n},X.prototype.unbindEvt=function(e,t){var n=this;return n._domHandlers_=n._domHandlers_||{},I(e,G[t],n._domHandlers_[t]),W[t]&&I(e,W[t],n._domHandlers_[t]),delete n._domHandlers_[t],this},J.prototype=new X,J.constructor=J,J.id=0,J.prototype.buildEl=function(e){return this.ui={},this.options.dataOnly||(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front)),this},J.prototype.stylize=function(){if(this.options.dataOnly)return this;var e=this.options.fadeTime+"ms",t=((e,t)=>{const n=z(e);for(let e in n)n.hasOwnProperty(e)&&(n[e]=t);return n})("borderRadius","50%"),n=B("transition","opacity",e),r={};return r.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},r.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",left:0,marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:this.options.color,opacity:".5"},r.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",left:0,marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:this.options.color,opacity:".5",transform:"translate(0px, 0px)"},V(r.el,n),"circle"===this.options.shape&&V(r.back,t),V(r.front,t),this.applyStyles(r),this},J.prototype.applyStyles=function(e){for(var t in this.ui)if(this.ui.hasOwnProperty(t))for(var n in e[t])this.ui[t].style[n]=e[t][n];return this},J.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)||this.options.zone.appendChild(this.ui.el),this},J.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)||this.options.zone.removeChild(this.ui.el),this},J.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()},J.prototype.show=function(e){var t=this;return t.options.dataOnly||(clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.addToDom(),t.restCallback(),setTimeout(function(){t.ui.el.style.opacity=1},0),t.showTimeout=setTimeout(function(){t.trigger("shown",t.instance),"function"==typeof e&&e.call(this)},t.options.fadeTime)),t},J.prototype.hide=function(e){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var n="dynamic"===t.options.mode?"none":"block";t.ui.el.style.display=n,"function"==typeof e&&e.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){const n=t.options.restJoystick,r={};r.x=!0===n||!1!==n.x?0:t.instance.frontPosition.x,r.y=!0===n||!1!==n.y?0:t.instance.frontPosition.y,t.setPosition(e,r)}return t},J.prototype.setPosition=function(e,t){var n=this;n.frontPosition={x:t.x,y:t.y};var r=n.options.fadeTime+"ms",o={};o.front=B("transition",["transform"],r);var i={front:{}};i.front={transform:"translate("+n.frontPosition.x+"px,"+n.frontPosition.y+"px)"},n.applyStyles(o),n.applyStyles(i),n.restTimeout=setTimeout(function(){"function"==typeof e&&e.call(n),n.restCallback()},n.options.fadeTime)},J.prototype.restCallback=function(){var e=this,t={};t.front=B("transition","none",""),e.applyStyles(t),e.trigger("rested",e.instance)},J.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}},J.prototype.computeDirection=function(e){var t,n,r,o=e.angle.radian,i=Math.PI/4,a=Math.PI/2;if(o>i&&o<3*i&&!e.lockX?t="up":o>-i&&o<=i&&!e.lockY?t="left":o>3*-i&&o<=-i&&!e.lockX?t="down":e.lockY||(t="right"),e.lockY||(n=o>-a&&o<a?"left":"right"),e.lockX||(r=o>0?"up":"down"),e.force>this.options.threshold){var s,c={};for(s in this.direction)this.direction.hasOwnProperty(s)&&(c[s]=this.direction[s]);var l={};for(s in this.direction={x:n,y:r,angle:t},e.direction=this.direction,c)c[s]===this.direction[s]&&(l[s]=!0);if(l.x&&l.y&&l.angle)return e;l.x&&l.y||this.trigger("plain",e),l.x||this.trigger("plain:"+n,e),l.y||this.trigger("plain:"+r,e),l.angle||this.trigger("dir dir:"+t,e)}else this.resetDirection();return e},Z.prototype=new X,Z.constructor=Z,Z.id=0,Z.prototype.prepareNipples=function(){var e=this,t=e.nipples;t.on=e.on.bind(e),t.off=e.off.bind(e),t.options=e.options,t.destroy=e.destroy.bind(e),t.ids=e.ids,t.id=e.id,t.processOnMove=e.processOnMove.bind(e),t.processOnEnd=e.processOnEnd.bind(e),t.get=function(e){if(void 0===e)return t[0];for(var n=0,r=t.length;n<r;n+=1)if(t[n].identifier===e)return t[n];return!1}},Z.prototype.bindings=function(){var e=this;e.bindEvt(e.options.zone,"start"),e.options.zone.style.touchAction="none",e.options.zone.style.msTouchAction="none"},Z.prototype.begin=function(){var e=this,t=e.options;if("static"===t.mode){var n=e.createNipple(t.position,e.manager.getIdentifier());n.add(),e.idles.push(n)}},Z.prototype.createNipple=function(e,t){var n=this,r=n.manager.scroll,o={},i=n.options,a=n.parentIsFlex?r.x:r.x+n.box.left,s=n.parentIsFlex?r.y:r.y+n.box.top;if(e.x&&e.y)o={x:e.x-a,y:e.y-s};else if(e.top||e.right||e.bottom||e.left){var c=document.createElement("DIV");c.style.display="hidden",c.style.top=e.top,c.style.right=e.right,c.style.bottom=e.bottom,c.style.left=e.left,c.style.position="absolute",i.zone.appendChild(c);var l=c.getBoundingClientRect();i.zone.removeChild(c),o=e,e={x:l.left+r.x,y:l.top+r.y}}var u=new J(n,{color:i.color,size:i.size,threshold:i.threshold,fadeTime:i.fadeTime,dataOnly:i.dataOnly,restJoystick:i.restJoystick,restOpacity:i.restOpacity,mode:i.mode,identifier:t,position:e,zone:i.zone,frontPosition:{x:0,y:0},shape:i.shape});return i.dataOnly||(F(u.ui.el,o),F(u.ui.front,u.frontPosition)),n.nipples.push(u),n.trigger("added "+u.identifier+":added",u),n.manager.trigger("added "+u.identifier+":added",u),n.bindNipple(u),u},Z.prototype.updateBox=function(){this.box=this.options.zone.getBoundingClientRect()},Z.prototype.bindNipple=function(e){var t,n=this,r=function(e,r){t=e.type+" "+r.id+":"+e.type,n.trigger(t,r)};e.on("destroyed",n.onDestroyed.bind(n)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)},Z.prototype.pressureFn=function(e,t,n){var r=this,o=0;clearInterval(r.pressureIntervals[n]),r.pressureIntervals[n]=setInterval(function(){var n=e.force||e.pressure||e.webkitForce||0;n!==o&&(t.trigger("pressure",n),r.trigger("pressure "+t.identifier+":pressure",n),o=n)}.bind(r),100)},Z.prototype.onstart=function(e){var t=this,n=t.options,r=e;e=j(e),t.updateBox();return U(e,function(o){t.actives.length<n.maxNumberOfNipples?t.processOnStart(o):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(n){if(Object.values(r.touches).findIndex(function(e){return e.identifier===n})<0){var o=[e[0]];o.identifier=n,t.processOnEnd(o)}}),t.actives.length<n.maxNumberOfNipples&&t.processOnStart(o))}),t.manager.bindDocument(),!1},Z.prototype.processOnStart=function(e){var t,n=this,r=n.options,o=n.manager.getIdentifier(e),i=e.force||e.pressure||e.webkitForce||0,a={x:e.pageX,y:e.pageY},s=n.getOrCreate(o,a);s.identifier!==o&&n.manager.removeIdentifier(s.identifier),s.identifier=o;var c=function(t){t.trigger("start",t),n.trigger("start "+t.id+":start",t),t.show(),i>0&&n.pressureFn(e,t,t.identifier),n.processOnMove(e)};if((t=n.idles.indexOf(s))>=0&&n.idles.splice(t,1),n.actives.push(s),n.ids.push(s.identifier),"semi"!==r.mode)c(s);else{if(!(N(a,s.position)<=r.catchDistance))return s.destroy(),void n.processOnStart(e);c(s)}return s},Z.prototype.getOrCreate=function(e,t){var n,r=this,o=r.options;return/(semi|static)/.test(o.mode)?(n=r.idles[0])?(r.idles.splice(0,1),n):"semi"===o.mode?r.createNipple(t,e):(console.warn("Coudln't find the needed nipple."),!1):n=r.createNipple(t,e)},Z.prototype.processOnMove=function(e){var t=this,n=t.options,r=t.manager.getIdentifier(e),o=t.nipples.get(r),i=t.manager.scroll;if((e=>isNaN(e.buttons)?0!==e.pressure:0!==e.buttons)(e)){if(!o)return console.error("Found zombie joystick with ID "+r),void t.manager.removeIdentifier(r);if(n.dynamicPage){var a=o.el.getBoundingClientRect();o.position={x:i.x+a.left,y:i.y+a.top}}o.identifier=r;var s=o.options.size/2,c={x:e.pageX,y:e.pageY};n.lockX&&(c.y=o.position.y),n.lockY&&(c.x=o.position.x);var l,u,d=N(c,o.position),h=((e,t)=>{const n=t.x-e.x,r=t.y-e.y;return D(Math.atan2(r,n))})(c,o.position),f=O(h),p=d/s,g={distance:d,position:c};if("circle"===o.options.shape?(l=Math.min(d,s),u=((e,t,n)=>{const r={x:0,y:0};return n=O(n),r.x=e.x-t*Math.cos(n),r.y=e.y-t*Math.sin(n),r})(o.position,l,h)):(u=((e,t,n)=>({x:Math.min(Math.max(e.x,t.x-n),t.x+n),y:Math.min(Math.max(e.y,t.y-n),t.y+n)}))(c,o.position,s),l=N(u,o.position)),n.follow){if(d>s){let e=c.x-u.x,n=c.y-u.y;o.position.x+=e,o.position.y+=n,o.el.style.top=o.position.y-(t.box.top+i.y)+"px",o.el.style.left=o.position.x-(t.box.left+i.x)+"px",d=N(c,o.position)}}else c=u,d=l;var m=c.x-o.position.x,y=c.y-o.position.y;o.frontPosition={x:m,y:y},n.dataOnly||(o.ui.front.style.transform="translate("+m+"px,"+y+"px)");var v={identifier:o.identifier,position:c,force:p,pressure:e.force||e.pressure||e.webkitForce||0,distance:d,angle:{radian:f,degree:h},vector:{x:m/s,y:-y/s},raw:g,instance:o,lockX:n.lockX,lockY:n.lockY};(v=o.computeDirection(v)).angle={radian:O(180-h),degree:180-h},o.trigger("move",v),t.trigger("move "+o.id+":move",v)}else this.processOnEnd(e)},Z.prototype.processOnEnd=function(e){var t=this,n=t.options,r=t.manager.getIdentifier(e),o=t.nipples.get(r),i=t.manager.removeIdentifier(o.identifier);o&&(n.dataOnly||o.hide(function(){"dynamic"===n.mode&&(o.trigger("removed",o),t.trigger("removed "+o.id+":removed",o),t.manager.trigger("removed "+o.id+":removed",o),o.destroy())}),clearInterval(t.pressureIntervals[o.identifier]),o.resetDirection(),o.trigger("end",o),t.trigger("end "+o.id+":end",o),t.ids.indexOf(o.identifier)>=0&&t.ids.splice(t.ids.indexOf(o.identifier),1),t.actives.indexOf(o)>=0&&t.actives.splice(t.actives.indexOf(o),1),/(semi|static)/.test(n.mode)?t.idles.push(o):t.nipples.indexOf(o)>=0&&t.nipples.splice(t.nipples.indexOf(o),1),t.manager.unbindDocument(),/(semi|static)/.test(n.mode)&&(t.manager.ids[i.id]=i.identifier))},Z.prototype.onDestroyed=function(e,t){var n=this;n.nipples.indexOf(t)>=0&&n.nipples.splice(n.nipples.indexOf(t),1),n.actives.indexOf(t)>=0&&n.actives.splice(n.actives.indexOf(t),1),n.idles.indexOf(t)>=0&&n.idles.splice(n.idles.indexOf(t),1),n.ids.indexOf(t.identifier)>=0&&n.ids.splice(n.ids.indexOf(t.identifier),1),n.manager.removeIdentifier(t.identifier),n.manager.unbindDocument()},Z.prototype.destroy=function(){var e=this;for(var t in e.unbindEvt(e.options.zone,"start"),e.nipples.forEach(function(e){e.destroy()}),e.pressureIntervals)e.pressureIntervals.hasOwnProperty(t)&&clearInterval(e.pressureIntervals[t]);e.trigger("destroyed",e.nipples),e.manager.unbindDocument(),e.off()},Y.prototype=new X,Y.constructor=Y,Y.prototype.prepareCollections=function(){var e=this;e.collections.create=e.create.bind(e),e.collections.on=e.on.bind(e),e.collections.off=e.off.bind(e),e.collections.destroy=e.destroy.bind(e),e.collections.get=function(t){var n;return e.collections.every(function(e){return!(n=e.get(t))}),n}},Y.prototype.create=function(e){return this.createCollection(e)},Y.prototype.createCollection=function(e){var t=this,n=new Z(t,e);return t.bindCollection(n),t.collections.push(n),n},Y.prototype.bindCollection=function(e){var t,n=this,r=function(e,r){t=e.type+" "+r.id+":"+e.type,n.trigger(t,r)};e.on("destroyed",n.onDestroyed.bind(n)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)},Y.prototype.bindDocument=function(){var e=this;e.binded||(e.bindEvt(document,"move").bindEvt(document,"end"),e.binded=!0)},Y.prototype.unbindDocument=function(e){var t=this;Object.keys(t.ids).length&&!0!==e||(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)},Y.prototype.getIdentifier=function(e){var t;return e?void 0===(t=void 0===e.identifier?e.pointerId:e.identifier)&&(t=this.latest||0):t=this.index,void 0===this.ids[t]&&(this.ids[t]=this.index,this.index+=1),this.latest=t,this.ids[t]},Y.prototype.removeIdentifier=function(e){var t={};for(var n in this.ids)if(this.ids[n]===e){t.id=n,t.identifier=this.ids[n],delete this.ids[n];break}return t},Y.prototype.onmove=function(e){return this.onAny("move",e),!1},Y.prototype.onend=function(e){return this.onAny("end",e),!1},Y.prototype.oncancel=function(e){return this.onAny("end",e),!1},Y.prototype.onAny=function(e,t){var n,r=this,o="processOn"+e.charAt(0).toUpperCase()+e.slice(1);t=j(t);var i=function(e,t,n){n.ids.indexOf(t)>=0&&(n[o](e),e._found_=!0)};return U(t,function(e){n=r.getIdentifier(e),U(r.collections,i.bind(null,e,n)),e._found_||r.removeIdentifier(n)}),!1},Y.prototype.destroy=function(){var e=this;e.unbindDocument(!0),e.ids={},e.index=0,e.collections.forEach(function(e){e.destroy()}),e.off()},Y.prototype.onDestroyed=function(e,t){var n=this;if(n.collections.indexOf(t)<0)return!1;n.collections.splice(n.collections.indexOf(t),1)};const Q=new Y;var ee,te=function(e){return Q.create(e)};function ne(){return ee||(ee=1,u||(u=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(e){const t=this.el;this.active&&this.checkpoint!==e&&(this.checkpoint&&t.emit("navigation-end",{checkpoint:this.checkpoint}),this.checkpoint=e,this.sync(),this.position.distanceTo(this.targetPosition)<.1?this.checkpoint=null:(t.emit("navigation-start",{checkpoint:e}),"teleport"===this.data.mode&&(this.el.setAttribute("position",this.targetPosition),this.checkpoint=null,t.emit("navigation-end",{checkpoint:e}),t.components["movement-controls"].updateNavLocation())))},isVelocityActive:function(){return!(!this.active||!this.checkpoint)},getVelocity:function(){if(!this.active)return;const e=this.data,t=this.offset,n=this.position,r=this.targetPosition,o=this.checkpoint;return this.sync(),n.distanceTo(r)<.1?(this.checkpoint=null,this.el.emit("navigation-end",{checkpoint:o}),t.set(0,0,0)):(t.setLength(e.animateSpeed),t)},sync:function(){const e=this.offset,t=this.position,n=this.targetPosition;t.copy(this.el.getAttribute("position")),this.checkpoint.object3D.getWorldPosition(n),n.add(this.checkpoint.components.checkpoint.getOffset()),e.copy(n).sub(t)}})),b(),function(){if(k)return x;k=1,C();const e=window.KeyboardEvent;x=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 e=this.data,t=this.getKeys();return this.dVelocity.set(0,0,0),e.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 e in this.localKeys)this.localKeys.hasOwnProperty(e)&&delete this.localKeys[e]},removeEventListeners:function(){window.removeEventListener("keydown",this.listeners.keydown),window.removeEventListener("keyup",this.listeners.keyup),window.removeEventListener("blur",this.listeners.blur)},onKeyDown:function(e){AFRAME.utils.shouldCaptureKeyEvent(e)&&(this.localKeys[e.code]=!0,this.emit(e))},onKeyUp:function(e){AFRAME.utils.shouldCaptureKeyEvent(e)&&(delete this.localKeys[e.code],this.emit(e))},onBlur:function(){for(const e in this.localKeys)this.localKeys.hasOwnProperty(e)&&delete this.localKeys[e]},emit:function(t){"__keyboard-controls-proxy"in t&&this.el.emit(t.type,t),this.el.emit(t.type+":"+t.code,new e(t.type,t)),this.data.debug&&console.log(t.type+":"+t.code)},isPressed:function(e){return e in this.getKeys()},getKeys:function(){return this.isProxied()?this.el.sceneEl.components["proxy-controls"].getKeyboard():this.localKeys},isProxied:function(){const e=this.el.sceneEl.components["proxy-controls"];return e&&e.isConnected()}})}(),E||(E=1,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 e=this.el.sceneEl,t=e.canvas;if(!t)return void e.addEventListener("render-target-loaded",this.addEventListeners.bind(this));t.addEventListener("touchstart",this.onTouchStart,{passive:!0}),t.addEventListener("touchend",this.onTouchEnd,{passive:!0});const n=e.getAttribute("vr-mode-ui");n&&n.cardboardModeEnabled&&e.addEventListener("enter-vr",this.onEnterVR)},removeEventListeners:function(){const e=this.el.sceneEl&&this.el.sceneEl.canvas;e&&(e.removeEventListener("touchstart",this.onTouchStart),e.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(e){this.direction=-1,this.data.reverseEnabled&&e.touches&&2===e.touches.length&&(this.direction=1),e.preventDefault()},onTouchEnd:function(e){this.direction=0,e.preventDefault()},onEnterVR:function(){const e=this.el.sceneEl.xrSession;e&&(e.addEventListener("selectstart",this.onTouchStart),e.addEventListener("selectend",this.onTouchEnd))}})),function(){if(A)return _;A=1;const e="-controls";_=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 e=this.el;this.data.camera||(this.data.camera=e.querySelector("[camera]")),this.velocityCtrl=null,this.velocity=new THREE.Vector3,this.heading=new THREE.Quaternion,this.eventDetail={},this.navGroup=null,this.navNode=null,e.sceneEl.hasLoaded?this.injectControls():e.sceneEl.addEventListener("loaded",this.injectControls.bind(this))},update:function(t){const n=this.el,r=this.data,o=n.sceneEl.systems.nav;if(n.sceneEl.hasLoaded&&this.injectControls(),o&&r.constrainToNavMesh!==t.constrainToNavMesh&&(r.constrainToNavMesh?o.addAgent(this):o.removeAgent(this)),r.enabled!==t.enabled)for(let t=0;t<r.controls.length;t++){const n=r.controls[t]+e;this.el.setAttribute(n,{enabled:this.data.enabled})}},injectControls:function(){const t=this.data;for(let n=0;n<t.controls.length;n++){const r=t.controls[n]+e;this.el.setAttribute(r,{enabled:this.data.enabled})}},updateNavLocation:function(){this.navGroup=null,this.navNode=null},tick:function(){const e=new THREE.Vector3,t=new THREE.Vector3,n=new THREE.Vector3;return function(r,o){if(!o)return;const i=this.el,a=this.data;if(!a.enabled)return;this.updateVelocityCtrl();const s=this.velocityCtrl,c=this.velocity;if(s)if(o/1e3>.2?c.set(0,0,0):this.updateVelocity(o),a.constrainToNavMesh&&!1!==s.isNavMeshConstrained){if(c.lengthSq()<1e-5)return;e.copy(i.object3D.position),t.copy(c).multiplyScalar(o/1e3).add(e);const r=i.sceneEl.systems.nav;this.navGroup=null===this.navGroup?r.getGroup(e):this.navGroup,this.navNode=this.navNode||r.getNode(e,this.navGroup),this.navNode=r.clampStep(e,t,this.navGroup,this.navNode,n),i.object3D.position.copy(n)}else i.hasAttribute("velocity")?i.setAttribute("velocity",c):(i.object3D.position.x+=c.x*o/1e3,i.object3D.position.y+=c.y*o/1e3,i.object3D.position.z+=c.z*o/1e3)}}(),updateVelocityCtrl:function(){const t=this.data;if(t.enabled){for(let n=0,r=t.controls.length;n<r;n++){const r=this.el.components[t.controls[n]+e];if(r&&r.isVelocityActive())return void(this.velocityCtrl=r)}this.velocityCtrl=null}},updateVelocity:function(){const e=new THREE.Vector2,t=new THREE.Quaternion;return function(n){let r;const o=this.el,i=this.velocityCtrl,a=this.velocity,s=this.data;if(i){if(!i.getVelocityDelta){if(i.getVelocity)return void a.copy(i.getVelocity());if(i.getPositionDelta)return void a.copy(i.getPositionDelta(n).multiplyScalar(1e3/n));throw new Error("Incompatible movement controls: ",i)}r=i.getVelocityDelta(n)}if(o.hasAttribute("velocity")&&!s.constrainToNavMesh&&a.copy(this.el.getAttribute("velocity")),r&&s.enabled){const n=s.camera;t.copy(n.object3D.quaternion),t.premultiply(o.object3D.quaternion),r.applyQuaternion(t);const i=r.length();s.fly?(a.copy(r),a.multiplyScalar(16.66667*this.data.speed)):(e.set(r.x,r.z),e.setLength(i*this.data.speed*16.66667),a.x=e.x,a.y=0,a.z=e.y),0===a.x&&0===a.y&&0===a.z||(this.eventDetail.velocity=a,this.el.emit("moved",this.eventDetail))}}}()})}(),M||(M=1,AFRAME.registerComponent("trackpad-controls",{schema:{enabled:{default:!0},enableNegX:{default:!0},enablePosX:{default:!0},enableNegZ:{default:!0},enablePosZ:{default:!0},mode:{default:"touch",oneOf:["swipe","touch","press"]}},init:function(){this.dVelocity=new THREE.Vector3,this.zVel=0,this.xVel=0,this.bindMethods()},play:function(){this.addEventListeners()},pause:function(){this.removeEventListeners(),this.dVelocity.set(0,0,0)},remove:function(){this.pause()},addEventListeners:function(){const e=this.data,t=this.el.sceneEl;switch(t.addEventListener("axismove",this.onAxisMove),e.mode){case"swipe":case"touch":t.addEventListener("trackpadtouchstart",this.onTouchStart),t.addEventListener("trackpadtouchend",this.onTouchEnd);break;case"press":t.addEventListener("trackpaddown",this.onTouchStart),t.addEventListener("trackpadup",this.onTouchEnd)}},removeEventListeners:function(){const e=this.el.sceneEl;e.removeEventListener("axismove",this.onAxisMove),e.removeEventListener("trackpadtouchstart",this.onTouchStart),e.removeEventListener("trackpadtouchend",this.onTouchEnd),e.removeEventListener("trackpaddown",this.onTouchStart),e.removeEventListener("trackpadup",this.onTouchEnd)},isVelocityActive:function(){return this.data.enabled&&this.isMoving},getVelocityDelta:function(){return this.dVelocity.z=this.isMoving?-this.zVel:1,this.dVelocity.x=this.isMoving?this.xVel:1,this.dVelocity.clone()},bindMethods:function(){this.onTouchStart=this.onTouchStart.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this),this.onAxisMove=this.onAxisMove.bind(this)},onTouchStart:function(e){switch(this.data.mode){case"swipe":this.canRecordAxis=!0,this.startingAxisData=[];break;case"touch":case"press":this.isMoving=!0}e.preventDefault()},onTouchEnd:function(e){"swipe"==this.data.mode&&(this.startingAxisData=[]),this.isMoving=!1,e.preventDefault()},onAxisMove:function(e){switch(this.data.mode){case"swipe":return this.handleSwipeAxis(e);case"touch":case"press":return this.handleTouchAxis(e)}},handleSwipeAxis:function(e){const t=this.data,n=e.detail.axis;if(0===this.startingAxisData.length&&this.canRecordAxis&&(this.canRecordAxis=!1,this.startingAxisData[0]=n[0],this.startingAxisData[1]=n[1]),this.startingAxisData.length>0){let e=0,r=0;t.enableNegX&&n[0]<this.startingAxisData[0]&&(e=-1),t.enablePosX&&n[0]>this.startingAxisData[0]&&(e=1),t.enablePosZ&&n[1]>this.startingAxisData[1]&&(r=-1),t.enableNegZ&&n[1]<this.startingAxisData[1]&&(r=1);const o=Math.abs(this.startingAxisData[1]-n[1]);Math.abs(this.startingAxisData[0]-n[0])>o?(this.zVel=0,this.xVel=e,this.isMoving=!0):(this.xVel=0,this.zVel=r,this.isMoving=!0)}},handleTouchAxis:function(e){const t=this.data,n=e.detail.axis;let r=0,o=0;t.enableNegX&&n[0]<0&&(r=-1),t.enablePosX&&n[0]>0&&(r=1),t.enablePosZ&&n[1]>0&&(o=