text: !function(t){function e(n){if(o[n])return o[n].exports;var i=o[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var o={};return e.m=t,e.c=o,e.p="",e(0)}([function(t,e){var o=Math.PI/2;AFRAME.registerComponent("orbit-controls",{schema:{enabled:{"default":!0}},init:function(){this.previousPosition=new THREE.Vector3,this.deltaPosition=new THREE.Vector3,this.setupMouseControls(),this.setupHMDControls(),this.bindMethods();var t=this.el.getAttribute("target");this.distance=this.el.getAttribute("distance"),this.target3D=document.getElementById(t.replace("#","")).object3D,window.target=this.target3D,window.camera=this.el},update:function(){this.data.enabled&&(this.controls.update(),this.updateOrientation(),this.updatePosition())},play:function(){this.previousPosition.set(0,0,0),this.addEventListeners()},pause:function(){this.removeEventListeners()},tick:function(t){this.update()},remove:function(){this.pause()},bindMethods:function(){this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.releaseMouse=this.releaseMouse.bind(this),this.onTouchStart=this.onTouchStart.bind(this),this.onTouchMove=this.onTouchMove.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this)},setupMouseControls:function(){this.mouseDown=!1,this.pitchObject=new THREE.Object3D,this.yawObject=new THREE.Object3D,this.yawObject.position.y=10,this.yawObject.add(this.pitchObject)},setupHMDControls:function(){this.dolly=new THREE.Object3D,this.euler=new THREE.Euler,this.controls=new THREE.VRControls(this.dolly),this.zeroQuaternion=new THREE.Quaternion},addEventListeners:function(){var t=this.el.sceneEl,e=t.canvas;return e?(e.addEventListener("mousedown",this.onMouseDown,!1),e.addEventListener("mousemove",this.onMouseMove,!1),e.addEventListener("mouseup",this.releaseMouse,!1),e.addEventListener("mouseout",this.releaseMouse,!1),e.addEventListener("touchstart",this.onTouchStart),e.addEventListener("touchmove",this.onTouchMove),void e.addEventListener("touchend",this.onTouchEnd)):void t.addEventListener("render-target-loaded",this.addEventListeners.bind(this))},removeEventListeners:function(){var t=document.querySelector("a-scene"),e=t&&t.canvas;e&&(e.removeEventListener("mousedown",this.onMouseDown),e.removeEventListener("mousemove",this.onMouseMove),e.removeEventListener("mouseup",this.releaseMouse),e.removeEventListener("mouseout",this.releaseMouse),e.removeEventListener("touchstart",this.onTouchStart),e.removeEventListener("touchmove",this.onTouchMove),e.removeEventListener("touchend",this.onTouchEnd))},updateOrientation:function(){var t=new THREE.Euler;return t.order="YXZ",function(){var e=this.pitchObject,o=this.yawObject,n=this.calculateHMDQuaternion();t.setFromQuaternion(n),this.el.setAttribute("rotation",{x:THREE.Math.radToDeg(t.x)+THREE.Math.radToDeg(e.rotation.x),y:THREE.Math.radToDeg(t.y)+THREE.Math.radToDeg(o.rotation.y),z:THREE.Math.radToDeg(t.z)+THREE.Math.radToDeg(o.rotation.z)})}}(),calculateHMDQuaternion:function(){var t=new THREE.Quaternion;return function(){var e=this.dolly;return this.zeroed||e.quaternion.equals(this.zeroQuaternion)||(this.zeroOrientation(),this.zeroed=!0),t.copy(this.zeroQuaternion).multiply(e.quaternion),t}}(),updatePosition:function(){var t=new THREE.Vector3,e=new THREE.Quaternion,o=new THREE.Vector3;return function(){var n=this.el,i=this.calculateDeltaPosition();this.target3D.position;this.el.object3D.matrixWorld.decompose(t,e,o),i.applyQuaternion(e),n.setAttribute("position",{x:this.target3D.position.x,y:this.target3D.position.y,z:this.target3D.position.z});var s=camera.object3D.translateOnAxis(new THREE.Vector3(0,0,1),this.distance).position;n.setAttribute("position",{x:s.x,y:s.y,z:s.z})}}(),calculateDeltaPosition:function(){var t=this.dolly,e=this.deltaPosition,o=this.previousPosition;return e.copy(t.position),e.sub(o),o.copy(t.position),e},updateHMDQuaternion:function(){var t=new THREE.Quaternion;return function(){var e=this.dolly;return this.controls.update(),this.zeroed||e.quaternion.equals(this.zeroQuaternion)||(this.zeroOrientation(),this.zeroed=!0),t.copy(this.zeroQuaternion).multiply(e.quaternion),t}}(),zeroOrientation:function(){var t=new THREE.Euler;t.setFromQuaternion(this.dolly.quaternion.clone().inverse()),t.z=0,t.x=0,this.zeroQuaternion.setFromEuler(t)},onMouseMove:function(t){var e=this.pitchObject,n=this.yawObject,i=this.previousMouseEvent;if(this.mouseDown&&this.data.enabled){var s=t.movementX||t.mozMovementX,r=t.movementY||t.mozMovementY;void 0!==s&&void 0!==r||(s=t.screenX-i.screenX,r=t.screenY-i.screenY),this.previousMouseEvent=t,n.rotation.y-=.002*s,e.rotation.x-=.002*r,e.rotation.x=Math.max(-o,Math.min(o,e.rotation.x))}},onMouseDown:function(t){this.mouseDown=!0,this.previousMouseEvent=t},releaseMouse:function(){this.mouseDown=!1},onTouchStart:function(t){1===t.touches.length&&(this.touchStart={x:t.touches[0].pageX,y:t.touches[0].pageY},this.touchStarted=!0)},onTouchMove:function(t){var e,o=this.yawObject;this.touchStarted&&(e=2*Math.PI*(t.touches[0].pageX-this.touchStart.x)/this.el.sceneEl.canvas.clientWidth,o.rotation.y-=.5*e,this.touchStart={x:t.touches[0].pageX,y:t.touches[0].pageY})},onTouchEnd:function(){this.touchStarted=!1}})}]);