-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathargon-aframe.min.js
2 lines (2 loc) · 35.8 KB
/
argon-aframe.min.js
1
2
!function(t){function e(n){if(i[n])return i[n].exports;var a=i[n]={exports:{},id:n,loaded:!1};return t[n].call(a.exports,a,a.exports,e),a.loaded=!0,a.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}([function(t,e,i){i(7),i(5),i(6),i(9),i(8),i(10)},function(t,e,i){var n=i(4),a={alternate:"alternate",alternateReverse:"alternate-reverse",normal:"normal",reverse:"reverse"},s={linear:n.Easing.Linear.None,ease:n.Easing.Cubic.InOut,"ease-in":n.Easing.Cubic.In,"ease-out":n.Easing.Cubic.Out,"ease-in-out":n.Easing.Cubic.InOut,"ease-cubic":n.Easing.Cubic.In,"ease-in-cubic":n.Easing.Cubic.In,"ease-out-cubic":n.Easing.Cubic.Out,"ease-in-out-cubic":n.Easing.Cubic.InOut,"ease-quad":n.Easing.Quadratic.InOut,"ease-in-quad":n.Easing.Quadratic.In,"ease-out-quad":n.Easing.Quadratic.Out,"ease-in-out-quad":n.Easing.Quadratic.InOut,"ease-quart":n.Easing.Quartic.InOut,"ease-in-quart":n.Easing.Quartic.In,"ease-out-quart":n.Easing.Quartic.Out,"ease-in-out-quart":n.Easing.Quartic.InOut,"ease-quint":n.Easing.Quintic.InOut,"ease-in-quint":n.Easing.Quintic.In,"ease-out-quint":n.Easing.Quintic.Out,"ease-in-out-quint":n.Easing.Quintic.InOut,"ease-sine":n.Easing.Sinusoidal.InOut,"ease-in-sine":n.Easing.Sinusoidal.In,"ease-out-sine":n.Easing.Sinusoidal.Out,"ease-in-out-sine":n.Easing.Sinusoidal.InOut,"ease-expo":n.Easing.Exponential.InOut,"ease-in-expo":n.Easing.Exponential.In,"ease-out-expo":n.Easing.Exponential.Out,"ease-in-out-expo":n.Easing.Exponential.InOut,"ease-circ":n.Easing.Circular.InOut,"ease-in-circ":n.Easing.Circular.In,"ease-out-circ":n.Easing.Circular.Out,"ease-in-out-circ":n.Easing.Circular.InOut,"ease-elastic":n.Easing.Elastic.InOut,"ease-in-elastic":n.Easing.Elastic.In,"ease-out-elastic":n.Easing.Elastic.Out,"ease-in-out-elastic":n.Easing.Elastic.InOut,"ease-back":n.Easing.Back.InOut,"ease-in-back":n.Easing.Back.In,"ease-out-back":n.Easing.Back.Out,"ease-in-out-back":n.Easing.Back.InOut,"ease-bounce":n.Easing.Bounce.InOut,"ease-in-bounce":n.Easing.Bounce.In,"ease-out-bounce":n.Easing.Bounce.Out,"ease-in-out-bounce":n.Easing.Bounce.InOut},r={backwards:"backwards",both:"both",forwards:"forwards",none:"none"},o={indefinite:"indefinite"},l={attribute:"rotation",begin:"",end:"",delay:0,dur:1e3,easing:"ease",direction:a.normal,fill:r.forwards,from:void 0,repeat:0,to:void 0};t.exports.defaults=l,t.exports.directions=a,t.exports.easingFunctions=s,t.exports.fills=r,t.exports.repeats=o},function(t,e,i){t.exports={AFRAME_INJECTED:"aframe-injected",DEFAULT_CAMERA_HEIGHT:1.6,animation:i(1),keyboardevent:i(3)}},function(t,e){t.exports={KEYCODE_TO_CODE:{38:"ArrowUp",37:"ArrowLeft",40:"ArrowDown",39:"ArrowRight",87:"KeyW",65:"KeyA",83:"KeyS",68:"KeyD"}}},function(t,e,i){var n,a;!function(t){if("performance"in t==!1&&(t.performance={}),Date.now=Date.now||function(){return(new Date).getTime()},"now"in t.performance==!1){var e=t.performance.timing&&t.performance.timing.navigationStart?performance.timing.navigationStart:Date.now();t.performance.now=function(){return Date.now()-e}}}(this);var s=s||function(){var t=[];return{REVISION:"14",getAll:function(){return t},removeAll:function(){t=[]},add:function(e){t.push(e)},remove:function(e){var i=t.indexOf(e);i!==-1&&t.splice(i,1)},update:function(e){if(0===t.length)return!1;var i=0;for(e=void 0!==e?e:window.performance.now();i<t.length;)t[i].update(e)?i++:t.splice(i,1);return!0}}}();s.Tween=function(t){var e=t,i={},n={},a={},r=1e3,o=0,l=!1,c=!1,u=!1,h=0,d=null,g=s.Easing.Linear.None,f=s.Interpolation.Linear,v=[],p=null,m=!1,E=null,y=null,b=null;for(var A in t)i[A]=parseFloat(t[A],10);this.to=function(t,e){return void 0!==e&&(r=e),n=t,this},this.start=function(t){s.add(this),c=!0,m=!1,d=void 0!==t?t:window.performance.now(),d+=h;for(var r in n){if(n[r]instanceof Array){if(0===n[r].length)continue;n[r]=[e[r]].concat(n[r])}i[r]=e[r],i[r]instanceof Array==!1&&(i[r]*=1),a[r]=i[r]||0}return this},this.stop=function(){return c?(s.remove(this),c=!1,null!==b&&b.call(e),this.stopChainedTweens(),this):this},this.stopChainedTweens=function(){for(var t=0,e=v.length;t<e;t++)v[t].stop()},this.delay=function(t){return h=t,this},this.repeat=function(t){return o=t,this},this.yoyo=function(t){return l=t,this},this.easing=function(t){return g=t,this},this.interpolation=function(t){return f=t,this},this.chain=function(){return v=arguments,this},this.onStart=function(t){return p=t,this},this.onUpdate=function(t){return E=t,this},this.onComplete=function(t){return y=t,this},this.onStop=function(t){return b=t,this},this.update=function(t){var s;if(t<d)return!0;m===!1&&(null!==p&&p.call(e),m=!0);var c=(t-d)/r;c=c>1?1:c;var b=g(c);for(s in n){var A=i[s]||0,w=n[s];w instanceof Array?e[s]=f(w,b):("string"==typeof w&&(w=A+parseFloat(w,10)),"number"==typeof w&&(e[s]=A+(w-A)*b))}if(null!==E&&E.call(e,b),1==c){if(o>0){isFinite(o)&&o--;for(s in a){if("string"==typeof n[s]&&(a[s]=a[s]+parseFloat(n[s],10)),l){var R=a[s];a[s]=n[s],n[s]=R}i[s]=a[s]}return l&&(u=!u),d=t+h,!0}null!==y&&y.call(e);for(var M=0,I=v.length;M<I;M++)v[M].start(t);return!1}return!0}},s.Easing={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 1-Math.cos(t*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(-Math.pow(2,-10*(t-1))+2)}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){var e,i=.1,n=.4;return 0===t?0:1===t?1:(!i||i<1?(i=1,e=n/4):e=n*Math.asin(1/i)/(2*Math.PI),-(i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n)))},Out:function(t){var e,i=.1,n=.4;return 0===t?0:1===t?1:(!i||i<1?(i=1,e=n/4):e=n*Math.asin(1/i)/(2*Math.PI),i*Math.pow(2,-10*t)*Math.sin((t-e)*(2*Math.PI)/n)+1)},InOut:function(t){var e,i=.1,n=.4;return 0===t?0:1===t?1:(!i||i<1?(i=1,e=n/4):e=n*Math.asin(1/i)/(2*Math.PI),(t*=2)<1?-.5*(i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n)):i*Math.pow(2,-10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n)*.5+1)}},Back:{In:function(t){var e=1.70158;return t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?.5*(t*t*((e+1)*t-e)):.5*((t-=2)*t*((e+1)*t+e)+2)}},Bounce:{In:function(t){return 1-s.Easing.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*s.Easing.Bounce.In(2*t):.5*s.Easing.Bounce.Out(2*t-1)+.5}}},s.Interpolation={Linear:function(t,e){var i=t.length-1,n=i*e,a=Math.floor(n),r=s.Interpolation.Utils.Linear;return e<0?r(t[0],t[1],n):e>1?r(t[i],t[i-1],i-n):r(t[a],t[a+1>i?i:a+1],n-a)},Bezier:function(t,e){var i,n=0,a=t.length-1,r=Math.pow,o=s.Interpolation.Utils.Bernstein;for(i=0;i<=a;i++)n+=r(1-e,a-i)*r(e,i)*t[i]*o(a,i);return n},CatmullRom:function(t,e){var i=t.length-1,n=i*e,a=Math.floor(n),r=s.Interpolation.Utils.CatmullRom;return t[0]===t[i]?(e<0&&(a=Math.floor(n=i*(1+e))),r(t[(a-1+i)%i],t[a],t[(a+1)%i],t[(a+2)%i],n-a)):e<0?t[0]-(r(t[0],t[0],t[1],t[1],-n)-t[0]):e>1?t[i]-(r(t[i],t[i],t[i-1],t[i-1],n-i)-t[i]):r(t[a?a-1:0],t[a],t[i<a+1?i:a+1],t[i<a+2?i:a+2],n-a)},Utils:{Linear:function(t,e,i){return(e-t)*i+t},Bernstein:function(t,e){var i=s.Interpolation.Utils.Factorial;return i(t)/i(e)/i(t-e)},Factorial:function(){var t=[1];return function(e){var i,n=1;if(t[e])return t[e];for(i=e;i>1;i--)n*=i;return t[e]=n}}(),CatmullRom:function(t,e,i,n,a){var s=.5*(i-t),r=.5*(n-e),o=a*a,l=a*o;return(2*e-2*i+s+r)*l+(-3*e+3*i-2*s-r)*o+s*a+e}}},function(i){n=[],a=function(){return s}.apply(e,n),!(void 0!==a&&(t.exports=a))}(this)},function(t,e){var i=1e-5;AFRAME.registerComponent("fixedsize",{schema:{default:1},init:function(){this.scale=1,this.factor=1},update:function(){var t=this.data;this.scale=0===t?i:t},tick:function(t){var e=this.el.object3D,i=this.el.sceneEl.camera;if(i){var n=i.getWorldPosition(),a=e.getWorldPosition(),s=a.distanceTo(n),r=this.el.sceneEl.argonApp.view.renderHeight;this.factor=2*(this.scale/r),fovScale=2*Math.tan(THREE.Math.degToRad(i.fov)/2);var o=fovScale*(s<i.near?i.near*this.factor:s*this.factor);e.scale.set(o,o,o)}}}),AFRAME.registerComponent("trackvisibility",{schema:{default:!0},init:function(){var t=this;this.el.addEventListener("referenceframe-statuschanged",function(e){t.updateVisibility(e)})},updateVisibility:function(t){console.log("visibility changed: "+t.detail.found),this.data&&t.detail.target===this.el&&(this.el.object3D.visible=t.detail.found)},update:function(){}}),AFRAME.registerComponent("physical",{schema:{default:!0},init:function(){},update:function(t){var e=this.el.getOrCreateObject3D("mesh");e&&(e.material.colorWrite=!this.data,e.renderOrder=this.data?-2:0)}}),AFRAME.registerComponent("show-in",{schema:{ar:{default:!1},vr:{default:!1},arhmd:{default:!1},vrhmd:{default:!1}},init:function(){var t=this;this.el.sceneEl.addEventListener("enter-vr",function(e){t.updateVisibility(e)}),this.el.sceneEl.addEventListener("exit-vr",function(e){t.updateVisibility(e)}),this.el.sceneEl.addEventListener("enter-ar",function(e){t.updateVisibility(e)}),this.el.sceneEl.addEventListener("exit-ar",function(e){t.updateVisibility(e)}),t.updateVisibility()},updateVisibility:function(){var t=this.el.sceneEl,e=t.is("ar-mode"),i=t.is("vr-mode"),n=this.data,a=!1;n.arhmd&&e&&i&&(a=!0),n.vrhmd&&!e&&i&&(a=!0),n.ar&&e&&(a=!0),n.vr&&!e&&(a=!0),this.el.object3D.visible=a},update:function(){}}),AFRAME.registerComponent("desiredreality",{schema:{src:{type:"src"},name:{default:"Custom Reality"}},init:function(){var t=this.el;t.isArgon||console.warn("vuforiadataset should be attached to an <ar-scene>.")},remove:function(){var t=this.el;t.isArgon&&t.argonApp.reality.setDesired(void 0)},update:function(){var t=this.el,e=this.data;t.isArgon&&t.argonApp.reality.setDesired({title:e.name,uri:Argon.resolveURL(e.src)})}}),AFRAME.registerComponent("enablehighaccuracy",{schema:{default:!0},init:function(){var t=this.el;t.isArgon||console.warn("enablehighaccuracy should be attached to an <ar-scene>.")},update:function(){var t=this.el,e=this.data;t.isArgon&&(t.enableHighAccuracy=e,t.subscribeGeolocation())}}),AFRAME.registerComponent("sunmoon",{schema:{default:!0},init:function(){var t=this.el;t.isArgon||console.warn("sunmoon should be attached to an <ar-scene>."),THREE.SunMoonLights&&(t.isArgon&&this.el.subscribeGeolocation(),this.sunMoonLights=new THREE.SunMoonLights,window.CESIUM_BASE_URL="https://samples-develop.argonjs.io/resources/cesium/")},remove:function(){var t=this.el;t.isArgon&&this.sunMoonLights&&(this.sunMoonLights=null,this.el.removeObject3D("sunmoon"))},update:function(){var t=this.el,e=this.data;t.isArgon&&(e?this.el.setObject3D("sunmoon",this.sunMoonLights.lights):this.el.removeObject3D("sunmoon"))},tick:function(){if(this.data&&this.sunMoonLights){var t=this.el.argonApp.context;this.sunMoonLights.update(t.time,t.defaultReferenceFrame)}}}),AFRAME.registerComponent("trigger",{multiple:!0,schema:{radius:{default:1},event:{default:"trigger"},initial:{default:!1}},init:function(){this.teststateset=!1,this.laststateinthetrigger=!1,this.name=""},update:function(t){this.radiusSquared=this.data.radius*this.data.radius,this.name=this.id?this.id:""},tick:function(){var t=this.data,e=this.radiusSquared,i=t.event,n=this.laststateset,a=this.laststateinthetrigger,s=this.el.sceneEl.camera;if(s){var r=s.position,o=this.el.object3D.position.distanceToSquared(r);o<=e?((!n&&t.initial||n&&!a)&&this.el.emit(i,{name:this.name,inside:!0,initial:!n,distanceSquared:o}),this.laststateinthetrigger=!0):((!n&&t.initial||n&&a)&&this.el.emit(i,{name:this.name,inside:!1,initial:!n,distanceSquared:o}),this.laststateinthetrigger=!1),this.laststateset=!0}}})},function(t,e){var i=Argon.Cesium,n=i.Cartesian3,a=i.Cartographic,s=i.ConstantPositionProperty,r=i.ReferenceFrame,o=i.ReferenceEntity,l=THREE.Math.degToRad,c=-7e6;AFRAME.registerComponent("referenceframe",{schema:{lla:{type:"vec3",default:{x:0,y:0,z:c}},parent:{default:"FIXED"},userotation:{default:!0},useposition:{default:!0}},init:function(){var t=this.el,e=this;this.update=this.update.bind(this),t.sceneEl?this.finishedInit=!0:(console.warn("referenceFrame initialized but no sceneEl"),this.finishedInit=!1),t.sceneEl&&!t.sceneEl.isArgon&&console.warn("referenceframe must be used on a child of a <ar-scene>."),this.localRotationEuler=new THREE.Euler(0,0,0,"XYZ"),this.localPosition={x:0,y:0,z:0},this.localScale={x:1,y:1,z:1},this.knownFrame=!1,t.addEventListener("componentchanged",this.updateLocalTransform.bind(this)),t.sceneEl&&t.sceneEl.addEventListener("argon-initialized",function(){e.update(e.data)})},checkFinished:function(){this.finishedInit||(this.finishedInit=!0,this.update(this.data))},update:function(t){if(this.el.sceneEl){var e=this.el,r=e.sceneEl,o=r.argonApp,u=this.data,h=e.getAttribute("position");h?(this.localPosition.x=h.x,this.localPosition.y=h.y,this.localPosition.z=h.z):(this.localPosition.x=0,this.localPosition.y=0,this.localPosition.z=0);var d=e.getAttribute("rotation");d?(this.localRotationEuler.x=l(d.x),this.localRotationEuler.y=l(d.y),this.localRotationEuler.z=l(d.z)):(this.localRotationEuler.x=0,this.localRotationEuler.y=0,this.localRotationEuler.z=0);var g=e.getAttribute("scale");if(g?(this.localScale.x=g.x,this.localScale.y=g.y,this.localScale.z=g.z):(this.localScale.x=1,this.localScale.y=1,this.localScale.z=1),o){"FIXED"==u.parent&&r.subscribeGeolocation();var f=this.getParentEntity(u.parent),v=null;if(this.attrValue.hasOwnProperty("lla")){if("FIXED"!==u.parent&&(console.warn("Using 'lla' with a 'parent' other than 'FIXED' is invalid. Ignoring parent value."),u.parent="FIXED"),u.lla.z===c){v=a.fromDegrees(u.lla.x,u.lla.y);var p=this,m=Argon.updateHeightFromTerrain(v);m?m.then(function(){console.log("found height for "+u.lla.x+", "+u.lla.y+" => "+v.height),v.height&&(p.data.lla.z=v.height),p.update(p.data)}).catch(function(t){console.log(t)}):console.log("failed to get height! "),console.log("initial height for "+u.lla.x+", "+u.lla.y+" => "+v.height)}else console.log("had a valid altitude: "+u.lla.z),v=a.fromDegrees(u.lla.x,u.lla.y,u.lla.z);var E=o.entity.createFixed(v,Argon.eastUpSouthToFixedFrame);""!==e.id&&(E._id=e.id),null==this.cesiumEntity||""!==e.id&&e.id!==this.cesiumEntity.id?this.cesiumEntity=E:(this.cesiumEntity.position=E.position,this.cesiumEntity.orientation=E.orientation)}else if(null==this.cesiumEntity||""!==e.id&&e.id!==this.cesiumEntity.id){var y={position:new s(n.ZERO,f),orientation:i.Quaternion.IDENTITY};""!==e.id&&(y.id=e.id),this.cesiumEntity=new i.Entity(y)}else this.cesiumEntity.position.setValue(n.ZERO,f),this.cesiumEntity.orientation.setValue(i.Quaternion.IDENTITY)}}},getParentEntity:function(t){var e=this.el,i=this,n=this.el.sceneEl.argonApp,a=null;if("FIXED"===t)a=r.FIXED;else{var s=e.sceneEl.systems.vuforia;if(s){var l=t.split(".");if(3===l.length&&"vuforia"===l[0]&&(console.log("looking for target '"+t+"'"),a=s.getTargetEntity(l[1],l[2]),null===a&&(console.log("not found, subscribing to target '"+t+"'"),a=s.subscribeToTarget(l[1],l[2])),null===a)){console.log("not loaded, waiting for dataset for target '"+t+"'");var c=l[1];e.sceneEl.addEventListener("argon-vuforia-dataset-loaded",function(t){console.log("dataset loaded."),console.log("dataset name '"+t.detail.target.name+"', our name '"+c+"'"),t.detail.target.name===c&&i.update(i.data)}),console.log("finished setting up to wait for dataset for target '"+t+"'")}}a||(a=n.context.entities.getById(t)),a||(a=new o(n.context.entities,t))}return a},convertReferenceFrame:function(t){var e=this.el;if(!this.cesiumEntity)return void console.warn("Tried to convertReferenceFrame on element '"+e.id+"' but no cesiumEntity initialized on that element")},updateLocalTransform:function(t){var e=t.detail.newData;t.target==this.el&&("rotation"==t.detail.name?(this.localRotationEuler.x=l(e.x),this.localRotationEuler.y=l(e.y),this.localRotationEuler.z=l(e.z)):"position"==t.detail.name?(this.localPosition.x=e.x,this.localPosition.y=e.y,this.localPosition.z=e.z):"scale"==t.detail.name&&(this.localScale.x=e.x,this.localScale.y=e.y,this.localScale.z=e.z))},tick:function(){var t=new THREE.Matrix4;return function(e){this.checkFinished();var i=this.data,n=this.el,a=n.object3D,s=a.matrix,r=n.sceneEl.argonApp,o=!n.parentEl.isScene;if(r&&this.cesiumEntity){var l=r.context.getEntityPose(this.cesiumEntity);l.poseStatus&Argon.PoseStatus.KNOWN?(this.knownFrame=!0,i.userotation?a.quaternion.copy(l.orientation):o&&(a.rotation.copy(this.localRotationEuler),a.rotation.order="YXZ"),i.useposition?a.position.copy(l.position):o&&a.position.copy(this.localPosition),l.poseStatus&Argon.PoseStatus.FOUND&&(console.log("reference frame changed to FOUND"),n.emit("referenceframe-statuschanged",{target:this.el,found:!0})),n.parentEl.isScene||(a.scale.set(1,1,1),n.parentEl.object3D.updateMatrixWorld(),t.getInverse(n.parentEl.object3D.matrixWorld),s.premultiply(t),s.decompose(a.position,a.quaternion,a.scale),a.updateMatrixWorld())):(this.knownFrame=!1,l.poseStatus&Argon.PoseStatus.LOST&&(console.log("reference frame changed to LOST"),n.emit("referenceframe-statuschanged",{target:this.el,found:!1})))}}}()}),AFRAME.registerPrimitive("ar-geopose",{defaultComponents:{referenceframe:{}},mappings:{lla:"referenceframe.lla",userotation:"referenceframe.userotation",useposition:"referenceframe.useposition"}}),AFRAME.registerPrimitive("ar-frame",{defaultComponents:{referenceframe:{}},mappings:{parent:"referenceframe.parent",userotation:"referenceframe.userotation",useposition:"referenceframe.useposition"}})},function(t,e,n){var a=AFRAME.AEntity,s=AFRAME.ANode,r=n(2),o="data-aframe-argon-camera",l=document.createElement("style");l.type="text/css",document.head.insertBefore(l,document.head.firstChild);var c=l.sheet;c.insertRule("ar-scene {\n display: block;\n overflow: hidden;\n position: relative;\n height: 100%;\n width: 100%;\n}\n",0),c.insertRule("\nar-scene video,\nar-scene img,\nar-scene audio {\n display: none;\n}\n",1),document.DOMReady=function(){return new Promise(function(t,e){"loading"!=document.readyState?t(document):document.addEventListener("DOMContentLoaded",function(){t(document)})})};var u=new THREE.Matrix4;AFRAME.registerElement("ar-scene",{prototype:Object.create(a.prototype,{defaultComponents:{value:{canvas:"",inspector:"","keyboard-shortcuts":""}},createdCallback:{value:function(){this.isMobile=AFRAME.utils.isMobile(),this.isIOS=AFRAME.utils.isIOS(),this.isScene=!0,this.isArgon=!0,this.object3D=new THREE.Scene,this.systems={},this.time=0,this.argonApp=null,this.renderer=null,this.canvas=null,this.session=null,this.init()}},init:{value:function(){this.behaviors=[],this.hasLoaded=!1,this.isPlaying=!1,this.originalHTML=this.innerHTML,Argon.ArgonSystem.instance?this.argonApp=Argon.ArgonSystem.instance:this.argonApp=Argon.init(this),this.enableHighAccuracy=!1,this.argonRender=this.argonRender.bind(this),this.argonUpdate=this.argonUpdate.bind(this),this.argonPresentChange=this.argonPresentChange.bind(this),this.argonChangeReality=this.argonChangeReality.bind(this),this.argonSessionChange=this.argonSessionChange.bind(this),this.argonApp.reality.changeEvent.addEventListener(this.argonChangeReality),this.argonApp.reality.connectEvent.addEventListener(this.argonSessionChange),this.initializeArgonView=this.initializeArgonView.bind(this),this.argonPresentChange(),this.addEventListener("render-target-loaded",function(){this.setupRenderer(),document.DOMReady().then(this.initializeArgonView)})},writable:!0},setupRenderer:{value:function(){var t=this.canvas,e="true"===this.getAttribute("antialias"),i="true"===this.getAttribute("logarithmicdepth");THREE.CSS3DArgonRenderer?this.cssRenderer=new THREE.CSS3DArgonRenderer:this.cssRenderer=null,THREE.CSS3DArgonHUD?this.hud=new THREE.CSS3DArgonHUD:this.hud=null,this.renderer=new THREE.WebGLRenderer({canvas:t,alpha:!0,antialias:e||window.hasNativeWebVRImplementation,logarithmicDepthBuffer:i}),this.renderer.setPixelRatio(window.devicePixelRatio)},writable:!0},initializeArgonView:{value:function(){var t=[{source:this.renderer.domElement}];this.cssRenderer&&t.push({source:this.cssRenderer.domElement}),this.hud&&t.push({source:this.hud.domElement}),this.argonApp.view.setLayers(t),this.argonPresentChange(),this.emit("argon-initialized",{target:this.argonApp})},writable:!0},subscribeGeolocation:{value:function(){this.argonApp.context.subscribeGeolocation({enableHighAccuracy:this.enableHighAccuracy})}},attachedCallback:{value:function(){this.initSystems(),this.play(),AFRAME.scenes.push(this)},writable:window.debug},addEventListeners:{value:function(){this.argonApp.renderEvent.addEventListener(this.argonRender),this.argonApp.updateEvent.addEventListener(this.argonUpdate),this.argonApp.device.presentHMDChangeEvent.addEventListener(this.argonPresentChange)},writable:!0},argonSessionChange:{value:function(t){this.session=t},writable:!0},setStageGeolocation:{value:function(t){if(this.session)return this.argonApp.reality.setStageGeolocation(this.session,t)},writable:!0},resetStageGeolocation:{value:function(){if(this.session)return this.argonApp.reality.resetStageGeolocation(this.session)},writable:!0},argonChangeReality:{value:function(){this.argonPresentChange()},writable:!0},argonPresentChange:{value:function(){var t=this.argonApp.device,e=this.argonApp.reality;console.log("-- checking presentation mode: "+(this.is("vr-mode")?"vr":"-")+(this.is("ar-mode")?" ar":" ")),t.isPresentingHMD?(this.is("vr-mode")||(this.addState("vr-mode"),console.log(">> enter vr-mode"),this.emit("enter-vr",{target:this})),t.isPresentingRealityHMD?this.is("ar-mode")||(this.addState("ar-mode"),console.log(">> enter ar-mode"),this.emit("enter-ar",{target:this})):this.is("ar-mode")&&(this.removeState("ar-mode"),console.log("<< exit ar-mode"),this.emit("exit-ar",{target:this}))):(this.is("vr-mode")&&(this.removeState("vr-mode"),console.log("<< exit vr-mode"),this.emit("exit-vr",{target:this})),e.current!=Argon.RealityViewer.EMPTY?this.is("ar-mode")||(this.addState("ar-mode"),console.log(">> enter ar-mode"),this.emit("enter-ar",{target:this})):this.is("ar-mode")&&(this.removeState("ar-mode"),console.log("<< exit ar-mode"),this.emit("exit-ar",{target:this})))},writable:!0},removeEventListeners:{value:function(){this.argonApp.updateEvent.removeEventListener(this.argonUpdate),this.argonApp.renderEvent.removeEventListener(this.argonRender),this.argonApp.device.presentChangeEvent.removeEventListener(this.argonPresentChange)},writable:!0},play:{value:function(){var t=this;return this.renderStarted?void a.prototype.play.call(this):(this.addEventListener("loaded",function(){if(!this.renderStarted){this.renderStarted=!0;var e=function(){var e=null,n=t.querySelectorAll("[camera]");for(i=0;i<n.length;i++)if(cameraEl=n[i],"AR-CAMERA"!==cameraEl.tagName)if(cameraEl.sceneEl)cameraEl.setAttribute("camera","active",!1),cameraEl.pause();else{var a=function(){var t=cameraEl;return function(){t.setAttribute("camera","active",!1),t.pause()}}();cameraEl.addEventListener("nodeready",a)}else e=cameraEl;if(null==e){var s=document.createElement("ar-camera");s.setAttribute(o,""),s.setAttribute(r.AFRAME_INJECTED,""),t.appendChild(s)}};this.addEventListener("camera-set-active",e),e(),this.argonApp?t.addEventListeners():this.addEventListener("argon-initialized",function(){t.addEventListeners()}),a.prototype.play.call(this),window.performance&&window.performance.mark("render-started"),this.emit("renderstart")}}),void setTimeout(function(){a.prototype.load.call(t)}))}},detachedCallback:{value:function(){var t;this.animationFrameID&&(cancelAnimationFrame(this.animationFrameID),this.animationFrameID=null),this.argonApp.reality.changeEvent.removeEventListener(this.argonChangeReality),this.argonApp.reality.connectEvent.removeEventListener(this.argonSessionChange),this.removeEventListeners(),t=scenes.indexOf(this),scenes.splice(t,1)}},reload:{value:function(t){function e(){i.isPlaying&&a.prototype.play.call(i)}var i=this;t&&this.pause(),this.innerHTML=this.originalHTML,this.init(),s.prototype.load.call(this,e)}},argonUpdate:{value:function(t){var e=t.timestamp,i=t.deltaTime;this.isPlaying&&this.tick(e,i),this.time=e},writable:!0},tick:{value:function(t,e){var i=this.systems;TWEEN.update(t),this.behaviors.forEach(function(i){i.el.isPlaying&&i.tick(t,e)}),Object.keys(i).forEach(function(n){i[n].tick&&i[n].tick(t,e)})}},enterVR:{value:function(t){function e(){n.addState("vr-mode"),n.emit("enter-vr",t)}function i(t){throw t&&t.message?new Error("Failed to enter VR mode (`argonApp.device.requestEnterHMD`): "+t.message):new Error("Failed to enter VR mode (`argonApp.device.requestEnterHMD`).")}var n=this;return this.is("vr-mode")?Promise.resolve("Already in VR."):this.argonApp?this.argonApp.device.requestEnterHMD(e,i):void 0}},exitVR:{value:function(){function t(){i.removeState("vr-mode"),i.emit("exit-vr",{target:i})}function e(t){throw t&&t.message?new Error("Failed to exit VR mode (`exitPresent`): "+t.message):new Error("Failed to exit VR mode (`exitPresent`).")}var i=this;return this.is("vr-mode")?this.argonApp?this.argonApp.device.requestEnterHMD(t,e):void 0:Promise.resolve("Not in VR.")}},argonRender:{value:function(t){var e=this.camera,i=this.renderer;if(!i||!e)return void(this.animationFrameID=null);var n=this.argonApp,a=this.object3D,s=this.cssRenderer,r=this.hud;e.parent&&(e.parent.updateMatrixWorld(),u.getInverse(e.parent.matrixWorld));const o=n.view;i.setSize(o.renderWidth,o.renderHeight,!1);var l=o.viewport;this.cssRenderer&&s.setSize(l.width,l.height),this.hud&&r.setSize(l.width,l.height);var c=n.view.subviews;this.is("vr-mode")?1==c.length&&(console.log("calling presentChange from render, because vr-mode is set and view is mono"),this.argonPresentChange()):c.length>1&&(console.log("calling presentChange from render, because vr-mode not set and view is stereo"),this.argonPresentChange()),e.near=c[0].frustum.near,e.far=c[0].frustum.far,e.aspect=c[0].frustum.aspect,l.width!=o.renderWidth?i.setPixelRatio(1):i.setPixelRatio(window.devicePixelRatio);for(var h=0;h<c.length;h++){var d=c[h],g=d.frustum;e.position.copy(d.pose.position),e.quaternion.copy(d.pose.orientation),e.updateMatrix(),e.matrix.premultiply(u),e.matrix.decompose(e.position,e.quaternion,e.scale),e.projectionMatrix.fromArray(d.projectionMatrix);var f=d.viewport,v=f.x,p=f.y,m=f.width,E=f.height;this.cssRenderer&&(e.fov=THREE.Math.radToDeg(g.fovy),s.setViewport(v,p,m,E,d.index),s.render(a,e,d.index)),this.hud&&(r.setViewport(v,p,m,E,d.index),r.render(d.index));var y=d.renderViewport,v=y.x,p=y.y,m=y.width,E=y.height;i.setViewport(v,p,m,E),i.setScissor(v,p,m,E),i.setScissorTest(!0),i.render(a,e)}this.animationFrameID=null},writable:!0},initSystems:{value:function(){var t=Object.keys(AFRAME.systems);t.forEach(this.initSystem.bind(this))}},initSystem:{value:function(t){var e;this.systems[t]||(e=this.systems[t]=new AFRAME.systems[t](this),e.init())}},addBehavior:{value:function(t){var e=this.behaviors;e.indexOf(t)===-1&&e.push(t)}},getAttribute:{value:function(t){var e=this.systems[t];return e?e.data:a.prototype.getAttribute.call(this,t)}},getComputedAttribute:{value:function(t){warn("`getComputedAttribute` is deprecated. Use `getAttribute` instead."),this.getAttribute(t)}},getDOMAttribute:{value:function(t){var e=this.systems[t];return e?e.data:a.prototype.getDOMAttribute.call(this,t)}},setAttribute:{value:function(t,e,i){var n=this.systems[t];return n?void s.prototype.setAttribute.call(this,t,e):void a.prototype.setAttribute.call(this,t,e,i)}},removeBehavior:{value:function(t){var e=this.behaviors,i=e.indexOf(t);i!==-1&&e.splice(i,1)}},resize:{value:function(){},writable:window.debug}})}),AFRAME.registerPrimitive("ar-camera",{defaultComponents:{camera:{active:!0},referenceframe:{parent:"ar.user"}}})},function(t,e){AFRAME.registerSystem("vuforia",{init:function(){this.key="",this.api=null,this.datasetMap={},this.available=!1,this.sceneEl.addEventListener("argon-initialized",this.startVuforia.bind(this))},setKey:function(t){this.key=t,this.sceneEl.argonApp&&this.startVuforia()},startVuforia:function(){var t=this,e=this.sceneEl,i=e.argonApp;i&&i.vuforia&&(this.api||""!==this.key&&i.vuforia.isAvailable().then(function(n){if(!t.available){if(!n)return t.available=!1,console.warn("vuforia not available on this platform."),void e.emit("argon-vuforia-not-available",{target:e});t.available=!0,i.vuforia.init({encryptedLicenseData:t.key}).then(function(i){t.api=i,console.log("vuforia initialized!"),Object.keys(t.datasetMap).forEach(function(e,i){var n=t.datasetMap[e];console.log("re-initializing dataset "+e+" as active="+n.active),t.createOrUpdateDataset(n.component,e,n.url,n.active)}),e.emit("argon-vuforia-initialized",{target:e})}).catch(function(t){console.log("vuforia failed to initialize: "+t.message),e.emit("argon-vuforia-initialization-failed",{target:e,error:t})})}}))},createEmptyDatasetObject:function(){return{component:null,api:null,url:null,fetched:!1,loaded:!1,active:!1,targets:{},trackables:null,initInProgress:!1}},createOrUpdateDataset:function(t,e,i,n){var a=this,s=this.api,r=this.datasetMap[e];if(r)if(r.component){if(r.component!=t)return void console.warn("vuforia.createOrUpdateDataset called multiple times for id="+e+", ignoring extra datasets");if(r.url!=i)return void console.warn("can't change the url for a vuforia dataset once it's created. Ignoring new URL '"+i+"' for dataset '"+e+"'")}else r.component=t,r.url=i;else r=this.datasetMap[e]=this.createEmptyDatasetObject(),r.component=t,r.url=i;if(r.active=n,console.log("creating dataset "+e+" active="+n),s){if(r.initInProgress)return void(r.active=n);if(r.api)return r.active=n,void(fetched&&a.setDatasetActive(e,r.active));console.log("objectTracker.createDataSet "+e),r.initInProgress=!0,s.objectTracker.createDataSet(i).then(function(t){console.log("created dataset "+e),r.initInProgress=!1,r.api=t,t.fetch().then(function(){console.log("fetched dataset "+e),r.fetched=!0,console.log("now, re-activate dataset "+e+" active="+r.active),a.setDatasetActive(e,r.active),r.component.datasetLoaded=!0,console.log("re-activated dataset "+e+" active="+r.active),a.sceneEl.emit("argon-vuforia-dataset-downloaded",{target:r.component})}).catch(function(t){console.log("couldn't download dataset: "+t.message),sceneEl.emit("argon-vuforia-dataset-download-failed",{target:sceneEl,error:t})})})}},setDatasetActive:function(t,e){var i=this,n=this.api,a=this.datasetMap[t];if(console.log("make dataset "+t+" active="+e),!n){if(a)return void(a.active=e);throw new Error("vuforia.setDatsetActive call before dataset initialized")}if(!a)throw new Error('ar-vuforia-dataset "'+t+'" should have been created before being activated');console.log("really making dataset "+t+" active="+e),!a.loaded&&e?(console.log("loading dataset "+t+" active="+e),a.api.load().then(function(){console.log("loaded dataset "+t+" active="+e),a.loaded||(a.loaded=!0,a.fetched=!0,a.trackables=a.api.getTrackables(),e&&(a.active=!0,n.objectTracker.activateDataSet(a.api)),Object.keys(a.targets).forEach(function(e,n){console.log("re-subscribing to target "+t+"."+e),i.subscribeToTarget(t,e,!0)}),i.sceneEl.emit("argon-vuforia-dataset-loaded",{target:a.component,
trackables:a.trackables}),console.log("dataset "+t+" loaded, ready to go"))}).catch(function(t){console.log("couldn't load dataset: "+t.message),sceneEl.emit("argon-vuforia-dataset-load-failed",{target:sceneEl,error:t})})):a.active!=e&&(a.active=e,e?n.objectTracker.activateDataSet(a.api):n.objectTracker.deactivateDataSet(a.api))},subscribeToTarget:function(t,e,i){var n=this.api,a=this.datasetMap[t];a||(a=this.datasetMap[t]=this.createEmptyDatasetObject());var s=a.targets[e];if(s?i||(a.targets[e]+=1):a.targets[e]=1,console.log("subscribe to "+t+"."+e),!n)return null;if(a.loaded){var r=a.trackables[e];return console.log("dataset loaded, subscribe to "+t+"."+e),r&&r.id?(console.log("subscribed to "+t+"."+e+" as "+r.id),this.sceneEl.argonApp.context.subscribeToEntityById(r.id)):(console.warn("can't subscribe to target '"+e+"' does not exist in dataset '"+t+"'"),null)}return null},getTargetEntity:function(t,e){var i=this.api,n=this.datasetMap[t];if(console.log("getTargetEntity "+t+"."+e),!i||!n||!n.loaded)return null;var a=n.targets[e];if(!a)return null;var s=n.trackables[e];return console.log("everything loaded, get "+t+"."+e),s&&s.id?(console.log("retrieved "+t+"."+e+" as "+s.id),this.sceneEl.argonApp.context.entities.getById(s.id)):(console.warn("can't get target '"+e+"', does not exist in dataset '"+t+"'"),null)}}),AFRAME.registerComponent("vuforiakey",{schema:{default:" "},init:function(){this.key=null},update:function(t){var e=this.el,i=this.el.sceneEl,n=i.systems.vuforia;if(!e.isArgon)return void console.warn("vuforia component can only be applied to <ar-scene>");var a=e.querySelector(this.data);return a?void(a.isAssetItem?(this.key=a.data,n.setKey(a.data)):(this.key=a.innerHTML,n.setKey(a.innerHTML))):void console.warn('vuforia component cannot find asset "'+this.data+'"')}}),AFRAME.registerComponent("vuforiadataset",{multiple:!0,schema:{src:{type:"src"},active:{default:!0}},init:function(){var t=this.el;this.name="default_dataset",this.active=!1,this.datasetLoaded=!1,t.isArgon||console.warn("vuforiadataset should be attached to an <ar-scene>.")},remove:function(){if(this.active){var t=this.el.sceneEl,e=t.systems.vuforia;e.setDatasetActive(this.name,!1)}},update:function(t){var e=this.el.sceneEl;this.name=this.id?this.id:"default_dataset";var i=e.systems.vuforia;i.createOrUpdateDataset(this,this.name,this.data.src,this.data.active)}})},function(t,e){AFRAME.registerComponent("css-object",{schema:{div:{default:""},div2:{default:""}},init:function(){this.div=null,this.div2=null},update:function(){var t=this.data;""!==t.div&&(this.div=document.querySelector(t.div),""!==t.div2&&(this.div2=document.querySelector(t.div2)),this.div&&THREE.CSS3DObject&&(null===this.div2?this.el.setObject3D("div",new THREE.CSS3DObject(this.div)):this.el.setObject3D("div",new THREE.CSS3DObject([this.div,this.div2]))))},remove:function(){this.div&&THREE.CSS3DObject&&this.el.removeObject3D("div")}})},function(t,e){AFRAME.registerComponent("panorama",{multiple:!0,schema:{src:{type:"src"},lla:{type:"vec3"},initial:{default:!1},offsetdegrees:{default:0},easing:{default:"Quadratic.InOut"},duration:{default:500}},init:function(){var t=this.el;this.name="default",this.active=!1,this.panoRealitySession=void 0,this.panorama=void 0,this.showOptions=void 0,t.isArgon?(t.argonApp.reality.connectEvent.addEventListener(this.realityWatcher.bind(this)),t.addEventListener("showpanorama",this.showPanorama.bind(this))):console.warn("panorama should be attached to an <ar-scene>.")},update:function(t){this.name=this.id?this.id:"default",this.panorama={name:this.name,url:Argon.resolveURL(this.data.src),longitude:this.data.lla.x,latitude:this.data.lla.y,height:this.data.lla.z,offsetDegrees:this.data.offsetdegrees},this.showOptions={url:Argon.resolveURL(this.data.src),transition:{easing:this.data.easing,duration:this.data.duration}}},realityWatcher:function(t){if(t.supportsProtocol("edu.gatech.ael.panorama")){this.panoRealitySession=t,this.panoRealitySession.request("edu.gatech.ael.panorama.loadPanorama",this.panorama),this.data.initial&&this.el.emit("showpanorama",{name:this.name});var e=this;t.closeEvent.addEventListener(function(){e.panoRealitySession=void 0})}},showPanorama:function(t){if(t.detail.name===this.name){this.active=!0;var e=this;this.panoRealitySession&&this.panoRealitySession.request("edu.gatech.ael.panorama.showPanorama",this.showOptions).then(function(){console.log("showing panorama: "+e.name),e.el.emit("showpanorama-success",{name:e.name})}).catch(function(t){console.log("couldn't show panorama: "+t.message),e.el.emit("showpanorama-failed",{name:e.name,error:t})})}else this.active=!1}})}]);