aframe-extras
Advanced tools
Comparing version 5.1.0 to 6.0.0
@@ -878,3 +878,3 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
position.copy(this.el.getAttribute('position')); | ||
targetPosition.copy(this.checkpoint.object3D.getWorldPosition()); | ||
this.checkpoint.object3D.getWorldPosition(targetPosition); | ||
targetPosition.add(this.checkpoint.components.checkpoint.getOffset()); | ||
@@ -881,0 +881,0 @@ offset.copy(targetPosition).sub(position); |
@@ -1,1 +0,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")),o.copy(this.checkpoint.object3D.getWorldPosition()),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");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.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),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.getDpad(),t=this.getJoystick(0),o=e.x||t.x,i=e.y||t.y;return Math.abs(o)>.2||Math.abs(i)>.2},getVelocityDelta:function(){var e=this.getDpad(),t=this.getJoystick(0),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.getJoystick(1);return 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"],a=n&&n.pitchObject&&n.yawObject;a&&(i.rotation.copy(n.pitchObject.rotation),o.rotation.copy(n.yawObject.rotation));var c=this.getJoystick(1);Math.abs(c.x)<=.2&&(c.x=0),Math.abs(c.y)<=.2&&(c.y=0),c.multiplyScalar(t.rotationSensitivity*e/1e3),o.rotation.y-=c.x,i.rotation.x-=c.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),a&&(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.el.sceneEl.components["proxy-controls"];return t&&t.isConnected()&&t.getGamepad(this.data.controller)||e},getButton:function(e){return this.getGamepad().buttons[e]},getAxis:function(e){return this.getGamepad().axes[e]},getJoystick:function(e){var t=this.getGamepad();switch(e){case 0:return new THREE.Vector2(t.axes[0],t.axes[1]);case 1:return new THREE.Vector2(t.axes[2],t.axes[3]);default:throw new Error('Unexpected joystick index "%d".',e)}},getDpad:function(){var e=this.getGamepad();return e.buttons[i.DPAD_RIGHT]?new THREE.Vector2((e.buttons[i.DPAD_RIGHT].pressed?1:0)+(e.buttons[i.DPAD_LEFT].pressed?-1:0),(e.buttons[i.DPAD_UP].pressed?-1:0)+(e.buttons[i.DPAD_DOWN].pressed?1:0)):new THREE.Vector2},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]); | ||
!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");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.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),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.getDpad(),t=this.getJoystick(0),o=e.x||t.x,i=e.y||t.y;return Math.abs(o)>.2||Math.abs(i)>.2},getVelocityDelta:function(){var e=this.getDpad(),t=this.getJoystick(0),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.getJoystick(1);return 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"],a=n&&n.pitchObject&&n.yawObject;a&&(i.rotation.copy(n.pitchObject.rotation),o.rotation.copy(n.yawObject.rotation));var c=this.getJoystick(1);Math.abs(c.x)<=.2&&(c.x=0),Math.abs(c.y)<=.2&&(c.y=0),c.multiplyScalar(t.rotationSensitivity*e/1e3),o.rotation.y-=c.x,i.rotation.x-=c.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),a&&(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.el.sceneEl.components["proxy-controls"];return t&&t.isConnected()&&t.getGamepad(this.data.controller)||e},getButton:function(e){return this.getGamepad().buttons[e]},getAxis:function(e){return this.getGamepad().axes[e]},getJoystick:function(e){var t=this.getGamepad();switch(e){case 0:return new THREE.Vector2(t.axes[0],t.axes[1]);case 1:return new THREE.Vector2(t.axes[2],t.axes[3]);default:throw new Error('Unexpected joystick index "%d".',e)}},getDpad:function(){var e=this.getGamepad();return e.buttons[i.DPAD_RIGHT]?new THREE.Vector2((e.buttons[i.DPAD_RIGHT].pressed?1:0)+(e.buttons[i.DPAD_LEFT].pressed?-1:0),(e.buttons[i.DPAD_UP].pressed?-1:0)+(e.buttons[i.DPAD_DOWN].pressed?1:0)):new THREE.Vector2},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]); |
@@ -679,2 +679,4 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
colliderScale = new THREE.Vector3(), | ||
size = new THREE.Vector3(), | ||
box = new THREE.Box3(), | ||
distanceMap = new Map(); | ||
@@ -693,3 +695,3 @@ return function () { | ||
distanceMap.clear(); | ||
position.copy(el.object3D.getWorldPosition()); | ||
el.object3D.getWorldPosition(position); | ||
el.object3D.getWorldScale(colliderScale); | ||
@@ -723,5 +725,3 @@ colliderRadius = data.radius * scaleFactor(colliderScale); | ||
distance = void 0, | ||
box = void 0, | ||
extent = void 0, | ||
size = void 0; | ||
extent = void 0; | ||
@@ -738,4 +738,3 @@ if (!el.isEntity) { | ||
box = new THREE.Box3().setFromObject(mesh); | ||
size = box.getSize(); | ||
box.setFromObject(mesh).getSize(size); | ||
extent = Math.max(size.x, size.y, size.z) / 2; | ||
@@ -742,0 +741,0 @@ radius = Math.sqrt(2 * extent * extent); |
@@ -1,1 +0,1 @@ | ||
!function t(e,i,n){function s(r,a){if(!i[r]){if(!e[r]){var l="function"==typeof require&&require;if(!a&&l)return l(r,!0);if(o)return o(r,!0);var h=new Error("Cannot find module '"+r+"'");throw h.code="MODULE_NOT_FOUND",h}var c=i[r]={exports:{}};e[r][0].call(c.exports,function(t){var i=e[r][1][t];return s(i||t)},c,c.exports,t,e,i,n)}return i[r].exports}for(var o="function"==typeof require&&require,r=0;r<n.length;r++)s(n[r]);return s}({1:[function(t,e,i){"use strict";t("./src/misc")},{"./src/misc":5}],2:[function(t,e,i){"use strict";e.exports=AFRAME.registerComponent("checkpoint",{schema:{offset:{default:{x:0,y:0,z:0},type:"vec3"}},init:function(){this.active=!1,this.targetEl=null,this.fire=this.fire.bind(this),this.offset=new THREE.Vector3},update:function(){this.offset.copy(this.data.offset)},play:function(){this.el.addEventListener("click",this.fire)},pause:function(){this.el.removeEventListener("click",this.fire)},remove:function(){this.pause()},fire:function(){var t=this.el.sceneEl.querySelector("[checkpoint-controls]");if(!t)throw new Error("No `checkpoint-controls` component found.");t.components["checkpoint-controls"].setCheckpoint(this.el)},getOffset:function(){return this.offset.copy(this.data.offset)}})},{}],3:[function(t,e,i){"use strict";function n(t,e,i,n){t&&(e=e||[],t.traverse(function(t){if(t.isMesh){(function(t){return t?Array.isArray(t)?t:t.materials?t.materials:[t]:[]})(t.material).forEach(function(t){(!t||"envMap"in t)&&(e.length&&-1===e.indexOf(t.name)||(t.envMap=i,t.reflectivity=n,t.needsUpdate=!0))})}}))}e.exports=AFRAME.registerComponent("cube-env-map",{multiple:!0,schema:{path:{default:""},extension:{default:"jpg",oneOf:["jpg","png"]},format:{default:"RGBFormat",oneOf:["RGBFormat","RGBAFormat"]},enableBackground:{default:!1},reflectivity:{default:1,min:0,max:1},materials:{default:[]}},init:function(){var t=this,e=this.data;this.texture=(new THREE.CubeTextureLoader).load([e.path+"posx."+e.extension,e.path+"negx."+e.extension,e.path+"posy."+e.extension,e.path+"negy."+e.extension,e.path+"posz."+e.extension,e.path+"negz."+e.extension]),this.texture.format=THREE[e.format],this.object3dsetHandler=function(){var e=t.el.getObject3D("mesh"),i=t.data;n(e,i.materials,t.texture,i.reflectivity)},this.el.addEventListener("object3dset",this.object3dsetHandler)},update:function(t){var e=this.data,i=this.el.getObject3D("mesh"),s=[],o=[];if(e.materials.length&&(t.materials?(s=e.materials.filter(function(e){return!t.materials.includes(e)}),o=t.materials.filter(function(t){return!e.materials.includes(t)})):s=e.materials),s.length&&n(i,s,this.texture,e.reflectivity),o.length&&n(i,o,null,1),t.materials&&e.reflectivity!==t.reflectivity){var r=e.materials.filter(function(e){return t.materials.includes(e)});r.length&&n(i,r,this.texture,e.reflectivity)}this.data.enableBackground&&!t.enableBackground?this.setBackground(this.texture):!this.data.enableBackground&&t.enableBackground&&this.setBackground(null)},remove:function(){this.el.removeEventListener("object3dset",this.object3dsetHandler);var t=this.el.getObject3D("mesh"),e=this.data;n(t,e.materials,null,1),e.enableBackground&&this.setBackground(null)},setBackground:function(t){this.el.sceneEl.object3D.background=t}})},{}],4:[function(t,e,i){"use strict";e.exports=AFRAME.registerComponent("grab",{init:function(){this.system=this.el.sceneEl.systems.physics,this.GRABBED_STATE="grabbed",this.grabbing=!1,this.hitEl=null,this.physics=this.el.sceneEl.systems.physics,this.constraint=null,this.onHit=this.onHit.bind(this),this.onGripOpen=this.onGripOpen.bind(this),this.onGripClose=this.onGripClose.bind(this)},play:function(){var t=this.el;t.addEventListener("hit",this.onHit),t.addEventListener("gripdown",this.onGripClose),t.addEventListener("gripup",this.onGripOpen),t.addEventListener("trackpaddown",this.onGripClose),t.addEventListener("trackpadup",this.onGripOpen),t.addEventListener("triggerdown",this.onGripClose),t.addEventListener("triggerup",this.onGripOpen)},pause:function(){var t=this.el;t.removeEventListener("hit",this.onHit),t.removeEventListener("gripdown",this.onGripClose),t.removeEventListener("gripup",this.onGripOpen),t.removeEventListener("trackpaddown",this.onGripClose),t.removeEventListener("trackpadup",this.onGripOpen),t.removeEventListener("triggerdown",this.onGripClose),t.removeEventListener("triggerup",this.onGripOpen)},onGripClose:function(){this.grabbing=!0},onGripOpen:function(){var t=this.hitEl;this.grabbing=!1,t&&(t.removeState(this.GRABBED_STATE),this.hitEl=void 0,this.system.removeConstraint(this.constraint),this.constraint=null)},onHit:function(t){var e=t.detail.el;e&&!e.is(this.GRABBED_STATE)&&this.grabbing&&!this.hitEl&&(e.addState(this.GRABBED_STATE),this.hitEl=e,this.constraint=new CANNON.LockConstraint(this.el.body,e.body),this.system.addConstraint(this.constraint))}})},{}],5:[function(t,e,i){"use strict";t("./checkpoint"),t("./cube-env-map"),t("./grab"),t("./jump-ability"),t("./kinematic-body"),t("./mesh-smooth"),t("./normal-material"),t("./sphere-collider")},{"./checkpoint":2,"./cube-env-map":3,"./grab":4,"./jump-ability":6,"./kinematic-body":7,"./mesh-smooth":8,"./normal-material":9,"./sphere-collider":10}],6:[function(t,e,i){"use strict";e.exports=AFRAME.registerComponent("jump-ability",{dependencies:["velocity"],schema:{on:{default:"keydown:Space gamepadbuttondown:0"},playerHeight:{default:1.764},maxJumps:{default:1},distance:{default:5},debug:{default:!1}},init:function(){this.velocity=0,this.numJumps=0;var t=this.beginJump.bind(this),e=this.data.on.split(" ");this.bindings={};for(var i=0;i<e.length;i++)this.bindings[e[i]]=t,this.el.addEventListener(e[i],t);this.bindings.collide=this.onCollide.bind(this),this.el.addEventListener("collide",this.bindings.collide)},remove:function(){for(var t in this.bindings)this.bindings.hasOwnProperty(t)&&(this.el.removeEventListener(t,this.bindings[t]),delete this.bindings[t]);this.el.removeEventListener("collide",this.bindings.collide),delete this.bindings.collide},beginJump:function(){if(this.numJumps<this.data.maxJumps){var t=this.data,e=Math.sqrt(-2*t.distance*-24.8),i=this.el.getAttribute("velocity");this.el.setAttribute("velocity",{x:i.x,y:e,z:i.z}),this.numJumps++,this.el.emit("jumpstart")}},onCollide:function(){this.numJumps>0&&this.el.emit("jumpend"),this.numJumps=0}})},{}],7:[function(t,e,i){"use strict";e.exports=AFRAME.registerComponent("kinematic-body",{dependencies:["velocity"],schema:{mass:{default:5},radius:{default:1.3},linearDamping:{default:.05},enableSlopes:{default:!0},enableJumps:{default:!1}},init:function(){this.system=this.el.sceneEl.systems.physics,this.system.addComponent(this);var t=this.el,e=this.data,i=(new CANNON.Vec3).copy(t.object3D.getWorldPosition(new THREE.Vector3));this.body=new CANNON.Body({material:this.system.getMaterial("staticMaterial"),position:i,mass:e.mass,linearDamping:e.linearDamping,fixedRotation:!0}),this.body.addShape(new CANNON.Sphere(e.radius),new CANNON.Vec3(0,e.radius,0)),this.body.el=this.el,this.el.body=this.body,this.system.addBody(this.body),t.hasAttribute("wasd-controls")&&console.warn("[kinematic-body] Not compatible with wasd-controls, use movement-controls.")},remove:function(){this.system.removeBody(this.body),this.system.removeComponent(this),delete this.el.body},beforeStep:function(t,e){if(e){var i=this.el,n=this.data,s=this.body;n.enableJumps||s.velocity.set(0,0,0),s.position.copy(i.getAttribute("position"))}},step:function(){var t=new THREE.Vector3,e=new THREE.Vector3,i=new THREE.Vector3,n=new THREE.Vector3;return function(s,o){if(o){var r=this.body,a=this.data,l=void 0,h=-1/0,c=void 0,d=this.system.getContacts();o=Math.min(o,1e3*this.system.data.maxInterval),n.set(0,0,0),t.copy(this.el.getAttribute("velocity")),r.velocity.copy(t);for(var u,p=0;u=d[p];p++)if(u.enabled){if(r.id===u.bi.id)u.ni.negate(i);else{if(r.id!==u.bj.id)continue;i.copy(u.ni)}r.velocity.dot(i)<-1e-6&&i.y<=.5?t.projectOnPlane(i):i.y>.5&&(l=r.id===u.bi.id?Math.abs(u.rj.y+u.bj.position.y):Math.abs(u.ri.y+u.bi.position.y))>h&&(h=l,n.copy(i),c=r.id===u.bi.id?u.bj:u.bi)}e.copy(t).normalize(),c&&(!a.enableJumps||e.y<.5)?(a.enableSlopes?n.y<1-1e-6&&n.copy(this.raycastToGround(c,n)):n.set(0,1,0),t.projectOnPlane(n)):this.system.driver.world&&t.add(this.system.driver.world.gravity.scale(4*o/1e3)),r.velocity.copy(t),this.el.setAttribute("velocity",r.velocity),this.el.setAttribute("position",r.position)}}}(),raycastToGround:function(t,e){var i=void 0,n=void 0,s=this.body.position,o=this.body.position.clone();return(i=new CANNON.Ray(s,o))._updateDirection(),i.intersectBody(t),i.hasHit?(n=i.result.hitNormalWorld,Math.abs(n.y)>Math.abs(e.y)?n:e):e}})},{}],8:[function(t,e,i){"use strict";e.exports=AFRAME.registerComponent("mesh-smooth",{init:function(){this.el.addEventListener("model-loaded",function(t){t.detail.model.traverse(function(t){t.isMesh&&t.geometry.computeVertexNormals()})})}})},{}],9:[function(t,e,i){"use strict";e.exports=AFRAME.registerComponent("normal-material",{init:function(){this.material=new THREE.MeshNormalMaterial({flatShading:!0}),this.applyMaterial=this.applyMaterial.bind(this),this.el.addEventListener("object3dset",this.applyMaterial)},remove:function(){this.el.removeEventListener("object3dset",this.applyMaterial)},applyMaterial:function(){var t=this;this.el.object3D.traverse(function(e){e.isMesh&&(e.material=t.material)})}})},{}],10:[function(t,e,i){"use strict";e.exports=AFRAME.registerComponent("sphere-collider",{schema:{objects:{default:""},state:{default:"collided"},radius:{default:.05},watch:{default:!0}},init:function(){this.observer=null,this.els=[],this.collisions=[],this.handleHit=this.handleHit.bind(this),this.handleHitEnd=this.handleHitEnd.bind(this)},remove:function(){this.pause()},play:function(){var t=this.el.sceneEl;this.data.watch&&(this.observer=new MutationObserver(this.update.bind(this,null)),this.observer.observe(t,{childList:!0,subtree:!0}))},pause:function(){this.observer&&(this.observer.disconnect(),this.observer=null)},update:function(){var t=this.data,e=void 0;e=t.objects?this.el.sceneEl.querySelectorAll(t.objects):this.el.sceneEl.children,this.els=Array.prototype.slice.call(e)},tick:function(){var t=new THREE.Vector3,e=new THREE.Vector3,i=new THREE.Vector3,n=new Map;return function(){var s=this.el,o=this.data,r=[],a=void 0;s.getObject3D("mesh")&&(n.clear(),t.copy(s.object3D.getWorldPosition()),s.object3D.getWorldScale(i),a=o.radius*function(t){return Math.max.apply(null,t.toArray())}(i),this.els.forEach(function(i){var s=void 0,o=void 0,l=void 0,h=void 0,c=void 0,d=void 0;i.isEntity&&(o=i.getObject3D("mesh"))&&(d=(h=(new THREE.Box3).setFromObject(o)).getSize(),c=Math.max(d.x,d.y,d.z)/2,s=Math.sqrt(2*c*c),h.getCenter(e),s&&(l=t.distanceTo(e))<s+a&&(r.push(i),n.set(i,l)))}),r.sort(function(t,e){return n.get(t)>n.get(e)?1:-1}).forEach(this.handleHit),0===r.length&&s.emit("hit",{el:null}),this.collisions.filter(function(t){return!n.has(t)}).forEach(this.handleHitEnd),this.collisions=r)}}(),handleHit:function(t){t.emit("hit"),t.addState(this.data.state),this.el.emit("hit",{el:t})},handleHitEnd:function(t){t.emit("hitend"),t.removeState(this.data.state),this.el.emit("hitend",{el:t})}})},{}]},{},[1]); | ||
!function t(e,i,n){function s(r,a){if(!i[r]){if(!e[r]){var l="function"==typeof require&&require;if(!a&&l)return l(r,!0);if(o)return o(r,!0);var h=new Error("Cannot find module '"+r+"'");throw h.code="MODULE_NOT_FOUND",h}var c=i[r]={exports:{}};e[r][0].call(c.exports,function(t){var i=e[r][1][t];return s(i||t)},c,c.exports,t,e,i,n)}return i[r].exports}for(var o="function"==typeof require&&require,r=0;r<n.length;r++)s(n[r]);return s}({1:[function(t,e,i){"use strict";t("./src/misc")},{"./src/misc":5}],2:[function(t,e,i){"use strict";e.exports=AFRAME.registerComponent("checkpoint",{schema:{offset:{default:{x:0,y:0,z:0},type:"vec3"}},init:function(){this.active=!1,this.targetEl=null,this.fire=this.fire.bind(this),this.offset=new THREE.Vector3},update:function(){this.offset.copy(this.data.offset)},play:function(){this.el.addEventListener("click",this.fire)},pause:function(){this.el.removeEventListener("click",this.fire)},remove:function(){this.pause()},fire:function(){var t=this.el.sceneEl.querySelector("[checkpoint-controls]");if(!t)throw new Error("No `checkpoint-controls` component found.");t.components["checkpoint-controls"].setCheckpoint(this.el)},getOffset:function(){return this.offset.copy(this.data.offset)}})},{}],3:[function(t,e,i){"use strict";function n(t,e,i,n){t&&(e=e||[],t.traverse(function(t){if(t.isMesh){(function(t){return t?Array.isArray(t)?t:t.materials?t.materials:[t]:[]})(t.material).forEach(function(t){(!t||"envMap"in t)&&(e.length&&-1===e.indexOf(t.name)||(t.envMap=i,t.reflectivity=n,t.needsUpdate=!0))})}}))}e.exports=AFRAME.registerComponent("cube-env-map",{multiple:!0,schema:{path:{default:""},extension:{default:"jpg",oneOf:["jpg","png"]},format:{default:"RGBFormat",oneOf:["RGBFormat","RGBAFormat"]},enableBackground:{default:!1},reflectivity:{default:1,min:0,max:1},materials:{default:[]}},init:function(){var t=this,e=this.data;this.texture=(new THREE.CubeTextureLoader).load([e.path+"posx."+e.extension,e.path+"negx."+e.extension,e.path+"posy."+e.extension,e.path+"negy."+e.extension,e.path+"posz."+e.extension,e.path+"negz."+e.extension]),this.texture.format=THREE[e.format],this.object3dsetHandler=function(){var e=t.el.getObject3D("mesh"),i=t.data;n(e,i.materials,t.texture,i.reflectivity)},this.el.addEventListener("object3dset",this.object3dsetHandler)},update:function(t){var e=this.data,i=this.el.getObject3D("mesh"),s=[],o=[];if(e.materials.length&&(t.materials?(s=e.materials.filter(function(e){return!t.materials.includes(e)}),o=t.materials.filter(function(t){return!e.materials.includes(t)})):s=e.materials),s.length&&n(i,s,this.texture,e.reflectivity),o.length&&n(i,o,null,1),t.materials&&e.reflectivity!==t.reflectivity){var r=e.materials.filter(function(e){return t.materials.includes(e)});r.length&&n(i,r,this.texture,e.reflectivity)}this.data.enableBackground&&!t.enableBackground?this.setBackground(this.texture):!this.data.enableBackground&&t.enableBackground&&this.setBackground(null)},remove:function(){this.el.removeEventListener("object3dset",this.object3dsetHandler);var t=this.el.getObject3D("mesh"),e=this.data;n(t,e.materials,null,1),e.enableBackground&&this.setBackground(null)},setBackground:function(t){this.el.sceneEl.object3D.background=t}})},{}],4:[function(t,e,i){"use strict";e.exports=AFRAME.registerComponent("grab",{init:function(){this.system=this.el.sceneEl.systems.physics,this.GRABBED_STATE="grabbed",this.grabbing=!1,this.hitEl=null,this.physics=this.el.sceneEl.systems.physics,this.constraint=null,this.onHit=this.onHit.bind(this),this.onGripOpen=this.onGripOpen.bind(this),this.onGripClose=this.onGripClose.bind(this)},play:function(){var t=this.el;t.addEventListener("hit",this.onHit),t.addEventListener("gripdown",this.onGripClose),t.addEventListener("gripup",this.onGripOpen),t.addEventListener("trackpaddown",this.onGripClose),t.addEventListener("trackpadup",this.onGripOpen),t.addEventListener("triggerdown",this.onGripClose),t.addEventListener("triggerup",this.onGripOpen)},pause:function(){var t=this.el;t.removeEventListener("hit",this.onHit),t.removeEventListener("gripdown",this.onGripClose),t.removeEventListener("gripup",this.onGripOpen),t.removeEventListener("trackpaddown",this.onGripClose),t.removeEventListener("trackpadup",this.onGripOpen),t.removeEventListener("triggerdown",this.onGripClose),t.removeEventListener("triggerup",this.onGripOpen)},onGripClose:function(){this.grabbing=!0},onGripOpen:function(){var t=this.hitEl;this.grabbing=!1,t&&(t.removeState(this.GRABBED_STATE),this.hitEl=void 0,this.system.removeConstraint(this.constraint),this.constraint=null)},onHit:function(t){var e=t.detail.el;e&&!e.is(this.GRABBED_STATE)&&this.grabbing&&!this.hitEl&&(e.addState(this.GRABBED_STATE),this.hitEl=e,this.constraint=new CANNON.LockConstraint(this.el.body,e.body),this.system.addConstraint(this.constraint))}})},{}],5:[function(t,e,i){"use strict";t("./checkpoint"),t("./cube-env-map"),t("./grab"),t("./jump-ability"),t("./kinematic-body"),t("./mesh-smooth"),t("./normal-material"),t("./sphere-collider")},{"./checkpoint":2,"./cube-env-map":3,"./grab":4,"./jump-ability":6,"./kinematic-body":7,"./mesh-smooth":8,"./normal-material":9,"./sphere-collider":10}],6:[function(t,e,i){"use strict";e.exports=AFRAME.registerComponent("jump-ability",{dependencies:["velocity"],schema:{on:{default:"keydown:Space gamepadbuttondown:0"},playerHeight:{default:1.764},maxJumps:{default:1},distance:{default:5},debug:{default:!1}},init:function(){this.velocity=0,this.numJumps=0;var t=this.beginJump.bind(this),e=this.data.on.split(" ");this.bindings={};for(var i=0;i<e.length;i++)this.bindings[e[i]]=t,this.el.addEventListener(e[i],t);this.bindings.collide=this.onCollide.bind(this),this.el.addEventListener("collide",this.bindings.collide)},remove:function(){for(var t in this.bindings)this.bindings.hasOwnProperty(t)&&(this.el.removeEventListener(t,this.bindings[t]),delete this.bindings[t]);this.el.removeEventListener("collide",this.bindings.collide),delete this.bindings.collide},beginJump:function(){if(this.numJumps<this.data.maxJumps){var t=this.data,e=Math.sqrt(-2*t.distance*-24.8),i=this.el.getAttribute("velocity");this.el.setAttribute("velocity",{x:i.x,y:e,z:i.z}),this.numJumps++,this.el.emit("jumpstart")}},onCollide:function(){this.numJumps>0&&this.el.emit("jumpend"),this.numJumps=0}})},{}],7:[function(t,e,i){"use strict";e.exports=AFRAME.registerComponent("kinematic-body",{dependencies:["velocity"],schema:{mass:{default:5},radius:{default:1.3},linearDamping:{default:.05},enableSlopes:{default:!0},enableJumps:{default:!1}},init:function(){this.system=this.el.sceneEl.systems.physics,this.system.addComponent(this);var t=this.el,e=this.data,i=(new CANNON.Vec3).copy(t.object3D.getWorldPosition(new THREE.Vector3));this.body=new CANNON.Body({material:this.system.getMaterial("staticMaterial"),position:i,mass:e.mass,linearDamping:e.linearDamping,fixedRotation:!0}),this.body.addShape(new CANNON.Sphere(e.radius),new CANNON.Vec3(0,e.radius,0)),this.body.el=this.el,this.el.body=this.body,this.system.addBody(this.body),t.hasAttribute("wasd-controls")&&console.warn("[kinematic-body] Not compatible with wasd-controls, use movement-controls.")},remove:function(){this.system.removeBody(this.body),this.system.removeComponent(this),delete this.el.body},beforeStep:function(t,e){if(e){var i=this.el,n=this.data,s=this.body;n.enableJumps||s.velocity.set(0,0,0),s.position.copy(i.getAttribute("position"))}},step:function(){var t=new THREE.Vector3,e=new THREE.Vector3,i=new THREE.Vector3,n=new THREE.Vector3;return function(s,o){if(o){var r=this.body,a=this.data,l=void 0,h=-1/0,c=void 0,d=this.system.getContacts();o=Math.min(o,1e3*this.system.data.maxInterval),n.set(0,0,0),t.copy(this.el.getAttribute("velocity")),r.velocity.copy(t);for(var u,p=0;u=d[p];p++)if(u.enabled){if(r.id===u.bi.id)u.ni.negate(i);else{if(r.id!==u.bj.id)continue;i.copy(u.ni)}r.velocity.dot(i)<-1e-6&&i.y<=.5?t.projectOnPlane(i):i.y>.5&&(l=r.id===u.bi.id?Math.abs(u.rj.y+u.bj.position.y):Math.abs(u.ri.y+u.bi.position.y))>h&&(h=l,n.copy(i),c=r.id===u.bi.id?u.bj:u.bi)}e.copy(t).normalize(),c&&(!a.enableJumps||e.y<.5)?(a.enableSlopes?n.y<1-1e-6&&n.copy(this.raycastToGround(c,n)):n.set(0,1,0),t.projectOnPlane(n)):this.system.driver.world&&t.add(this.system.driver.world.gravity.scale(4*o/1e3)),r.velocity.copy(t),this.el.setAttribute("velocity",r.velocity),this.el.setAttribute("position",r.position)}}}(),raycastToGround:function(t,e){var i=void 0,n=void 0,s=this.body.position,o=this.body.position.clone();return(i=new CANNON.Ray(s,o))._updateDirection(),i.intersectBody(t),i.hasHit?(n=i.result.hitNormalWorld,Math.abs(n.y)>Math.abs(e.y)?n:e):e}})},{}],8:[function(t,e,i){"use strict";e.exports=AFRAME.registerComponent("mesh-smooth",{init:function(){this.el.addEventListener("model-loaded",function(t){t.detail.model.traverse(function(t){t.isMesh&&t.geometry.computeVertexNormals()})})}})},{}],9:[function(t,e,i){"use strict";e.exports=AFRAME.registerComponent("normal-material",{init:function(){this.material=new THREE.MeshNormalMaterial({flatShading:!0}),this.applyMaterial=this.applyMaterial.bind(this),this.el.addEventListener("object3dset",this.applyMaterial)},remove:function(){this.el.removeEventListener("object3dset",this.applyMaterial)},applyMaterial:function(){var t=this;this.el.object3D.traverse(function(e){e.isMesh&&(e.material=t.material)})}})},{}],10:[function(t,e,i){"use strict";e.exports=AFRAME.registerComponent("sphere-collider",{schema:{objects:{default:""},state:{default:"collided"},radius:{default:.05},watch:{default:!0}},init:function(){this.observer=null,this.els=[],this.collisions=[],this.handleHit=this.handleHit.bind(this),this.handleHitEnd=this.handleHitEnd.bind(this)},remove:function(){this.pause()},play:function(){var t=this.el.sceneEl;this.data.watch&&(this.observer=new MutationObserver(this.update.bind(this,null)),this.observer.observe(t,{childList:!0,subtree:!0}))},pause:function(){this.observer&&(this.observer.disconnect(),this.observer=null)},update:function(){var t=this.data,e=void 0;e=t.objects?this.el.sceneEl.querySelectorAll(t.objects):this.el.sceneEl.children,this.els=Array.prototype.slice.call(e)},tick:function(){var t=new THREE.Vector3,e=new THREE.Vector3,i=new THREE.Vector3,n=new THREE.Vector3,s=new THREE.Box3,o=new Map;return function(){var r=this.el,a=this.data,l=[],h=void 0;r.getObject3D("mesh")&&(o.clear(),r.object3D.getWorldPosition(t),r.object3D.getWorldScale(i),h=a.radius*function(t){return Math.max.apply(null,t.toArray())}(i),this.els.forEach(function(i){var r=void 0,a=void 0,c=void 0,d=void 0;i.isEntity&&(a=i.getObject3D("mesh"))&&(s.setFromObject(a).getSize(n),d=Math.max(n.x,n.y,n.z)/2,r=Math.sqrt(2*d*d),s.getCenter(e),r&&(c=t.distanceTo(e))<r+h&&(l.push(i),o.set(i,c)))}),l.sort(function(t,e){return o.get(t)>o.get(e)?1:-1}).forEach(this.handleHit),0===l.length&&r.emit("hit",{el:null}),this.collisions.filter(function(t){return!o.has(t)}).forEach(this.handleHitEnd),this.collisions=l)}}(),handleHit:function(t){t.emit("hit"),t.addState(this.data.state),this.el.emit("hit",{el:t})},handleHitEnd:function(t){t.emit("hitend"),t.removeState(this.data.state),this.el.emit("hitend",{el:t})}})},{}]},{},[1]); |
@@ -82,2 +82,4 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
colliderScale = new THREE.Vector3(), | ||
size = new THREE.Vector3(), | ||
box = new THREE.Box3(), | ||
distanceMap = new Map(); | ||
@@ -96,3 +98,3 @@ return function () { | ||
distanceMap.clear(); | ||
position.copy(el.object3D.getWorldPosition()); | ||
el.object3D.getWorldPosition(position); | ||
el.object3D.getWorldScale(colliderScale); | ||
@@ -126,5 +128,3 @@ colliderRadius = data.radius * scaleFactor(colliderScale); | ||
distance = void 0, | ||
box = void 0, | ||
extent = void 0, | ||
size = void 0; | ||
extent = void 0; | ||
@@ -141,4 +141,3 @@ if (!el.isEntity) { | ||
box = new THREE.Box3().setFromObject(mesh); | ||
size = box.getSize(); | ||
box.setFromObject(mesh).getSize(size); | ||
extent = Math.max(size.x, size.y, size.z) / 2; | ||
@@ -145,0 +144,0 @@ radius = Math.sqrt(2 * extent * extent); |
@@ -1,1 +0,1 @@ | ||
!function t(e,i,n){function r(o,l){if(!i[o]){if(!e[o]){var a="function"==typeof require&&require;if(!l&&a)return a(o,!0);if(s)return s(o,!0);var h=new Error("Cannot find module '"+o+"'");throw h.code="MODULE_NOT_FOUND",h}var c=i[o]={exports:{}};e[o][0].call(c.exports,function(t){var i=e[o][1][t];return r(i||t)},c,c.exports,t,e,i,n)}return i[o].exports}for(var s="function"==typeof require&&require,o=0;o<n.length;o++)r(n[o]);return r}({1:[function(t,e,i){"use strict";t("./src/misc/sphere-collider")},{"./src/misc/sphere-collider":2}],2:[function(t,e,i){"use strict";e.exports=AFRAME.registerComponent("sphere-collider",{schema:{objects:{default:""},state:{default:"collided"},radius:{default:.05},watch:{default:!0}},init:function(){this.observer=null,this.els=[],this.collisions=[],this.handleHit=this.handleHit.bind(this),this.handleHitEnd=this.handleHitEnd.bind(this)},remove:function(){this.pause()},play:function(){var t=this.el.sceneEl;this.data.watch&&(this.observer=new MutationObserver(this.update.bind(this,null)),this.observer.observe(t,{childList:!0,subtree:!0}))},pause:function(){this.observer&&(this.observer.disconnect(),this.observer=null)},update:function(){var t=this.data,e=void 0;e=t.objects?this.el.sceneEl.querySelectorAll(t.objects):this.el.sceneEl.children,this.els=Array.prototype.slice.call(e)},tick:function(){var t=new THREE.Vector3,e=new THREE.Vector3,i=new THREE.Vector3,n=new Map;return function(){var r=this.el,s=this.data,o=[],l=void 0;r.getObject3D("mesh")&&(n.clear(),t.copy(r.object3D.getWorldPosition()),r.object3D.getWorldScale(i),l=s.radius*function(t){return Math.max.apply(null,t.toArray())}(i),this.els.forEach(function(i){var r=void 0,s=void 0,a=void 0,h=void 0,c=void 0,u=void 0;i.isEntity&&(s=i.getObject3D("mesh"))&&(u=(h=(new THREE.Box3).setFromObject(s)).getSize(),c=Math.max(u.x,u.y,u.z)/2,r=Math.sqrt(2*c*c),h.getCenter(e),r&&(a=t.distanceTo(e))<r+l&&(o.push(i),n.set(i,a)))}),o.sort(function(t,e){return n.get(t)>n.get(e)?1:-1}).forEach(this.handleHit),0===o.length&&r.emit("hit",{el:null}),this.collisions.filter(function(t){return!n.has(t)}).forEach(this.handleHitEnd),this.collisions=o)}}(),handleHit:function(t){t.emit("hit"),t.addState(this.data.state),this.el.emit("hit",{el:t})},handleHitEnd:function(t){t.emit("hitend"),t.removeState(this.data.state),this.el.emit("hitend",{el:t})}})},{}]},{},[1]); | ||
!function t(e,i,n){function r(o,l){if(!i[o]){if(!e[o]){var a="function"==typeof require&&require;if(!l&&a)return a(o,!0);if(s)return s(o,!0);var h=new Error("Cannot find module '"+o+"'");throw h.code="MODULE_NOT_FOUND",h}var c=i[o]={exports:{}};e[o][0].call(c.exports,function(t){var i=e[o][1][t];return r(i||t)},c,c.exports,t,e,i,n)}return i[o].exports}for(var s="function"==typeof require&&require,o=0;o<n.length;o++)r(n[o]);return r}({1:[function(t,e,i){"use strict";t("./src/misc/sphere-collider")},{"./src/misc/sphere-collider":2}],2:[function(t,e,i){"use strict";e.exports=AFRAME.registerComponent("sphere-collider",{schema:{objects:{default:""},state:{default:"collided"},radius:{default:.05},watch:{default:!0}},init:function(){this.observer=null,this.els=[],this.collisions=[],this.handleHit=this.handleHit.bind(this),this.handleHitEnd=this.handleHitEnd.bind(this)},remove:function(){this.pause()},play:function(){var t=this.el.sceneEl;this.data.watch&&(this.observer=new MutationObserver(this.update.bind(this,null)),this.observer.observe(t,{childList:!0,subtree:!0}))},pause:function(){this.observer&&(this.observer.disconnect(),this.observer=null)},update:function(){var t=this.data,e=void 0;e=t.objects?this.el.sceneEl.querySelectorAll(t.objects):this.el.sceneEl.children,this.els=Array.prototype.slice.call(e)},tick:function(){var t=new THREE.Vector3,e=new THREE.Vector3,i=new THREE.Vector3,n=new THREE.Vector3,r=new THREE.Box3,s=new Map;return function(){var o=this.el,l=this.data,a=[],h=void 0;o.getObject3D("mesh")&&(s.clear(),o.object3D.getWorldPosition(t),o.object3D.getWorldScale(i),h=l.radius*function(t){return Math.max.apply(null,t.toArray())}(i),this.els.forEach(function(i){var o=void 0,l=void 0,c=void 0,u=void 0;i.isEntity&&(l=i.getObject3D("mesh"))&&(r.setFromObject(l).getSize(n),u=Math.max(n.x,n.y,n.z)/2,o=Math.sqrt(2*u*u),r.getCenter(e),o&&(c=t.distanceTo(e))<o+h&&(a.push(i),s.set(i,c)))}),a.sort(function(t,e){return s.get(t)>s.get(e)?1:-1}).forEach(this.handleHit),0===a.length&&o.emit("hit",{el:null}),this.collisions.filter(function(t){return!s.has(t)}).forEach(this.handleHitEnd),this.collisions=a)}}(),handleHit:function(t){t.emit("hit"),t.addState(this.data.state),this.el.emit("hit",{el:t})},handleHitEnd:function(t){t.emit("hitend"),t.removeState(this.data.state),this.el.emit("hitend",{el:t})}})},{}]},{},[1]); |
{ | ||
"name": "aframe-extras", | ||
"version": "5.1.0", | ||
"version": "6.0.0", | ||
"description": "Add-ons and examples for A-Frame VR.", | ||
@@ -5,0 +5,0 @@ "author": "Don McCurdy <dm@donmccurdy.com>", |
@@ -24,2 +24,3 @@ # A-Frame Extras | ||
│ ├── animation-mixer.js | ||
│ ├── collada-model-legacy.js <sub><img alt="New" src="https://img.shields.io/badge/status-new-green.svg"></sub> | ||
│ ├── fbx-model.js | ||
@@ -52,9 +53,9 @@ │ ├── gltf-model-legacy.js | ||
```html | ||
<script src="//cdn.rawgit.com/donmccurdy/aframe-extras/v5.1.0/dist/aframe-extras.min.js"></script> | ||
<script src="//cdn.rawgit.com/donmccurdy/aframe-extras/v6.0.0/dist/aframe-extras.min.js"></script> | ||
``` | ||
CDN builds for aframe-extras/v5.1.0: | ||
CDN builds for aframe-extras/v6.0.0: | ||
- [aframe-extras.js](https://cdn.rawgit.com/donmccurdy/aframe-extras/v5.1.0/dist/aframe-extras.js) *(development)* | ||
- [aframe-extras.min.js](https://cdn.rawgit.com/donmccurdy/aframe-extras/v5.1.0/dist/aframe-extras.min.js) *(production)* | ||
- [aframe-extras.js](https://cdn.rawgit.com/donmccurdy/aframe-extras/v6.0.0/dist/aframe-extras.js) *(development)* | ||
- [aframe-extras.min.js](https://cdn.rawgit.com/donmccurdy/aframe-extras/v6.0.0/dist/aframe-extras.min.js) *(production)* | ||
@@ -65,9 +66,10 @@ For partial builds, use a subpackage like `aframe-extras.controls.min.js`. Full list of packages above. | ||
| A-Frame | Extras | | ||
|-----------|-------------------| | ||
| v0.8.X | aframe-extras/v5.1.0 | | ||
| v0.5.X | */v3.13.1 | | ||
| v0.4.X | */v3.3.0 | | ||
| v0.3.X | */v2.6.1 | | ||
| v0.2.X | */v1.17.0 | | ||
| A-Frame | Extras | | ||
|----------|----------------------| | ||
| v0.9.X | aframe-extras/v6.0.0 | | ||
| v0.8.X | */v5.1.0 | | ||
| v0.5.X | */v3.13.1 | | ||
| v0.4.X | */v3.3.0 | | ||
| v0.3.X | */v2.6.1 | | ||
| v0.2.X | */v1.17.0 | | ||
@@ -74,0 +76,0 @@ > **NOTE:** Several components and examples also rely on [aframe-physics-system](https://github.com/donmccurdy/aframe-physics-system). |
@@ -82,3 +82,3 @@ const EPS = 0.1; | ||
position.copy(this.el.getAttribute('position')); | ||
targetPosition.copy(this.checkpoint.object3D.getWorldPosition()); | ||
this.checkpoint.object3D.getWorldPosition(targetPosition); | ||
targetPosition.add(this.checkpoint.components.checkpoint.getOffset()); | ||
@@ -85,0 +85,0 @@ offset.copy(targetPosition).sub(position); |
require('./animation-mixer'); | ||
require('./collada-model-legacy'); | ||
require('./fbx-model'); | ||
require('./gltf-model-legacy'); | ||
require('./object-model'); |
@@ -5,14 +5,13 @@ # Loaders | ||
- **gltf-model-legacy**: Loader for glTF 1.0 format, removed from A-Frame core with v0.7.0 release. For glTF 2.0, use the `gltf-model` component that ships with A-Frame. | ||
- **object-model**: Loader for THREE.js .JSON format, generally containing multiple meshes or an entire scene. | ||
- **collada-model-legacy**: Loader for COLLADA (`.dae`) format, removed from A-Frame core with v0.9.0 release. Where possible, use the `gltf-model` component that ships with A-Frame instead. | ||
- **gltf-model-legacy**: Loader for glTF 1.0 format, removed from A-Frame core with v0.7.0 release. For glTF 2.0, use the `gltf-model` component that ships with A-Frame instead. | ||
- **object-model**: Loader for THREE.js .JSON format, generally containing multiple meshes or an entire scene. Where possible, use the `gltf-model` component that ships with A-Frame instead. | ||
- **fbx-model**: Loader for FBX format. | ||
- **animation-mixer**: Controls animations embedded in a glTF model. | ||
Unsure whether to use `json-model` or `object-model`? Check the console for errors. See also: [Clara.io | THREE.js Export](https://clara.io/learn/user-guide/data_exchange/threejs_export). | ||
## Usage | ||
```html | ||
<!-- three.js JSON --> | ||
<a-entity json-model="src: url(my-model.json);"></a-entity> | ||
<!-- FBX --> | ||
<a-entity fbx-model="src: url(my-model.fbx);"></a-entity> | ||
``` | ||
@@ -23,3 +22,3 @@ | ||
```html | ||
<a-entity scale="0.5 0.5 0.5" object-model="src: url(my-model.json);"> | ||
<a-entity scale="0.5 0.5 0.5" fbx-model="src: url(my-model.fbx);"> | ||
</a-entity> | ||
@@ -26,0 +25,0 @@ ``` |
@@ -73,2 +73,4 @@ /** | ||
colliderScale = new THREE.Vector3(), | ||
size = new THREE.Vector3(), | ||
box = new THREE.Box3(), | ||
distanceMap = new Map(); | ||
@@ -85,3 +87,3 @@ return function () { | ||
distanceMap.clear(); | ||
position.copy(el.object3D.getWorldPosition()); | ||
el.object3D.getWorldPosition(position); | ||
el.object3D.getWorldScale(colliderScale); | ||
@@ -110,3 +112,3 @@ colliderRadius = data.radius * scaleFactor(colliderScale); | ||
function intersect (el) { | ||
let radius, mesh, distance, box, extent, size; | ||
let radius, mesh, distance, extent; | ||
@@ -119,4 +121,3 @@ if (!el.isEntity) { return; } | ||
box = new THREE.Box3().setFromObject(mesh); | ||
size = box.getSize(); | ||
box.setFromObject(mesh).getSize(size); | ||
extent = Math.max(size.x, size.y, size.z) / 2; | ||
@@ -123,0 +124,0 @@ radius = Math.sqrt(2 * extent * extent); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1531814
75
25275
94