1 |
- !function e(t,o,i){function n(c,s){if(!o[c]){if(!t[c]){var r="function"==typeof require&&require;if(!s&&r)return r(c,!0);if(a)return a(c,!0);var d=new Error("Cannot find module '"+c+"'");throw d.code="MODULE_NOT_FOUND",d}var h=o[c]={exports:{}};t[c][0].call(h.exports,function(e){var o=t[c][1][e];return n(o||e)},h,h.exports,e,t,o,i)}return o[c].exports}for(var a="function"==typeof require&&require,c=0;c<i.length;c++)n(i[c]);return n}({1:[function(e,t,o){"use strict";e("./src/controls")},{"./src/controls":7}],2:[function(e,t,o){"use strict";t.exports=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})},{}],3:[function(e,t,o){"use strict";t.exports=function(e,t,o){this.type=e,this.index=t,this.pressed=o.pressed,this.value=o.value}},{}],4:[function(e,t,o){"use strict";!function(e){function t(e,t){return-1!==String(e).indexOf(t)}function o(e,t,o){l!==t&&h!==t&&d!==t||Object.keys(o).forEach(function(t){e[t]=o[t]})}function i(e){var t="keyCode"in e?e.keyCode:"which"in e?e.which:0,o=function(){if(m||"keyLocation"in e){var o=m?e.location:e.keyLocation;if(o&&t in p[o])return p[o][t]}return"keyIdentifier"in e&&e.keyIdentifier in u?u[e.keyIdentifier]:t in y?y[t]:null}();if(!o)return null;var i=function(){var t=f[o.code];return t?e.shiftKey&&"shiftKey"in t?t.shiftKey:t.key:o.code}();return{code:o.code,key:i,location:o.location,keyCap:o.keyCap}}var n="KeyboardEvent"in e;n||(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 a=window.KeyboardEvent.DOM_KEY_LOCATION_STANDARD,c=window.KeyboardEvent.DOM_KEY_LOCATION_LEFT,s=window.KeyboardEvent.DOM_KEY_LOCATION_RIGHT,r=window.KeyboardEvent.DOM_KEY_LOCATION_NUMPAD,d=t(navigator.platform,"Win")?"win":t(navigator.platform,"Mac")?"mac":t(navigator.platform,"CrOS")?"cros":t(navigator.platform,"Linux")?"linux":t(navigator.userAgent,"iPad")||t(navigator.platform,"iPod")||t(navigator.platform,"iPhone")?"ios":"",h=t(navigator.userAgent,"Chrome/")?"chrome":t(navigator.vendor,"Apple")?"safari":t(navigator.userAgent,"MSIE")?"ie":t(navigator.userAgent,"Gecko/")?"moz":t(navigator.userAgent,"Opera/")?"opera":"",l=h+"-"+d,y={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:c},92:{code:"OSRight",location:s},93:{code:"ContextMenu"},95:{code:"Standby"},96:{code:"Numpad0",keyCap:"0",location:r},97:{code:"Numpad1",keyCap:"1",location:r},98:{code:"Numpad2",keyCap:"2",location:r},99:{code:"Numpad3",keyCap:"3",location:r},100:{code:"Numpad4",keyCap:"4",location:r},101:{code:"Numpad5",keyCap:"5",location:r},102:{code:"Numpad6",keyCap:"6",location:r},103:{code:"Numpad7",keyCap:"7",location:r},104:{code:"Numpad8",keyCap:"8",location:r},105:{code:"Numpad9",keyCap:"9",location:r},106:{code:"NumpadMultiply",keyCap:"*",location:r},107:{code:"NumpadAdd",keyCap:"+",location:r},108:{code:"NumpadComma",keyCap:",",location:r},109:{code:"NumpadSubtract",keyCap:"-",location:r},110:{code:"NumpadDecimal",keyCap:".",location:r},111:{code:"NumpadDivide",keyCap:"/",location:r},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:r},145:{code:"ScrollLock"},160:{code:"ShiftLeft",location:c},161:{code:"ShiftRight",location:s},162:{code:"ControlLeft",location:c},163:{code:"ControlRight",location:s},164:{code:"AltLeft",location:c},165:{code:"AltRight",location:s},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"}};o(y,"moz",{59:{code:"Semicolon",keyCap:";"},61:{code:"Equal",keyCap:"="},107:{code:"Equal",keyCap:"="},109:{code:"Minus",keyCap:"-"},187:{code:"NumpadAdd",keyCap:"+",location:r},189:{code:"NumpadSubtract",keyCap:"-",location:r}}),o(y,"moz-mac",{12:{code:"NumLock",location:r},173:{code:"Minus",keyCap:"-"}}),o(y,"moz-win",{173:{code:"Minus",keyCap:"-"}}),o(y,"chrome-mac",{93:{code:"OSRight",location:s}}),o(y,"safari",{3:{code:"Enter"},25:{code:"Tab"}}),o(y,"ios",{10:{code:"Enter",location:a}}),o(y,"safari-mac",{91:{code:"OSLeft",location:c},93:{code:"OSRight",location:s},229:{code:"KeyQ",keyCap:"Q"}});var u={};"cros"===d&&(u["U+00A0"]={code:"ShiftLeft",location:c},u["U+00A1"]={code:"ShiftRight",location:s},u["U+00A2"]={code:"ControlLeft",location:c},u["U+00A3"]={code:"ControlRight",location:s},u["U+00A4"]={code:"AltLeft",location:c},u["U+00A5"]={code:"AltRight",location:s}),"chrome-mac"===l&&(u["U+0010"]={code:"ContextMenu"}),"safari-mac"===l&&(u["U+0010"]={code:"ContextMenu"}),"ios"===d&&(u["U+0010"]={code:"Function"},u["U+001C"]={code:"ArrowLeft"},u["U+001D"]={code:"ArrowRight"},u["U+001E"]={code:"ArrowUp"},u["U+001F"]={code:"ArrowDown"},u["U+0001"]={code:"Home"},u["U+0004"]={code:"End"},u["U+000B"]={code:"PageUp"},u["U+000C"]={code:"PageDown"});var p=[];p[c]={16:{code:"ShiftLeft",location:c},17:{code:"ControlLeft",location:c},18:{code:"AltLeft",location:c}},p[s]={16:{code:"ShiftRight",location:s},17:{code:"ControlRight",location:s},18:{code:"AltRight",location:s}},p[r]={13:{code:"NumpadEnter",location:r}},o(p[r],"moz",{109:{code:"NumpadSubtract",location:r},107:{code:"NumpadAdd",location:r}}),o(p[c],"moz-mac",{224:{code:"OSLeft",location:c}}),o(p[s],"moz-mac",{224:{code:"OSRight",location:s}}),o(p[s],"moz-win",{91:{code:"OSRight",location:s}}),o(p[s],"mac",{93:{code:"OSRight",location:s}}),o(p[r],"chrome-mac",{12:{code:"NumLock",location:r}}),o(p[r],"safari-mac",{12:{code:"NumLock",location:r},187:{code:"NumpadAdd",location:r},189:{code:"NumpadSubtract",location:r},190:{code:"NumpadDecimal",location:r},191:{code:"NumpadDivide",location:r}});var f={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:"|"}};o(f,"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=function(e,t){var o={};return Object.keys(e).forEach(function(i){var n=e[i];t in n&&(o[n[t]]=n)}),o}(y,"code");try{var m=n&&"location"in new KeyboardEvent("")}catch(e){}"KeyboardEvent"in e&&"defineProperty"in Object&&function(){function e(e,t,o){t in e||Object.defineProperty(e,t,o)}if(e(KeyboardEvent.prototype,"code",{get:function(){var e=i(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=i(this);return e&&"key"in e?e.key:"Unidentified"}}),e(KeyboardEvent.prototype,"location",{get:function(){var e=i(this);return e&&"location"in e?e.location:a}}),e(KeyboardEvent.prototype,"locale",{get:function(){return""}})}(),"queryKeyCap"in e.KeyboardEvent||(e.KeyboardEvent.queryKeyCap=function(e,t){if(e=String(e),!k.hasOwnProperty(e))return"Undefined";if(t&&"en-us"!==String(t).toLowerCase())throw Error("Unsupported locale");var o=k[e];return o.keyCap||o.code||"Undefined"}),e.identifyKey=function(e){if(!("code"in e)){var t=i(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:a,e.locale=""}}}(window)},{}],5:[function(e,t,o){"use strict";t.exports=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){var 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){var e=this.data,t=this.offset,o=this.position,i=this.targetPosition,n=this.checkpoint;return this.sync(),o.distanceTo(i)<.1?(this.checkpoint=null,this.el.emit("navigation-end",{checkpoint:n}),t.set(0,0,0)):(t.setLength(e.animateSpeed),t)}},sync:function(){var e=this.offset,t=this.position,o=this.targetPosition;t.copy(this.el.getAttribute("position")),this.checkpoint.object3D.getWorldPosition(o),o.add(this.checkpoint.components.checkpoint.getOffset()),e.copy(o).sub(t)}})},{}],6:[function(e,t,o){"use strict";var i=e("../../lib/GamepadButton"),n=e("../../lib/GamepadButtonEvent"),a={MOVEMENT:1,ROTATION:2};t.exports=AFRAME.registerComponent("gamepad-controls",{GamepadButton:i,schema:{controller:{default:0,oneOf:[0,1,2,3]},enabled:{default:!0},debug:{default:!1},camera:{default:"[camera]",type:"selector"},rotationSensitivity:{default:2}},init:function(){var e=this.el.sceneEl;this.system=e.systems["tracked-controls-webxr"]||{controllers:[]},this.prevTime=window.performance.now(),this.buttons={};var t=this.el.object3D.rotation;this.pitch=new THREE.Object3D,this.pitch.rotation.x=THREE.Math.degToRad(t.x),this.yaw=new THREE.Object3D,this.yaw.position.y=10,this.yaw.rotation.y=THREE.Math.degToRad(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;var e=this._dpadVector,t=this._moveVector;this.getDpad(e),this.getJoystick(a.MOVEMENT,t);var o=e.x||t.x,i=e.y||t.y;return Math.abs(o)>.2||Math.abs(i)>.2},getVelocityDelta:function(){var e=this._dpadVector,t=this._moveVector;this.getDpad(e),this.getJoystick(a.MOVEMENT,t);var o=e.x||t.x,i=e.y||t.y,n=new THREE.Vector3;return Math.abs(o)>.2&&(n.x+=o),Math.abs(i)>.2&&(n.z+=i),n},isRotationActive:function(){if(!this.data.enabled||!this.isConnected())return!1;var e=this._lookVector;return this.getJoystick(a.ROTATION,e),Math.abs(e.x)>.2||Math.abs(e.y)>.2},updateRotation:function(e){if(this.isRotationActive()){var t=this.data,o=this.yaw,i=this.pitch,n=t.camera.components["look-controls"],c=n&&n.pitchObject&&n.yawObject;c&&(i.rotation.copy(n.pitchObject.rotation),o.rotation.copy(n.yawObject.rotation));var s=this._lookVector;this.getJoystick(a.ROTATION,s),Math.abs(s.x)<=.2&&(s.x=0),Math.abs(s.y)<=.2&&(s.y=0),s.multiplyScalar(t.rotationSensitivity*e/1e3),o.rotation.y-=s.x,i.rotation.x-=s.y,i.rotation.x=Math.max(-Math.PI/2,Math.min(Math.PI/2,i.rotation.x)),t.camera.object3D.rotation.set(i.rotation.x,o.rotation.y,0),c&&(n.pitchObject.rotation.copy(i.rotation),n.yawObject.rotation.copy(o.rotation))}},updateButtonState:function(){var e=this.getGamepad();if(this.data.enabled&&e)for(var t=0;t<e.buttons.length;t++)e.buttons[t].pressed&&!this.buttons[t]?this.emit(new n("gamepadbuttondown",t,e.buttons[t])):!e.buttons[t].pressed&&this.buttons[t]&&this.emit(new n("gamepadbuttonup",t,e.buttons[t])),this.buttons[t]=e.buttons[t].pressed;else Object.keys(this.buttons)&&(this.buttons={})},emit:function(e){this.el.emit(e.type,e),this.el.emit(e.type+":"+e.index,new n(e.type,e.index,e))},getGamepad:function(){var e=navigator.getGamepads&&navigator.getGamepads()[this.data.controller],t=this.system.controllers[this.data.controller],o=t&&t.gamepad,i=this.el.sceneEl.components["proxy-controls"];return i&&i.isConnected()&&i.getGamepad(this.data.controller)||o||e},getButton:function(e){return this.getGamepad().buttons[e]},getAxis:function(e){return this.getGamepad().axes[e]},getJoystick:function(e,t){var o=this.getGamepad();if("xr-standard"===o.mapping)switch(e){case a.MOVEMENT:return t.set(o.axes[2],o.axes[3]);case a.ROTATION:return t.set(o.axes[0],o.axes[1])}else switch(e){case a.MOVEMENT:return t.set(o.axes[0],o.axes[1]);case a.ROTATION:return t.set(o.axes[2],o.axes[3])}throw new Error('Unexpected joystick index "%d".',e)},getDpad:function(e){var t=this.getGamepad();return t.buttons[i.DPAD_RIGHT]?e.set((t.buttons[i.DPAD_RIGHT].pressed?1:0)+(t.buttons[i.DPAD_LEFT].pressed?-1:0),(t.buttons[i.DPAD_UP].pressed?-1:0)+(t.buttons[i.DPAD_DOWN].pressed?1:0)):e.set(0,0)},isConnected:function(){var e=this.getGamepad();return!(!e||!e.connected)},getID:function(){return this.getGamepad().id}})},{"../../lib/GamepadButton":2,"../../lib/GamepadButtonEvent":3}],7:[function(e,t,o){"use strict";e("./checkpoint-controls"),e("./gamepad-controls"),e("./keyboard-controls"),e("./touch-controls"),e("./movement-controls"),e("./trackpad-controls")},{"./checkpoint-controls":5,"./gamepad-controls":6,"./keyboard-controls":8,"./movement-controls":9,"./touch-controls":10,"./trackpad-controls":11}],8:[function(e,t,o){"use strict";e("../../lib/keyboard.polyfill");var i=window.KeyboardEvent;t.exports=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)},this.attachEventListeners()},isVelocityActive:function(){return this.data.enabled&&!!Object.keys(this.getKeys()).length},getVelocityDelta:function(){var 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)),this.dVelocity.clone()},play:function(){this.attachEventListeners()},pause:function(){this.removeEventListeners()},remove:function(){this.pause()},attachEventListeners:function(){window.addEventListener("keydown",this.listeners.keydown,!1),window.addEventListener("keyup",this.listeners.keyup,!1),window.addEventListener("blur",this.listeners.blur,!1)},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(var e in this.localKeys)this.localKeys.hasOwnProperty(e)&&delete this.localKeys[e]},emit:function(e){"__keyboard-controls-proxy"in e&&this.el.emit(e.type,e),this.el.emit(e.type+":"+e.code,new i(e.type,e)),this.data.debug&&console.log(e.type+":"+e.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(){var e=this.el.sceneEl.components["proxy-controls"];return e&&e.isConnected()}})},{"../../lib/keyboard.polyfill":4}],9:[function(e,t,o){"use strict";t.exports=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(){var e=this.el;this.velocityCtrl=null,this.velocity=new THREE.Vector3,this.heading=new THREE.Quaternion,this.navGroup=null,this.navNode=null,e.sceneEl.hasLoaded?this.injectControls():e.sceneEl.addEventListener("loaded",this.injectControls.bind(this))},update:function(e){var t=this.el,o=this.data,i=t.sceneEl.systems.nav;t.sceneEl.hasLoaded&&this.injectControls(),i&&o.constrainToNavMesh!==e.constrainToNavMesh&&(o.constrainToNavMesh?i.addAgent(this):i.removeAgent(this))},injectControls:function(){for(var e,t=this.data,o=0;o<t.controls.length;o++)e=t.controls[o]+"-controls",this.el.components[e]||this.el.setAttribute(e,"")},updateNavLocation:function(){this.navGroup=null,this.navNode=null},tick:function(){var e=new THREE.Vector3,t=new THREE.Vector3,o=new THREE.Vector3;return function(i,n){if(n){var a=this.el,c=this.data;if(c.enabled){this.updateVelocityCtrl();var s=this.velocityCtrl,r=this.velocity;if(s)if(n/1e3>.2?r.set(0,0,0):this.updateVelocity(n),c.constrainToNavMesh&&!1!==s.isNavMeshConstrained){if(r.lengthSq()<1e-5)return;e.copy(a.object3D.position),t.copy(r).multiplyScalar(n/1e3).add(e);var d=a.sceneEl.systems.nav;this.navGroup=null===this.navGroup?d.getGroup(e):this.navGroup,this.navNode=this.navNode||d.getNode(e,this.navGroup),this.navNode=d.clampStep(e,t,this.navGroup,this.navNode,o),a.object3D.position.copy(o)}else a.hasAttribute("velocity")?a.setAttribute("velocity",r):(a.object3D.position.x+=r.x*n/1e3,a.object3D.position.y+=r.y*n/1e3,a.object3D.position.z+=r.z*n/1e3)}}}}(),updateVelocityCtrl:function(){var e=this.data;if(e.enabled){for(var t=0,o=e.controls.length;t<o;t++){var i=this.el.components[e.controls[t]+"-controls"];if(i&&i.isVelocityActive())return void(this.velocityCtrl=i)}this.velocityCtrl=null}},updateVelocity:function(){var e=new THREE.Vector2,t=new THREE.Quaternion;return function(o){var i=void 0,n=this.el,a=this.velocityCtrl,c=this.velocity,s=this.data;if(a){if(!a.getVelocityDelta){if(a.getVelocity)return void c.copy(a.getVelocity());if(a.getPositionDelta)return void c.copy(a.getPositionDelta(o).multiplyScalar(1e3/o));throw new Error("Incompatible movement controls: ",a)}i=a.getVelocityDelta(o)}if(n.hasAttribute("velocity")&&!s.constrainToNavMesh&&c.copy(this.el.getAttribute("velocity")),i&&s.enabled){var r=s.camera;t.copy(r.object3D.quaternion),t.premultiply(n.object3D.quaternion),i.applyQuaternion(t);var d=i.length();s.fly?(c.copy(i),c.multiplyScalar(16.66667*this.data.speed)):(e.set(i.x,i.z),e.setLength(d*this.data.speed*16.66667),c.x=e.x,c.z=e.y)}}}()})},{}],10:[function(e,t,o){"use strict";t.exports=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(){var e=this.el.sceneEl,t=e.canvas;t?(t.addEventListener("touchstart",this.onTouchStart),t.addEventListener("touchend",this.onTouchEnd)):e.addEventListener("render-target-loaded",this.addEventListeners.bind(this))},removeEventListeners:function(){var e=this.el.sceneEl&&this.el.sceneEl.canvas;e&&(e.removeEventListener("touchstart",this.onTouchStart),e.removeEventListener("touchend",this.onTouchEnd))},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)},onTouchStart:function(e){this.direction=-1,this.data.reverseEnabled&&2===e.touches.length&&(this.direction=1),e.preventDefault()},onTouchEnd:function(e){this.direction=0,e.preventDefault()}})},{}],11:[function(e,t,o){"use strict";t.exports=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(){var 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(){var 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){var t=this.data,o=e.detail.axis;if(0===this.startingAxisData.length&&this.canRecordAxis&&(this.canRecordAxis=!1,this.startingAxisData[0]=o[0],this.startingAxisData[1]=o[1]),this.startingAxisData.length>0){var i=0,n=0;t.enableNegX&&o[0]<this.startingAxisData[0]&&(i=-1),t.enablePosX&&o[0]>this.startingAxisData[0]&&(i=1),t.enablePosZ&&o[1]>this.startingAxisData[1]&&(n=-1),t.enableNegZ&&o[1]<this.startingAxisData[1]&&(n=1);var a=Math.abs(this.startingAxisData[1]-o[1]);Math.abs(this.startingAxisData[0]-o[0])>a?(this.zVel=0,this.xVel=i,this.isMoving=!0):(this.xVel=0,this.zVel=n,this.isMoving=!0)}},handleTouchAxis:function(e){var t=this.data,o=e.detail.axis,i=0,n=0;t.enableNegX&&o[0]<0&&(i=-1),t.enablePosX&&o[0]>0&&(i=1),t.enablePosZ&&o[1]>0&&(n=-1),t.enableNegZ&&o[1]<0&&(n=1),Math.abs(o[0])>Math.abs(o[1])?(this.zVel=0,this.xVel=i):(this.xVel=0,this.zVel=n)}})},{}]},{},[1]);
|