text: !function(e){function t(i){if(a[i])return a[i].exports;var n=a[i]={exports:{},id:i,loaded:!1};return e[i].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var a={};return t.m=e,t.c=a,t.p="",t(0)}([function(e,t,a){a(6),a(5),a(2),a(4),a(1),a(3)},function(e,t){AFRAME.registerComponent("ar-camera",{schema:{enabled:{default:!0}},init:function(){var e=this.el.getAttribute("look-controls");this.wasLookControlsEnabled=!!e&&e.enabled},update:function(e){if(!e||e.enabled!==this.data.enabled)if(this.data.enabled){var t=this.el.getAttribute("look-controls");this.wasLookControlsEnabled=!!t&&t.enabled,this.wasLookControlsEnabled&&this.el.setAttribute("look-controls","enabled",!1)}else this.wasLookControlsEnabled&&this.el.setAttribute("look-controls","enabled",!0)},tick:function(e,t){if(this.data.enabled){var a=this.checkWhichAR();a&&(this.el.setAttribute("position",a.getPosition()),this.el.setAttribute("rotation",a.getRotation()),this.el.sceneEl.is("vr-mode")||(this.el.components.camera.camera.projectionMatrix=a.getProjectionMatrix()))}},checkWhichAR:function(){if(!this.whichar){var e=this.el.sceneEl.components["three-ar"];if(e&&e.arDisplay||(e=this.el.sceneEl.components["mozilla-xr-ar"]),!e||!e.arDisplay)return;this.whichar=e}return this.whichar}})},function(e,t){AFRAME.registerComponent("ar-planes",{getPlaneSource:function(){var e;return this.planeSource||(e=this.el.sceneEl.components["three-ar"],e&&e.arDisplay&&(this.planeSource=e.arDisplay)),this.planeSource||(e=this.el.sceneEl.components["mozilla-xr-ar"],e&&e.arDisplay&&(this.planeSource=e)),this.planeSource},getPlanes:function(){var e=this.getPlaneSource();if(e&&e.getPlanes)return e.getPlanes()},init:function(){this.planes={},this.anchorsAdded=[],this.anchorsAddedDetail={type:"added",anchors:this.anchorsAdded},this.anchorsUpdated=[],this.anchorsUpdatedDetail={type:"updated",anchors:this.anchorsUpdated},this.anchorsRemoved=[],this.anchorsRemovedDetail={type:"removed",anchors:this.anchorsRemoved}},tick:function(e,t){var a=new THREE.Vector3(1,1,1),i=new THREE.Matrix4,n=new THREE.Vector3,r=new THREE.Quaternion;return function(e,t){var s=this.getPlanes();if(s){var o,l=[],c=[],h=[],p={};for(o=0;s&&o<s.length;o++){var d,u=s[o],m=(void 0!==u.identifier?u.identifier:u.id).toString(),E=u.timestamp;p[m]=!0;var f=!this.planes[m],w=void 0!==E;if(f||!w||E!==this.planes[m].timestamp){if(d={identifier:m},void 0!==E&&(d.timestamp=E),u.modelMatrix||u.transform?d.modelMatrix=u.modelMatrix||u.transform:(n.fromArray(u.position),r.fromArray(u.orientation),a.set(1,1,1),i.compose(n,r,a),d.modelMatrix=i.elements.slice()),d.extent=u.extent,u.center&&(d.center=u.center),u.polygon?d.vertices=u.polygon:u.vertices&&(d.vertices=u.vertices),f)l.push(d);else if(w)c.push(d);else{if(AFRAME.utils.deepEqual(d,this.planes[m]))continue;c.push(d)}w?this.planes[m]=d:(this.planes[m]={identifier:d.identifier,modelMatrix:d.modelMatrix.slice(),extent:d.extent.slice()},d.vertices&&(this.planes[m].vertices=d.vertices.slice()))}}var R=this;Object.keys(R.planes).forEach(function(e){p[e]||(h.push(R.planes[e]),delete R.planes[e])}),this.anchorsAdded=l,l.length>0&&(this.anchorsAddedDetail.anchors=l,this.el.emit("anchorsadded",this.anchorsAddedDetail)),this.anchorsUpdated=c,c.length>0&&(this.anchorsUpdatedDetail.anchors=c,this.el.emit("anchorsupdated",this.anchorsUpdatedDetail)),this.anchorsRemoved=h,h.length>0&&(this.anchorsRemovedDetail.anchors=h,this.el.emit("anchorsremoved",this.anchorsRemovedDetail))}}}()})},function(e,t){AFRAME.registerComponent("ar-raycaster",{dependencies:["raycaster"],schema:{x:{default:.5},y:{default:.5},el:{type:"selector"}},init:function(){this.raycaster=this.el.components.raycaster.raycaster,this.raycasterIntersectObjects=this.raycaster.intersectObjects.bind(this.raycaster),this.raycaster.intersectObjects=this.intersectObjects.bind(this)},update:function(e){this.data.el||this.el.sceneEl.object3D.el||(this.el.sceneEl.object3D.el=this.el.sceneEl)},intersectObjects:function(e,t,a){var i=this.raycasterIntersectObjects(e,t,a);return i=a?a=a.concat(this.hitAR()):i.concat(this.hitAR())},hitAR:function(){var e=this.checkWhichAR();if(!e||!e.arDisplay)return[];var t=this.data.x,a=this.data.y;return arguments.length>=2&&(t=arguments[0],a=arguments[1]),e.hitAR(t,a,this.data.el,this.el)},checkWhichAR:function(){if(!this.whichar){var e=this.el.sceneEl.components["three-ar"];if(e&&e.arDisplay||(e=this.el.sceneEl.components["mozilla-xr-ar"]),!e||!e.arDisplay)return;this.whichar=e}return this.whichar}})},function(e,t){AFRAME.registerComponent("ar",{schema:{takeOverCamera:{default:!0},cameraUserHeight:{default:!1},hideUI:{default:!0}},dependencies:["three-ar","mozilla-xr-ar","ar-planes"],init:function(){this.el.setAttribute("three-ar",{takeOverCamera:this.data.takeOverCamera,cameraUserHeight:this.data.cameraUserHeight}),this.el.setAttribute("mozilla-xr-ar",{takeOverCamera:this.data.takeOverCamera,cameraUserHeight:this.data.cameraUserHeight}),this.data.hideUI&&this.el.sceneEl.setAttribute("vr-mode-ui",{enabled:!1}),document.head.insertAdjacentHTML("beforeend","<style>html,body {background-color: transparent !important;}</style>")}})},function(e,t){function a(e){var t,a=e.length,i=new Float32Array(3*a),n=0,r=0;for(n=0;n<a;n++)t=e[n],i[r]=t.x,i[r+1]=t.y,i[r+2]=t.z,r+=3;return i}AFRAME.registerComponent("mozilla-xr-ar",{schema:{takeOverCamera:{default:!0},cameraUserHeight:{default:!1}},init:function(){this.onInit=this.onInit.bind(this),this.onWatch=this.onWatch.bind(this),this.poseMatrix=new THREE.Matrix4,this.posePosition=new THREE.Vector3,this.poseQuaternion=new THREE.Quaternion,this.poseEuler=new THREE.Euler(0,0,0,"YXZ"),this.poseRotation=new THREE.Vector3,this.projectionMatrix=new THREE.Matrix4,this.viewMatrix=new THREE.Matrix4,this.onceSceneLoaded=this.onceSceneLoaded.bind(this),this.el.sceneEl.hasLoaded?(console.log("mozilla-xr-ar: hasLoaded, setTimeout"),setTimeout(this.onceSceneLoaded)):(console.log("mozilla-xr-ar: !hasLoaded, addEventListener"),this.el.sceneEl.addEventListener("loaded",this.onceSceneLoaded)),this.planes_=new Map,this.anchors_=new Map},takeOverCamera:function(e){this.arCamera=e,e.el.setAttribute("ar-camera","enabled",!0)},onceSceneLoaded:function(){if(window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.initAR){setTimeout(function(){var e=AFRAME.scenes[0];e.canvas.style.position="absolute !important",e.canvas.style.width="100% !important",e.canvas.style.height="100% !important",setTimeout(function(){e.resize()})},1e3),window.arkitCallback0=this.onInit,window.arkitCallback1=this.onWatch;var e={options:{ui:{browser:!0,points:!0,focus:!1,rec:!0,rec_time:!0,mic:!1,build:!1,plane:!0,warnings:!0,anchors:!1,debug:!0,statistics:!1}},callback:"arkitCallback0"};window.webkit.messageHandlers.initAR.postMessage(e)}},checkForARDisplay:function(){if(window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.watchAR){this.arDisplay=!0;var e={options:{location:!0,camera:!0,objects:!0,light_intensity:!0},callback:"arkitCallback1"};window.arkitWindowResize=function(){setTimeout(function(){AFRAME.scenes[0].resize()},100)},window.webkit.messageHandlers.watchAR.postMessage(e);var t=this,a=t.el.sceneEl;t.data.takeOverCamera&&setTimeout(function(){t.takeOverCamera(a.camera)}),a.renderer.setPixelRatio(1),a.renderer.autoClear=!1,a.renderer.setClearColor("#000",0),a.renderer.alpha=!0}},onInit:function(e){this.checkForARDisplay()},onWatch:function(e){this.frameData=e,this.handleFrame(e)},handleFrame:function(e){this.poseMatrix.fromArray(e.camera_transform),this.poseMatrix.decompose(this.posePosition,this.poseQuaternion,this.poseRotation),this.poseEuler.setFromQuaternion(this.poseQuaternion),this.poseRotation.set(THREE.Math.RAD2DEG*this.poseEuler.x,THREE.Math.RAD2DEG*this.poseEuler.y,THREE.Math.RAD2DEG*this.poseEuler.z),this.projectionMatrix.fromArray(e.projection_camera),this.viewMatrix.fromArray(e.camera_view),this.arCamera&&this.data.cameraUserHeight&&(this.posePosition.y+=this.arCamera.el.components.camera.data.userHeight);var t=this.posePosition.x||this.posePosition.y||this.posePosition.z||this.poseQuaternion.x||this.poseQuaternion.y||this.poseQuaternion.z;t?this.poseLost!==!1&&(this.poseLost=!1,this.el.emit("poseFound")):this.poseLost!==!0&&(this.poseLost=!0,this.el.emit("poseLost",!1));var i,n;if(e.newObjects&&e.newObjects.length)for(i=0;i<e.newObjects.length;i++)n=e.newObjects[i],n.plane_center?this.planes_.set(n.uuid,{id:n.uuid,center:n.plane_center,extent:[n.plane_extent.x,n.plane_extent.z],modelMatrix:n.transform,alignment:n.plane_alignment,vertices:a(n.geometry.vertices)}):this.anchors_.set(n.uuid,{id:n.uuid,modelMatrix:n.transform});if(e.removedObjects&&e.removedObjects.length)for(i=0;i<e.removedObjects.length;i++)n=e.removedObjects[i],this.planes_.get(n)?this.planes_.delete(n):this.anchors_.delete(n);if(e.objects&&e.objects.length)for(i=0;i<e.objects.length;i++)if(n=e.objects[i],n.plane_center){var r=this.planes_.get(n.uuid);r?(r.center=n.plane_center,r.extent=[n.plane_extent.x,n.plane_extent.z],r.modelMatrix=n.transform,r.alignment=n.plane_alignment,r.vertices=a(n.geometry.vertices)):this.planes_.set(n.uuid,{id:n.uuid,center:n.plane_center,extent:[n.plane_extent.x,n.plane_extent.z],modelMatrix:n.transform,alignment:n.plane_alignment,vertices:a(n.geometry.vertices)})}else{var s=this.anchors_.get(n.uuid);s?s.modelMatrix=n.transform:this.anchors_.set(n.uuid,{id:n.uuid,modelMatrix:n.transform})}},getPosition:function(){return this.arDisplay?this.posePosition:null},getOrientation:function(){return this.arDisplay?this.poseQuaternion:null},getRotation:function(){return this.arDisplay?this.poseRotation:null},getProjectionMatrix:function(){return this.arDisplay?this.projectionMatrix:null},getPlanes:function(){return Array.from(this.planes_.values())},hitTestNoAnchor:function(){function e(){return this.modelMatrix=new Float32Array(16),this}var t={rayStart:new THREE.Vector3,rayEnd:new THREE.Vector3,cameraPosition:new THREE.Vector3,cameraQuaternion:new THREE.Quaternion,projViewMatrix:new THREE.Matrix4,worldRayStart:new THREE.Vector3,worldRayEnd:new THREE.Vector3,worldRayDir:new THREE.Vector3,planeMatrix:new THREE.Matrix4,planeMatrixInverse:new THREE.Matrix4,planeExtent:new THREE.Vector3,planePosition:new THREE.Vector3,planeCenter:new THREE.Vector3,planeNormal:new THREE.Vector3,planeIntersection:new THREE.Vector3,planeIntersectionLocal:new THREE.Vector3,planeHit:new THREE.Matrix4,planeQuaternion:new THREE.Quaternion},a=function(){var e=new THREE.Vector3;return function(t,a,i,n){var r=t.dot(n);return e.subVectors(a,i),e.dot(t)/r}}(),i=function(e,a){t.planeMatrix.fromArray(e.modelMatrix),t.planeIntersection.setFromMatrixPosition(t.planeMatrix);var i=t.planeIntersection.distanceTo(t.cameraPosition);t.planeMatrix.fromArray(a.modelMatrix),t.planeIntersection.setFromMatrixPosition(t.planeMatrix);var n=t.planeIntersection.distanceTo(t.cameraPosition);return i<n?-1:1};return function(n,r){if(n<0||n>1||r<0||r>1)throw new Error("hitTest - x and y values must be normalized [0,1]!");var s=[],o=this.getPlanes();if(!o||0===o.length)return s;t.rayStart.set(2*n-1,2*(1-r)-1,0),t.rayEnd.set(2*n-1,2*(1-r)-1,1),t.planeMatrix.multiplyMatrices(this.projectionMatrix,this.viewMatrix),t.projViewMatrix.getInverse(t.planeMatrix),t.worldRayStart.copy(t.rayStart).applyMatrix4(t.projViewMatrix),t.worldRayEnd.copy(t.rayEnd).applyMatrix4(t.projViewMatrix),t.worldRayDir.subVectors(t.worldRayEnd,t.worldRayStart).normalize();for(var l=0;l<o.length;l++){var c=o[l];t.planeMatrix.fromArray(c.modelMatrix),t.planeCenter.set(c.center.x,c.center.y,c.center.z),t.planePosition.copy(t.planeCenter).applyMatrix4(t.planeMatrix),t.planeAlignment=c.alignment,0===t.planeAlignment?t.planeNormal.set(0,1,0):t.planeNormal.set(t.planeMatrix[4],t.planeMatrix[5],t.planeMatrix[6]);var h=a(t.planeNormal,t.planePosition,t.worldRayStart,t.worldRayDir);if(!(h<0)){t.planeIntersectionLocal.copy(t.worldRayDir).multiplyScalar(h),t.planeIntersection.addVectors(t.worldRayStart,t.planeIntersectionLocal),t.planeExtent.set(c.extent[0],0,c.extent[1]),t.planeMatrixInverse.getInverse(t.planeMatrix),t.planeIntersectionLocal.copy(t.planeIntersection).applyMatrix4(t.planeMatrixInverse);var p=.0075;if(!(Math.abs(t.planeIntersectionLocal.x)>t.planeExtent.x/2+p||Math.abs(t.planeIntersectionLocal.z)>t.planeExtent.z/2+p)){t.planeQuaternion.setFromRotationMatrix(t.planeMatrix),t.planeHit.makeRotationFromQuaternion(t.planeQuaternion).setPosition(t.planeIntersection);for(var d=new e,u=0;u<16;u++)d.modelMatrix[u]=t.planeHit.elements[u];d.i=l,s.push(d)}}}return s.sort(i),s}}(),hitAR:function(){var e=new THREE.Matrix4,t=new THREE.Vector3,a=new THREE.Quaternion,i=new THREE.Vector3,n=new THREE.Vector3;return function(r,s,o,l){if(!this.arDisplay)return[];for(var c=this.hitTestNoAnchor(r,s),h=[],p=0;c&&p<c.length;p++)e.fromArray(c[p].modelMatrix),e.decompose(t,a,i),l.object3D.getWorldPosition(n),h.push({distance:t.distanceTo(n),point:t,object:o&&o.object3D||this.el.sceneEl.object3D});return h}}()})},function(e,t){AFRAME.registerComponent("three-ar",{schema:{takeOverCamera:{default:!0},cameraUserHeight:{default:!1}},init:function(){this.posePosition=new THREE.Vector3,this.poseQuaternion=new THREE.Quaternion,this.poseEuler=new THREE.Euler(0,0,0,"YXZ"),this.poseRotation=new THREE.Vector3,this.projectionMatrix=new THREE.Matrix4,this.onceSceneLoaded=this.onceSceneLoaded.bind(this),this.el.sceneEl.hasLoaded?setTimeout(this.onceSceneLoaded):this.el.sceneEl.addEventListener("loaded",this.onceSceneLoaded)},tick:function(e,t){if(this.arDisplay&&this.arDisplay.getFrameData){this.arView&&this.arView.render(),this.frameData||(this.frameData=new VRFrameData),this.arDisplay.getFrameData(this.frameData),this.posePosition.fromArray(this.frameData.pose.position),this.poseQuaternion.fromArray(this.frameData.pose.orientation),this.poseEuler.setFromQuaternion(this.poseQuaternion),this.poseRotation.set(THREE.Math.RAD2DEG*this.poseEuler.x,THREE.Math.RAD2DEG*this.poseEuler.y,THREE.Math.RAD2DEG*this.poseEuler.z),this.arCamera&&this.data.cameraUserHeight&&(this.posePosition.y+=this.arCamera.el.components.camera.data.userHeight);var a=this.posePosition.x||this.posePosition.y||this.posePosition.z||this.poseQuaternion.x||this.poseQuaternion.y||this.poseQuaternion.z;a?this.poseLost!==!1&&(this.poseLost=!1,this.el.emit("poseFound")):this.poseLost!==!0&&(this.poseLost=!0,this.el.emit("poseLost",!1)),this.projectionMatrix.fromArray(this.frameData.leftProjectionMatrix)}},takeOverCamera:function(e){this.arCamera=e,e.isARPerspectiveCamera=!0,e.vrDisplay=this.arDisplay,e.el.setAttribute("ar-camera","enabled",!0)},onceSceneLoaded:function(){var e=this;window.addEventListener("ardisplayconnect",function(){e.arDisplay||e.checkForARDisplay()}),this.checkForARDisplay()},checkForARDisplay:function(){var e=this;THREE.ARUtils.getARDisplay().then(function(t){if(e.arDisplay=t,t){var a=e.el.sceneEl;e.data.takeOverCamera&&setTimeout(function(){e.takeOverCamera(a.camera)}),a.renderer.alpha=!0,a.renderer.autoClearColor=THREE.ARUtils.isARKit(t)&&!window.WebARonARKitSendsCameraFrames,a.renderer.autoClearDepth=!0,e.arView=new THREE.ARView(t,a.renderer)}})},getPosition:function(){return this.arDisplay&&this.arDisplay.getFrameData?this.posePosition:null},getOrientation:function(){return this.arDisplay&&this.arDisplay.getFrameData?this.poseQuaternion:null},getRotation:function(){return this.arDisplay&&this.arDisplay.getFrameData?this.poseRotation:null},getProjectionMatrix:function(){return this.arDisplay&&this.arDisplay.getFrameData?this.projectionMatrix:null},hitAR:function(){var e=new THREE.Matrix4,t=new THREE.Vector3,a=new THREE.Quaternion,i=new THREE.Vector3,n=new THREE.Vector3;return function(r,s,o,l){if(!this.arDisplay||!this.arDisplay.hitTest)return[];for(var c=this.arDisplay.hitTest(r,s),h=[],p=0;c&&p<c.length;p++)e.fromArray(c[p].modelMatrix),e.decompose(t,a,i),l.object3D.getWorldPosition(n),h.push({distance:t.distanceTo(n),point:t,object:o&&o.object3D||this.el.sceneEl.object3D});return h}}()})}]);