UNPKG

aframe-babia-components

Version:

A data visualization set of components for A-Frame.

2 lines 959 kB
/*! For license information please see aframe-babia-components.min.js.LICENSE.txt */ (()=>{var __webpack_modules__={9590(t){t.exports.NotiBuffer=class{constructor(t,e){this.currentId=0,this.notifiers={},this.data,this.function1=t,this.function2=e}set(t){console.log("produced",t),this.data=t;for(const t of Object.values(this.notifiers))t(this.data)}register(t,e){void 0!==this.data&&(console.log("Data was ready"),t(this.data));let i=this.currentId;return this.notifiers[i]=t,this.currentId++,e&&this.function1&&this.function1(e),i}unregister(t,e){delete this.notifiers[t],e&&this.function2&&this.function2(e)}}},4601(t,e,i){let n=i(1392).findProdComponent,r=i(1392).parseJson;if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");const a=i(9590).NotiBuffer;AFRAME.registerComponent("babia-filter",{schema:{from:{type:"string"},filter:{type:"string"},data:{type:"string"}},multiple:!1,init:function(){this.notiBuffer=new a},update:function(t){let e=this.data,i=this.el;if(!e.data||t.data===e.data&&e.filter===t.filter)e.from===t.from&&e.filter===t.filter||(this.prodComponent&&this.prodComponent.notiBuffer.unregister(this.notiBufferId),this.prodComponent=n(e,i,"babia-filter"),this.prodComponent.notiBuffer&&(this.notiBufferId=this.prodComponent.notiBuffer.register(this.processData.bind(this))));else{let t=r(e.data);this.processData(t)}},remove:function(){},pause:function(){},play:function(){},prodComponent:void 0,notiBufferId:void 0,processData:function(t){let e,i=this.data.filter.split("=");i[0]&&i[1]?(e=t.filter(t=>t[i[0]]==i[1]),this.notiBuffer.set(e)):console.error("Error on filter, please use key=value syntax")}})},8394(t,e,i){let n=i(1392).findProdComponent,r=i(1392).findNavComponent,a=i(1392).parseJson;class o{constructor(t,e,i,n,r,a){this.field=t,this.step=i||1,this.speed=n||1,this.current=-2==e?0:e,this.state=r||"play",this.direction=a||"forward"}updateData(t){this.data={};for(let e of t){let t=e[this.field];this.data[t]?this.data[t].push(e):this.data[t]=[e]}this.selectors=Object.keys(this.data).sort(),this.length=this.selectors.length}next(){let t=this.data[this.selectors[this.current]];return this.current+this.step<=this.length-1?this.current+=this.step:(this.current=this.length-1,this.current=this.length),t}prev(){let t=this.data[this.selectors[this.current]];return this.current-this.step>=0?this.current-=this.step:this.current=-1,t}setValue(t){let e=this.data[this.selectors[t]];return"rewind"!=this.direction?t>this.length?this.current=this.length:this.current=t<1?1:t+1:t>this.length-2?this.current=this.length-2:this.current=t<-1?-1:t-1,e}}if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");const s=i(9590).NotiBuffer;AFRAME.registerComponent("babia-selector",{schema:{from:{type:"string"},controller:{type:"string",default:""},select:{type:"string",default:"date"},timeout:{type:"number",default:6e3},data:{type:"string"},current_value:{type:"number",default:-2},speed:{type:"number",default:0},step:{type:"number",default:0},direction:{type:"string",default:""},state:{type:"string",default:""}},multiple:!1,interval:void 0,init:function(){this.notiBuffer=new s,this.navNotiBuffer=new s,this.selectable=new o(this.data.select,this.data.current_value,this.data.step,this.data.speed)},babiaMetadata:{id:0},update:function(t){let e=this.data,i=this.el;if(e.data&&t.data!==e.data){let t=a(e.data);this.processData(t)}else e.from!==t.from&&(this.prodComponent&&this.prodComponent.notiBuffer.unregister(this.notiBufferId),this.prodComponent=n(e,i,"babia-selector"),this.prodComponent.notiBuffer&&(this.notiBufferId=this.prodComponent.notiBuffer.register(this.processData.bind(this))));if(e.controller&&e.controller!=t.controller&&(this.selectorController=document.querySelector("#"+e.controller),this.navComponent&&(this.navComponent.notiBuffer.unregister(this.navNotiBufferId,this),i.components.networked&&this.removeOldNavListener(this.navComponent.el)),this.navComponent=r(e,i),this.navComponent.notiBuffer&&(this.navNotiBufferId=this.navComponent.notiBuffer.register(this.processEvent.bind(this),this)),i.components.networked&&this.addMultiuserMode(this.navComponent.el)),e.direction&&e.direction!=t.direction&&("rewind"!=e.direction?(this.selectable.current!=this.selectable.length&&(this.selectable.current+=2),this.navNotiBuffer&&this.navNotiBuffer.set("forward")):(this.selectable.current<1?this.selectable.current=0:this.selectable.current-=2,this.navNotiBuffer&&this.navNotiBuffer.set("rewind"))),e.step&&e.step!=this.selectable.step&&(this.selectable.step=e.step,this.navNotiBuffer.set({type:"step",value:e.step}),"rewind"!=this.data.direction?this.selectable.current+e.step>this.selectable.length?this.selectable.current=this.selectable.length:this.selectable.current+=e.step-1:this.selectable.current-e.step<=0?this.selectable.current=-1:this.selectable.current-=e.step+1),e.speed&&e.speed!=this.selectable.speed){this.selectable.speed=e.speed;let t=this.data.timeout/e.speed;this.navNotiBuffer.set({type:"speed",value:e.speed});let i=this;clearInterval(this.interval),this.interval=window.setInterval(function(){i.loop()},t)}i.components.networked&&i.components.networked.data.owner!=NAF.clientId&&"scene"!=i.components.networked.data.owner&&(-2!=e.current_value&&e.current_value!=t.current_value&&("rewind"!=e.direction?(this.navNotiBuffer.set({type:"position",value:e.current_value-1,label:this.selectable.selectors[e.current_value-1]}),this.setSelect(e.current_value-1)):(this.navNotiBuffer.set({type:"position",value:e.current_value+1,label:this.selectable.selectors[e.current_value+1]}),this.setSelect(e.current_value+1))),"pause"==e.state&&e.state!=t.state&&this.navNotiBuffer.set("pause"))},nextSelect:function(){this.selectable.current>this.selectable.length-1?(this.selectable.current=this.selectable.length,this.selectable.state="pause",this.el.setAttribute("babia-selector","state","pause"),this.navNotiBuffer.set("pause")):(this.newData=this.selectable.next(),this.el.setAttribute("babia-selector","current_value",this.selectable.current),this.notiBuffer.set(this.newData),this.navNotiBuffer.set({type:"position",value:this.selectable.current,label:this.selectable.selectors[this.selectable.current-1]}),this.babiaMetadata={id:this.selectable.current})},prevSelect:function(){this.selectable.current>=0?(this.newData=this.selectable.prev(),this.el.setAttribute("babia-selector","current_value",this.selectable.current),this.notiBuffer.set(this.newData),this.navNotiBuffer.set({type:"position",value:this.selectable.current,label:this.selectable.selectors[this.selectable.current+1]}),this.babiaMetadata={id:this.selectable.current}):(this.selectable.current=-1,this.selectable.state="pause",this.el.setAttribute("babia-selector","state","pause"),this.navNotiBuffer.set("pause"))},setSelect:function(t){if(t!=this.selectable.current-1&&"rewind"!=this.data.direction||t!=this.selectable.current+1&&"rewind"===this.data.direction){let e;this.newData=this.selectable.setValue(t),"rewind"!=this.data.direction?(this.babiaMetadata={id:t++},e=this.selectable.selectors[t-1]):(this.babiaMetadata={id:t--},this.selectable.current-=2,e=this.selectable.selectors[t+1]),this.notiBuffer.set(this.newData),this.navNotiBuffer.set({type:"position",value:t,label:e})}},loop:function(){"pause"!=this.data.state&&("rewind"!=this.data.direction?this.nextSelect():this.prevSelect())},prodComponent:void 0,navComponent:void 0,prodNotiBufferId:void 0,navNotiBufferId:void 0,newData:void 0,processData:function(t){this.selectable.updateData(t),this.navNotiBuffer.set({type:"position",value:this.selectable.current,label:this.selectable.selectors[this.selectable.current-1]});let e=this;this.nextSelect(),this.interval=window.setInterval(function(){e.loop()},e.data.timeout*e.selectable.speed)},processEvent:function(t){if(t.includes("pause"))this.selectable.state="pause",this.el.setAttribute("babia-selector","state","pause");else if(t.includes("play"))this.selectable.state="play",this.el.setAttribute("babia-selector","state","play");else if(t.includes("forward"))this.selectable.direction="forward",this.el.setAttribute("babia-selector","direction","forward");else if(t.includes("rewind"))this.selectable.direction="rewind",this.el.setAttribute("babia-selector","direction","rewind");else if(t.includes("babiaSetPosition")){this.selectable.state="pause";let e=parseInt(t.substring(16),10);"rewind"!=this.data.direction?this.el.setAttribute("babia-selector",{state:"pause",current_value:e+1}):this.el.setAttribute("babia-selector",{state:"pause",current_value:e-1}),this.setSelect(e),this.navNotiBuffer.set("pause")}else t.includes("babiaSetStep")?this.el.setAttribute("babia-selector","step",parseInt(t.substring(12),10)):t.includes("babiaSetSpeed")&&this.el.setAttribute("babia-selector","speed",parseInt(t.substring(13),10))},removeOldNavListener:function(t){t.removeEventListener("click",function(){NAF.utils.isMine(selector)||"scene"==selector.components.networked.data.owner||Object.keys(NAF.connection.connectedClients).length>0&&NAF.utils.takeOwnership(selector)})},addMultiuserMode:function(t){let e=this.el;function i(){t.children[1].setAttribute("visible",!1),t.children[2].setAttribute("visible",!1),t.children[3].setAttribute("visible",!1)}document.body.addEventListener("clientConnected",function(t){let n=t.detail.clientId;console.log("clientConnected event. clientId =",n),console.log("Selector owner: ",e.components.networked.data.owner);let r=!0;if("scene"==e.components.networked.data.owner){for(let t in NAF.connection.getConnectedClients()){let e=NAF.connection.getConnectedClients()[t].roomJoinTime,i=NAF.connection.adapter._myRoomJoinTime;console.log("Other: ",e),console.log("Mine: ",i),i>e&&(r=!1)}r?NAF.utils.takeOwnership(e):(console.log("I'm not first"),i())}else e.components.networked.data.owner!=NAF.clientId&&i()}),t.addEventListener("click",function(){NAF.utils.isMine(e)||"scene"==e.components.networked.data.owner||Object.keys(NAF.connection.connectedClients).length>0&&NAF.utils.takeOwnership(e)}),e.addEventListener("ownership-gained",e=>{console.log("Selector ownership gained"),t.children[1].setAttribute("visible",!0),t.children[2].setAttribute("visible",!0),t.children[3].setAttribute("visible",!0)}),e.addEventListener("ownership-lost",t=>{console.log("Selector ownership lost"),i()})}})},2240(e,i,n){let r=n(1392).findProdComponent,a=n(1392).parseJson;const o=n(9590).NotiBuffer;if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");function s(e,i,n){for(t=0;t<e.length&&e[t][i]!==n;)t++;return t<e.length&&e[t]}AFRAME.registerComponent("babia-treebuilder",{schema:{from:{type:"string"},field:{type:"string"},split_by:{type:"string",default:"/"},build_root:{type:"boolean",default:!1},root_name:{type:"string",default:"Main"},data:{type:"string"}},multiple:!1,prodComponent:void 0,notiBufferId:void 0,init:function(){this.notiBuffer=new o},update:function(t){let e=this.data,i=this.el;if(!e.data||t.data===e.data&&e.field===t.field&&e.split_by===t.split_by)e.from===t.from&&e.field===t.field&&e.split_by===t.split_by||(this.prodComponent&&this.prodComponent.notiBuffer.unregister(this.notiBufferId),this.prodComponent=r(e,i,"babia-treebuilder"),this.prodComponent.notiBuffer&&(this.notiBufferId=this.prodComponent.notiBuffer.register(this.processData.bind(this))));else{let t=a(e.data);this.processData(t)}},processData:function(t){let e=this.data,i=[],n=i;e.build_root&&(i=[{name:e.root_name,id:"",children:[]}],n=i[0].children);for(let i=0;i<t.length;i++){let r=t[i][e.field].split(e.split_by),a=n,o="";for(let n=0;n<r.length;n++){if(!r[n])continue;let l=r[n],c=s(a,"name",l);if(c)a=c.children,o=c.uid;else{let s={};n===r.length-1?s=t[i]:s.children=[],s.uid=o?o+e.split_by+l:l,s.name=l,a.push(s),a=s.children,o=s.uid}}}this.notiBuffer.set(i)}})},3285(t,e,i){i(1392).colors,AFRAME.registerComponent("babia-bar",{schema:{height:{type:"number"},width:{type:"number"},depth:{type:"number"},color:{type:"color",default:"#000"},animation:{type:"boolean",default:!0},dur:{type:"number",default:2e3},label:{type:"string",default:""},labelText:{type:"string",default:""},labelLookat:{type:"string",default:"[camera]"},labelScale:{type:"number",default:1}},init:function(){console.log("Starting bar:",this.data.height,this.data.color);let t=this.data;this.box=document.createElement("a-entity"),this.box.classList.add("babiaxraycasterclass"),this.el.appendChild(this.box);let e={};e=t.animation?{height:0,width:t.width,depth:t.depth}:{height:t.height,width:t.width,depth:t.depth},this.box.setAttribute("geometry",{primitive:"box",height:e.height,width:e.width,depth:e.depth}),this.box.setAttribute("material",{color:t.color})},update:function(t){let e=this.data,i=this.box;this.updateProperty(i,"geometry","height",e.animation,e.height,t.height),e.height!=t.height&&(e.animation?(i.setAttribute("animation__pos",{property:"position",to:{x:0,y:e.height/2,z:0},dur:e.dur}),e.height<=0&&t.height>0?i.setAttribute("animation__opacity",{property:"material.opacity",to:0,dur:e.dur}):t.height<=0&&e.height>0&&i.setAttribute("animation__opacity",{property:"material.opacity",to:100,dur:e.dur})):(i.setAttribute("position",{x:0,y:e.height/2,z:0}),e.height<=0&&t.height>0?i.setAttribute("material","opacity",0):t.height<=0&&e.height>0&&i.setAttribute("material","opacity",100))),this.updateProperty(i,"geometry","width",e.animation,e.width,t.width),this.updateProperty(i,"geometry","depth",e.animation,e.depth,t.depth),this.updateProperty(i,"material","color",e.animation,e.color,t.color),"events"===this.data.label?(i.addEventListener("mouseenter",this.showLabel.bind(this)),i.addEventListener("mouseleave",this.hideLabel.bind(this))):"fixed"===this.data.label&&this.showLabel(t)},updateProperty:function(t,e,i,n,r,a){let o=this.data;if(r!==a)if(n){let n=e;i&&(n=n+"."+i),t.setAttribute("animation__"+e+"_"+i,{property:n,to:r,dur:o.dur})}else i?t.setAttribute(e,{[i]:r}):t.setAttribute(e,r)},showLabel:function(t){let e=this.data;"events"===e.label&&this.el.setAttribute("scale",{x:1.1,y:1.1,z:1.1}),text=e.labelText;let i=2;text.length>16&&(i=text.length/8),oldHeight=t.height||0,oldDepth=t.depth||0;let n={x:0,y:oldHeight+.6,z:0};this.labelEl||(this.labelEl=document.createElement("a-entity"),this.labelEl.setAttribute("babia-label",{width:i,textWidth:6}),e.animation&&"fixed"===e.label&&this.labelEl.setAttribute("position",n),this.el.appendChild(this.labelEl));let r={x:0,y:e.height+.6,z:.7*e.depth},a=e.animation&&"fixed"===e.label;this.updateProperty(this.labelEl,"position","",a,r,n),this.labelEl.setAttribute("rotation",{x:0,y:0,z:0}),text!=t.labelText&&this.labelEl.setAttribute("babia-label",{text:e.labelText}),e.labelLookat&&t.labelLookat!==e.labelLookat&&this.labelEl.setAttribute("babia-lookat",e.labelLookat),e.labelScale&&t.labelScale!==e.labelScale&&this.labelEl.setAttribute("scale",{x:e.labelScale,y:e.labelScale,z:e.labelScale})},hideLabel:function(){"events"===this.data.label&&this.el.setAttribute("scale",{x:1,y:1,z:1}),this.labelEl&&(this.el.removeChild(this.labelEl),this.labelEl=null)}})},4324(t,e,i){i(1392).colors,AFRAME.registerComponent("babia-cyl",{schema:{height:{type:"number"},radius:{type:"number"},color:{type:"color",default:"#000"},animation:{type:"boolean",default:!0},dur:{type:"number",default:2e3},label:{type:"string",default:""},labelText:{type:"string",default:""},labelLookat:{type:"string",default:"[camera]"}},init:function(){console.log("Starting cyl:",this.data.height,this.data.color);let t=this.data;this.cylinder=document.createElement("a-entity"),this.cylinder.classList.add("babiaxraycasterclass"),this.el.appendChild(this.cylinder);let e={};e=t.animation?{height:0,radius:t.radius}:{height:t.height,radius:t.radius},this.cylinder.setAttribute("geometry",{primitive:"cylinder",height:e.height,radius:e.radius}),this.cylinder.setAttribute("material",{color:t.color})},update:function(t){let e=this.data,i=this.cylinder;this.updateProperty(i,"geometry","height",e.animation,e.height,t.height),e.height!=t.height&&(e.animation?(i.setAttribute("animation__pos",{property:"position",to:{x:0,y:e.height/2,z:0},dur:e.dur}),e.height<=0&&t.height>0?i.setAttribute("animation__opacity",{property:"material.opacity",to:0,dur:e.dur}):t.height<=0&&e.height>0&&i.setAttribute("animation__opacity",{property:"material.opacity",to:100,dur:e.dur})):(i.setAttribute("position",{x:0,y:e.height/2,z:0}),e.height<=0&&t.height>0?i.setAttribute("material","opacity",0):t.height<=0&&e.height>0&&i.setAttribute("material","opacity",100))),this.updateProperty(i,"geometry","radius",e.animation,e.radius,t.radius),this.updateProperty(i,"material","color",e.animation,e.color,t.color),"events"===this.data.label?(i.addEventListener("mouseenter",this.showLabel.bind(this)),i.addEventListener("mouseleave",this.hideLabel.bind(this))):"fixed"===this.data.label&&this.showLabel(t)},updateProperty:function(t,e,i,n,r,a){let o=this.data;if(r!==a)if(n){let n=e;i&&(n=n+"."+i),t.setAttribute("animation__"+e+"_"+i,{property:n,to:r,dur:o.dur})}else i?t.setAttribute(e,{[i]:r}):t.setAttribute(e,r)},showLabel:function(t){let e=this.data;"events"===e.label&&this.el.setAttribute("scale",{x:1.1,y:1.1,z:1.1}),text=e.labelText;let i=2;text.length>16&&(i=text.length/8),oldHeight=t.height||0;let n={x:0,y:oldHeight+.6,z:0};this.labelEl||(this.labelEl=document.createElement("a-entity"),this.labelEl.setAttribute("babia-label",{width:i,textWidth:6}),e.animation&&"fixed"===e.label&&this.labelEl.setAttribute("position",n),this.el.appendChild(this.labelEl));let r={x:0,y:e.height+.7,z:.7*e.radius},a=e.animation&&"fixed"===e.label;this.updateProperty(this.labelEl,"position","",a,r,n),this.labelEl.setAttribute("rotation",{x:0,y:0,z:0}),text!=t.labelText&&this.labelEl.setAttribute("babia-label",{text:e.labelText}),e.labelLookat&&t.labelLookat!==e.labelLookat&&this.labelEl.setAttribute("babia-lookat",e.labelLookat),e.labelScale&&t.labelScale!==e.labelScale&&this.labelEl.setAttribute("scale",{x:e.labelScale,y:e.labelScale,z:e.labelScale})},hideLabel:function(){"events"===this.data.label&&this.el.setAttribute("scale",{x:1,y:1,z:1}),this.labelEl&&(this.el.removeChild(this.labelEl),this.labelEl=null)}})},4330(t,e,i){const n=i(1392).colors;if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");class r{constructor(t,e,i,n){this.el=t,this.axis=e,this.anim=i,this.dur=n}updateLine(t,e){const i=this.axis,n=this.el,r=this.anim,a=this.dur,o=`line__${i}axis`;let s=n.components[o],l={x:0,y:0,z:0};l[i]=t,r&&s?(n.setAttribute(`animation__${i}axis`,{property:`${o}.end`,to:l,dur:a}),n.setAttribute(o,{color:e})):n.setAttribute(o,{start:{x:0,y:0,z:0},end:l,color:e})}removeLabels(){const t=this.el,e=this.anim,i=this.dur;let n=t.querySelectorAll("[text]");for(const t of n)e?(t.addEventListener("animationcomplete",function(t){t.target.remove()}),t.setAttribute("animation",{property:"text.opacity",to:0,dur:i})):t.remove()}updateLabels(t,e,i,r,a){const o=this.axis;let s=this.el;const l=this.anim,c=this.dur;for(let h=0;h<t.length;++h){let u,d=document.createElement("a-entity"),p=i;r&&(p=n.get(h,r)),d.setAttribute("text",{value:e[h],align:"right",width:10,color:p,opacity:0}),"behind"!=a&&"right"!=a||d.setAttribute("text",{align:"left"}),"x"===o?u="behind"==a?{x:t[h],y:0,z:-5.15}:{x:t[h],y:0,z:5.25}:"y"===o?u="right"==a?{x:5.2,y:t[h],z:0}:{x:-5.2,y:t[h],z:0}:"z"===o&&(u="right"==a?{x:5.2,y:0,z:t[h]}:{x:-5.2,y:0,z:t[h]}),d.setAttribute("position",u),"x"===o?d.setAttribute("rotation",{x:-90,y:90,z:0}):"z"===o&&d.setAttribute("rotation",{x:-90,y:0,z:0}),l?d.setAttribute("animation",{property:"text.opacity",to:1,dur:c}):d.setAttribute("text",{opacity:1}),s.appendChild(d)}}updateName(t,e,i){const n=this.axis;let r=this.el;const a=this.anim,o=this.dur;let s,l=document.createElement("a-entity");l.setAttribute("text",{value:t,align:"right",width:10,color:"#000",opacity:0}),"behind"!=e&&"right"!=e||l.setAttribute("text",{align:"left"}),"x"===n?s="behind"==e?{x:i+.5,y:0,z:-5.15}:{x:i+.5,y:0,z:5.25}:"y"===n?s="right"==e?{x:5.2,y:i+.5,z:0}:{x:-5.2,y:i+.5,z:0}:"z"===n&&(s="right"==e?{x:5.2,y:0,z:i+.5}:{x:-5.2,y:0,z:i+.5}),l.setAttribute("position",s),"x"===n?l.setAttribute("rotation",{x:-90,y:90,z:0}):"z"===n&&l.setAttribute("rotation",{x:-90,y:0,z:0}),a?l.setAttribute("animation",{property:"text.opacity",to:1,dur:o}):l.setAttribute("text",{opacity:1}),r.appendChild(l)}}AFRAME.registerComponent("babia-axis-y",{schema:{maxValue:{type:"number"},length:{type:"number"},minSteps:{type:"number",default:6},color:{type:"color",default:"#000"},animation:{type:"boolean",default:!0},dur:{type:"number",default:2e3},align:{type:"string",default:"left"},name:{type:"string",default:""}},init:function(){this.axis=new r(this.el,"y",this.data.animation,this.data.dur)},update:function(t){const e=this.data;let i=this.data.maxValue,n=this.data.length,r=this.data.minSteps;this.data.animation,this.data.dur;let a=0;if(console.log("Starting babia-axis-y:",i,n,this.data.color),i!=t.maxValue||n!=t.maxValue||r!=t.minSteps){let t=Math.floor(Math.log10(i));t<=0&&(a=1-t);let o=n/i,s=Math.pow(10,t),l=i/s;for(;l<=r;)s/=2,l=i/s;this.axis.updateLine(n,e.color),this.axis.removeLabels();let c=[],h=[];for(let t=1;s*t<i;t++)vtick=s*t,c.push(vtick*o),h.push(vtick.toFixed(a));this.axis.updateLabels(c,h,e.color,e.palette,e.align)}e.name&&this.axis.updateName(e.name,e.align,e.length)}}),AFRAME.registerComponent("babia-axis-x",{schema:{labels:{type:"array"},ticks:{type:"array"},length:{type:"number"},color:{type:"color",default:"#000"},palette:{type:"string",default:""},animation:{type:"boolean",default:!0},dur:{type:"number",default:2e3},align:{type:"string",default:"front"},name:{type:"string",default:""}},init:function(){this.axis=new r(this.el,"x",this.data.animation,this.data.dur)},update:function(t){const e=this.data;console.log("Starting babia-axis-x:",e.ticks.length,e.length,this.data.color),this.axis.updateLine(e.length,e.color),this.axis.removeLabels(),this.axis.updateLabels(e.ticks,e.labels,e.color,e.palette,e.align),e.name&&this.axis.updateName(e.name,e.align,e.length)}}),AFRAME.registerComponent("babia-axis-z",{schema:{labels:{type:"array"},ticks:{type:"array"},length:{type:"number"},color:{type:"color",default:"#000"},palette:{type:"string",default:""},animation:{type:"boolean",default:!0},dur:{type:"number",default:2e3},align:{type:"string",default:"left"},name:{type:"string",default:""}},init:function(){this.axis=new r(this.el,"z",this.data.animation,this.data.dur)},update:function(t){const e=this.data;console.log("Starting babia-axis-z:",e.ticks.length,e.length,this.data.color),this.axis.updateLine(e.length,e.color),this.axis.removeLabels(),this.axis.updateLabels(e.ticks,e.labels,e.color,e.palette,e.align),e.name&&this.axis.updateName(e.name,e.align,e.length)}})},5852(){if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");AFRAME.registerComponent("babia-camera",{schema:{raycasterMouse:{type:"string",default:".babiaxraycasterclass"},raycasterHand:{type:"string",default:".babiaxraycasterclass"},tipsOpened:{type:"boolean",default:!0},gripRLabel:{type:"string",default:"Open/Close \nTips"},gripLLabel:{type:"string",default:"Stop Audio"},triggerRLabel:{type:"string",default:"Click"},triggerLLabel:{type:"string",default:"Teleport"},teleportCollisions:{type:"string",default:".environmentGround"}},multiple:!1,init:function(){},update:function(t){this.data!=this.oldData&&((this.cursor||this.leftHand||this.rightHand)&&(this.el.parentElement.removeChild(this.cursor),this.el.parentElement.removeChild(this.leftHand),this.el.parentElement.removeChild(this.rightHand),this.cursor=void 0,this.leftHand=void 0,this.rightHand=void 0),this.addCursor(),this.setOculusConnected())},addCursor:function(){this.cursor=document.createElement("a-entity"),this.cursor.id="cursor",this.cursor.setAttribute("cursor",{rayOrigin:"mouse"}),this.cursor.setAttribute("raycaster",{objects:this.data.raycasterMouse}),this.el.parentElement.append(this.cursor)},createTip:function(t,e,i){let n=document.createElement("a-entity");return n.id=t,n.classList.add("tips"),n.setAttribute("tooltip",e),n.setAttribute("position",i),n},setOculusConnected:function(){let t=this;t.tooltips=[],t.leftHand=document.createElement("a-entity"),t.leftHand.id="babia-leftHand",t.leftHand.setAttribute("oculus-touch-controls",{hand:"left"}),t.el.parentElement.append(t.leftHand),t.rightHand=document.createElement("a-entity"),t.rightHand.id="babia-rightHand",t.rightHand.setAttribute("oculus-touch-controls",{hand:"right"}),t.el.parentElement.append(t.rightHand),document.addEventListener("controllerconnected",e=>{let i=t.el.parentElement.object3D.position;t.el.parentElement.setAttribute("position",{x:i.x,y:0,z:i.z}),"babia-leftHand"===e.target.id&&(t.leftHand.setAttribute("teleport-controls",{cameraRig:`#${t.el.parentElement.id}`,teleportOrigin:`#${t.el.id}`,collisionEntities:t.data.teleportCollisions,hitCylinderColor:"#ff3468",curveHitColor:"#ff3468",curveMissColor:"#333333",curveLineWidth:.01,button:"trigger"}),tipTriggerLconfig={text:t.data.triggerLLabel,width:.07,height:.03,targetPosition:"0.002 -0.02 -0.014",lineHorizontalAlign:"right",rotation:"-90 0 0",src:tooltip.default},tipTriggerLpos={x:-.09,y:-.04,z:-.08},t.tipTriggerL=this.createTip("babia-tooltip_trigger_L",tipTriggerLconfig,tipTriggerLpos),t.leftHand.append(t.tipTriggerL),t.tooltips.push(t.tipTriggerL),tipGripLconfig={text:t.data.gripLLabel,width:.08,height:.04,targetPosition:"0.006 -0.008 0.033",rotation:"-90 0 0",src:tooltip.default},tipGripLpos={x:.085,y:-.01,z:.07},t.tipGripL=this.createTip("babia-tooltip_grip_L",tipGripLconfig,tipGripLpos),t.leftHand.append(t.tipGripL),t.tooltips.push(t.tipGripL)),"babia-rightHand"===e.target.id&&(t.rightHand.setAttribute("laser-controls",{hand:"right"}),t.rightHand.setAttribute("raycaster",{objects:this.data.raycasterHand,lineOpacity:1}),tipTriggerRconfig={text:t.data.triggerRLabel,width:.07,height:.03,targetPosition:"0.005 -0.02 -0.014",lineHorizontalAlign:"left",rotation:"-90 0 0",src:tooltip.default},tipTriggerRpos={x:-.09,y:-.04,z:-.08},t.tipTriggerR=this.createTip("babia-tooltip_trigger_R",tipTriggerRconfig,tipTriggerRpos),t.rightHand.append(t.tipTriggerR),t.tooltips.push(t.tipTriggerR),tipGripRconfig={text:t.data.gripRLabel,width:.08,height:.04,targetPosition:"0.006 -0.008 0.033",lineHorizontalAlign:"right",rotation:"-90 0 0",src:tooltip.default},tipGripRpos={x:-.085,y:-.01,z:.07},t.tipGripR=this.createTip("babia-tooltip_grip_R",tipGripRconfig,tipGripRpos),t.rightHand.append(t.tipGripR),t.tooltips.push(t.tipGripR)),this.tipsController(),this.data.networkedAudio&&this.setAudioController()})},tipsController:function(){let t=this;this.tipsOpened=t.data.tipsOpened,t.tipsOpened||t.tooltips.forEach(t=>{t.setAttribute("visible",!1)}),t.rightHand.addEventListener("gripdown",()=>{t.tipsOpened?(t.tipsOpened=!1,t.tooltips.forEach(t=>{t.setAttribute("visible",!1)})):(t.tipsOpened=!0,t.tooltips.forEach(t=>{t.setAttribute("visible",!0)}))})}})},3773(){if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");function t(t,i){t.getObject3D("mesh")?e(t,i):t.addEventListener("model-loaded",function(){t.color=i,e(t,i)})}function e(t,e){t.object3D.traverse(function(t){last_material=t.material,last_material&&(t.material=new THREE.MeshBasicMaterial({color:e}))})}AFRAME.registerComponent("babia-controls",{schema:{direction:{type:"string",default:""},state:{type:"string",default:""}},multiple:!1,init:function(){this.createPlayer()},update:function(e){let i=this.data;if(i.state&&i.state!=e.state){let t=document.getElementsByClassName("babiaPause")[0],e=document.getElementsByClassName("babiaPlay")[0];"pause"===i.state?(t&&this.el.children[0].removeChild(t),e||this.createButton("play","white")):(e&&this.el.children[0].removeChild(e),t||this.createButton("pause","white")),this.el.parentEl.setAttribute("babia-navigator","state",i.state)}if(i.direction&&i.direction!=e.direction){let e=document.getElementsByClassName("babiaRewind")[0],n=document.getElementsByClassName("babiaForward")[0];"rewind"===i.direction?(n.color="white",e.color="grey",t(n,"white"),t(e,"grey")):(n.color="grey",e.color="white",t(n,"grey"),t(e,"white")),this.el.parentEl.setAttribute("babia-navigator","direction",i.direction)}},player:void 0,createPlayer:function(){this.player=document.createElement("a-entity"),this.player.classList.add("babiaxrPlayer"),this.player.classList.add("babiaxraycasterclass"),this.el.appendChild(this.player),this.createButton("rewind","white"),this.createButton("skipPrev","white"),this.createButton("pause","white"),this.createButton("skipNext","white"),this.createButton("forward","grey")},createButton:function(e,i){let n,r,a,o=!1;if("play"===e)n=playButton.default,r=.2,a="babiaPlay";else if("pause"===e)n=pauseButton.default,r=0,a="babiaPause";else if("skipNext"===e)n=skipButton.default,r=3,a="babiaSkipNext",o=!0;else if("skipPrev"===e)n=skipButton.default,r=-3,a="babiaSkipPrev";else if("rewind"===e)n=rewindButton.default,r=-6,a="babiaRewind";else{if("forward"!==e)throw new Error("That button type doesn't exist.");n=rewindButton.default,r=6,a="babiaForward",o=!0}let s=document.createElement("a-entity");s.setAttribute("gltf-model","url("+n+")"),s.classList.add("babiaxraycasterclass"),s.classList.add(a),s.setAttribute("position",{x:r,y:0,z:0}),t(s,i),o&&s.setAttribute("rotation",{x:0,y:180,z:0}),this.player.appendChild(s),this.mouseOver(s),this.processEvents(s)},mouseOver:function(e){e.addEventListener("mouseenter",function(){t(e,"grey")}),e.addEventListener("mouseleave",function(){t(e,e.color)})},processEvents:function(t){let e=this;t.addEventListener("click",function(){if(t.classList.contains("babiaPlay"))this.parentEl.parentEl.setAttribute("babia-controls","state","play");else if(t.classList.contains("babiaPause"))this.parentEl.parentEl.setAttribute("babia-controls","state","pause");else if(t.classList.contains("babiaSkipNext")||t.classList.contains("babiaSkipPrev")){"pause"!=e.data.state&&this.parentEl.parentEl.setAttribute("babia-controls","state","pause");let i="skipPrev";t.classList.contains("babiaSkipNext")&&(i="skipNext"),e.el.parentEl.components["babia-navigator"].controlNavigator(i)}else t.classList.contains("babiaForward")?this.parentEl.parentEl.setAttribute("babia-controls","direction","forward"):t.classList.contains("babiaRewind")&&this.parentEl.parentEl.setAttribute("babia-controls","direction","rewind")})}})},80(){if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");function t(t){let e=t.el.sceneEl.camera.el;t.recordedData[Date.now()]={position:e.getAttribute("position"),rotation:e.getAttribute("rotation")}}function e(t,e){let i="data:text/json;charset=utf-8,"+encodeURIComponent(JSON.stringify(t)),n=document.createElement("a");n.setAttribute("href",i),n.setAttribute("download",e+".json"),document.body.appendChild(n),n.click(),n.remove()}AFRAME.registerComponent("babia-experiment",{schema:{taskTitle:{type:"string",default:"Default task title"},taskDescription:{type:"string",default:"Default task text"},openTaskImg:{type:"string"},closeTaskImg:{type:"string"},timeLimitEnding:{type:"boolean",default:!1},timeLimitTime:{type:"number",default:300},forceFinishWhenTimeLimit:{type:"boolean",default:!1},finishButton:{type:"boolean",default:!0},recordDelta:{type:"number",default:3e3},recordAudio:{type:"boolean",default:!0},taskAudio:{type:"boolean",default:!1},taskAudioUrl:{type:"string",default:null},taskVideo:{type:"boolean",default:!1},taskVideoId:{type:"string",default:null},taskVideoWidth:{type:"number",default:3},taskVideoHeight:{type:"number",default:1.75},lookat:{type:"string",default:"[camera]"}},multiple:!0,recordedData:{},runningExperiment:!1,init:function(){},update:function(t){if(this.data!=this.oldData){let t=this.el.querySelectorAll("[babia-camera]");if(t.length>0){this.babiaCameraEl=t[0];let e=this.babiaCameraEl.getAttribute("babia-camera");this.babiaCameraEl.setAttribute("babia-camera",{raycasterMouse:e.raycasterMouse+", #babiaTaskPopup, #babiaTaskPopup--close-icon, #babiaStartButton, #babiaFinishButton, #babiaTaskAudio, #babiaTaskVideo",raycasterHand:e.raycasterHand+", #babiaTaskPopup, #babiaTaskPopup--close-icon, #babiaStartButton, #babiaFinishButton, #babiaTaskAudio, #babiaTaskVideo"})}else this.babiaCameraEl=this.el.sceneEl.camera.el;this.findBabiaCharts(),this.hideCharts(),0==this.el.querySelectorAll("[babia-task]").length&&(this.data.taskAudio?this.addAudioTask():this.data.taskVideo?this.addVideoTask():this.addTask()),this.addStartButton(),this.data.finishButton&&this.addFinishButton()}},findBabiaCharts:function(){this.babiaCharts=this.el.querySelectorAll("[babia-pie], [babia-bars], [babia-barsmap], [babia-bubbles], [babia-city], [babia-cyls], [babia-cylsmap], [babia-doughnut], [babia-terrain], [babia-boats], [babia-network], [babiaxr-codecity]")},hideCharts:function(){for(let t of this.babiaCharts)t.setAttribute("visible",!1)},showCharts:function(){for(let t of this.babiaCharts)t.setAttribute("visible",!0)},addTask:function(){this.taskEntity=document.createElement("a-entity"),this.taskEntity.setAttribute("class","babiaxrayscasterclass"),this.taskEntity.setAttribute("id","babiaTaskPopup"),this.taskEntity.setAttribute("babia-poster",{openIconImage:"../assets/popups/info.jpg",closeIconImage:"../assets/popups/close.jpg",title:this.data.taskTitle,titleWrapCount:30,titleColor:"black",bodyColor:"black",posterBoxColor:"white",bodyFont:"roboto",posterBoxHeight:4.5,body:this.data.taskDescription}),this.taskEntity.setAttribute("scale",{x:.5,y:.5,z:.5}),this.babiaCameraPosition=this.babiaCameraEl.getAttribute("position"),this.taskEntity.setAttribute("position",{x:this.babiaCameraPosition.x,y:this.babiaCameraPosition.y+1.5,z:this.babiaCameraPosition.z-4}),this.taskEntity.setAttribute("babia-lookat",this.data.lookat),this.el.parentElement.append(this.taskEntity)},audioPlaying:!1,addAudioTask:function(){const t=this;this.taskAudioEntity=document.createElement("a-entity"),this.taskAudioEntity.setAttribute("class","babiaxrayscasterclass"),this.taskAudioEntity.setAttribute("geometry",{primitive:"plane",width:1.1,height:.5}),this.taskAudioEntity.setAttribute("text",{value:"Play audio!",color:"white",align:"center",wrapCount:30,width:3.6}),this.taskAudioEntity.setAttribute("id","babiaTaskAudio"),this.taskAudioEntity.setAttribute("sound",{src:`url(${t.data.taskAudioUrl})`}),this.taskAudioEntity.addEventListener("click",function(e){t.audioPlaying?(t.audioPlaying=!1,t.taskAudioEntity.components.sound.stopSound(),t.taskAudioEntity.setAttribute("text","value","Play audio!")):(t.audioPlaying=!0,t.taskAudioEntity.components.sound.playSound(),t.taskAudioEntity.setAttribute("text","value","Stop audio!"))},!1),this.taskAudioEntity.addEventListener("sound-ended",function(e){t.audioPlaying=!1,t.taskAudioEntity.setAttribute("text","value","Play audio!")},!1),this.babiaCameraPosition=this.babiaCameraEl.getAttribute("position"),this.taskAudioEntity.setAttribute("position",{x:this.babiaCameraPosition.x,y:this.babiaCameraPosition.y+1.5,z:this.babiaCameraPosition.z-4}),this.taskAudioEntity.setAttribute("babia-lookat",this.data.lookat),this.el.parentElement.append(this.taskAudioEntity)},videoPlaying:!1,addVideoTask:function(){const t=this;this.taskVideoEntity=document.createElement("a-video"),this.taskVideoEntity.setAttribute("class","babiaxrayscasterclass"),this.taskVideoEntity.setAttribute("id","babiaTaskVideo"),this.taskVideoEntity.setAttribute("src",t.data.taskVideoId),this.taskVideoStream=document.querySelector(t.data.taskVideoId),this.taskVideoEntity.setAttribute("width",t.data.taskVideoWidth),this.taskVideoEntity.setAttribute("height",t.data.taskVideoHeight),this.taskVideoEntity.addEventListener("click",function(e){t.videoPlaying?(t.videoPlaying=!1,t.taskVideoStream.pause()):(t.videoPlaying=!0,t.taskVideoStream.play())},!1),this.babiaCameraPosition=this.babiaCameraEl.getAttribute("position"),this.taskVideoEntity.setAttribute("position",{x:this.babiaCameraPosition.x,y:this.babiaCameraPosition.y+1.5,z:this.babiaCameraPosition.z-4}),this.taskVideoEntity.setAttribute("babia-lookat",this.data.lookat),this.el.parentElement.append(this.taskVideoEntity)},addStartButton:function(){const e=this;this.startButtonEntity=document.createElement("a-plane"),this.startButtonEntity.setAttribute("id","babiaStartButton"),this.startButtonEntity.setAttribute("scale",{x:.4,y:.4,z:.4}),this.startButtonEntity.setAttribute("babia-lookat",this.data.lookat),this.startButtonEntity.setAttribute("class",".babiaxrayscasterclass"),this.startButtonEntity.setAttribute("color","#3ac961"),this.startButtonEntity.setAttribute("geometry",{primitive:"plane",width:1.8,height:.5}),this.startButtonEntity.setAttribute("text",{value:"Start!",color:"white",align:"center",wrapCount:30,width:3.6}),this.babiaCameraPosition=this.babiaCameraEl.getAttribute("position"),this.startButtonEntity.setAttribute("position",{x:this.babiaCameraPosition.x-.5,y:this.babiaCameraPosition.y+1,z:this.babiaCameraPosition.z-1.5}),this.startButtonEntity.addEventListener("click",async function(n){e.showCharts(),e.runningExperiment=!0,e.recordingData=window.setInterval(function(){t(e)},e.data.recordDelta),e.recordedData.startTime=Date.now(),e.data.recordAudio&&(e.audioRecorder=await i(),e.audioRecorder.start()),e.startButtonEntity.setAttribute("visible",!1),e.data.finishButton&&e.finishButtonEntity.setAttribute("visible",!0),e.data.timeLimitEnding&&(e.recordedData.maxTime=e.recordedData.startTime+1e3*e.data.timeLimitTime)},!1),this.el.parentElement.append(this.startButtonEntity)},addFinishButton:function(){const i=this;this.finishButtonEntity=document.createElement("a-plane"),this.finishButtonEntity.setAttribute("id","babiaFinishButton"),this.finishButtonEntity.setAttribute("scale",{x:.4,y:.4,z:.4}),this.finishButtonEntity.setAttribute("babia-lookat",this.data.lookat),this.finishButtonEntity.setAttribute("class","babiaxrayscasterclass"),this.finishButtonEntity.setAttribute("color","#9e0000"),this.finishButtonEntity.setAttribute("visible",!1),this.finishButtonEntity.setAttribute("geometry",{primitive:"plane",width:1.8,height:.5}),this.finishButtonEntity.setAttribute("text",{value:"Finish!",color:"white",align:"center",wrapCount:30,width:3.6}),this.finishButtonEntity.setAttribute("position",{x:this.babiaCameraPosition.x+.5,y:this.babiaCameraPosition.y+1,z:this.babiaCameraPosition.z-1.5}),this.finishButtonEntity.addEventListener("click",function(n){i.hideCharts(),i.runningExperiment=!1,t(i),clearInterval(this.recordingData),i.audioRecorder&&i.stopAndDownloadAudio(),i.recordedData.finishTime=Date.now(),i.recordedData.totalDuration=i.recordedData.finishTime-i.recordedData.startTime,e(i.recordedData,"experimentdetails"),i.finishButtonEntity.setAttribute("visible",!1)},!1),this.el.parentElement.append(this.finishButtonEntity)},stopAndDownloadAudio:async function(){let t=await this.audioRecorder.stop();const e=document.createElement("a");document.body.appendChild(e),e.style="display: none",e.href=t.audioUrl,e.download="audio.webm",e.click(),window.URL.revokeObjectURL(t.audioUrl)},tick:function(){const i=this;this.runningExperiment&&this.data.timeLimitEnding&&Date.now()>this.recordedData.maxTime&&(this.recordedData.finishTime=this.recordedData.maxTime,this.recordedData.totalDuration=this.recordedData.finishTime-this.recordedData.startTime,this.runningExperiment=!1,this.data.forceFinishWhenTimeLimit?(alert("The time limit is done! Thank you!"),this.hideCharts(),e(i.recordedData,"experimentdetails"),i.finishButtonEntity.setAttribute("visible",!1),t(i),clearInterval(this.recordingData),i.audioRecorder&&i.stopAndDownloadAudio()):alert("The time limit is done, but you can continue doing the experiment, please, click on Finish when done!"))}});const i=()=>new Promise(t=>{navigator.mediaDevices.getUserMedia({audio:!0}).then(e=>{const i=new MediaRecorder(e),n=[];i.addEventListener("dataavailable",t=>{n.push(t.data)}),t({start:()=>{i.start()},stop:()=>new Promise(t=>{i.addEventListener("stop",()=>{const e=new Blob(n),i=URL.createObjectURL(e),r=new Audio(i);t({audioBlob:e,audioUrl:i,play:()=>{r.play()}})}),i.stop()})})})})},3337(){if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");AFRAME.registerComponent("babia-label",{schema:{text:{type:"string"},height:{type:"number",default:1},width:{type:"number",default:3},textWidth:{type:"number",default:6},color:{type:"color",default:"white"},font:{type:"string",default:"default"},background:{type:"color",default:"black"},align:{type:"string",default:"center"}},update:function(t){console.log("Starting label..."),this.el.setAttribute("geometry",{primitive:"plane",height:this.data.height,width:this.data.width}),this.el.setAttribute("material",{color:this.data.color}),this.el.setAttribute("text",{value:this.data.text,align:this.data.align,width:this.data.textWidth,color:this.data.background}),this.el.classList.add("babiaxrLegend")}})},577(){var t,e=AFRAME.utils.debug,i=AFRAME.utils.coordinates,n=e("components:babia-lookat:warn"),r=i.isCoordinates||i.isCoordinate;delete AFRAME.components["babia-lookat"],AFRAME.registerComponent("babia-lookat",{schema:{default:"0 0 0",parse:function(t){return r(t)||"object"==typeof t?i.parse(t):t},stringify:function(t){return"object"==typeof t?i.stringify(t):t}},init:function(){this.target3D=null,this.vector=new THREE.Vector3,this.cameraListener=AFRAME.utils.bind(this.cameraListener,this),this.el.addEventListener("componentinitialized",this.cameraListener),this.el.addEventListener("componentremoved",this.cameraListener)},update:function(){var t,e=this,i=e.data;return!i||"object"==typeof i&&!Object.keys(i).length?e.remove():"object"==typeof i?this.lookAt(new THREE.Vector3(i.x,i.y,i.z)):(t=e.el.sceneEl.querySelector(i))?t.hasLoaded?e.beginTracking(t):t.addEventListener("loaded",function(){e.beginTracking(t)}):void n('"'+i+'" does not point to a valid entity to babia-lookat')},tick:(t=new THREE.Vector3,function(e){var i=this.target3D;i&&(i.getWorldPosition(t),this.lookAt(t))}),remove:function(){this.el.removeEventListener("componentinitialized",this.cameraListener),this.el.removeEventListener("componentremoved",this.cameraListener)},beginTracking:function(t){this.target3D=t.object3D},cameraListener:function(t){t.detail&&"camera"===t.detail.name&&this.update()},lookAt:function(t){var e=this.vector,i=this.el.object3D;this.el.getObject3D("camera")?e.subVectors(i.position,t).add(i.position):e.copy(t),i.lookAt(e)}})},7026(t,e,i){if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");const n=i(9590).NotiBuffer;AFRAME.registerComponent("babia-navigator",{schema:{direction:{type:"string",default:""},state:{type:"string",default:""}},multiple:!1,sliderEl:void 0,init:function(){this.notiBuffer=new n(this.registerBack.bind(this),this.unregisterBack.bind(this))},update:function(t){let e=this,i=this.data;if(i.state&&i.state!=t.state&&this.controlNavigator(i.state),i.direction&&i.direction!=t.direction&&this.controlNavigator(i.direction),document.querySelector("#babia-menu-hand")){let t=document.querySelector("#babia-menu-hand");t.parentNode.removeChild(t),r(e,e.handController)}document.addEventListener("controllerconnected",t=>{controller=t.detail.name,"left"!==t.target.getAttribute(controller).hand||document.querySelector("#babia-menu-hand")||(e.handController=t.target.id,r(e,e.handController))})},initializeControls:function(){this.sliderEl=document.createElement("a-entity"),this.sliderEl.min=0,this.sliderEl.max=this.selector.selectable.length-1,this.current=this.selector.selectable.current,this.sliderEl.setAttribute("babia-slider",{size:1.5,min:this.sliderEl.min,max:this.sliderEl.max,value:this.current}),this.sliderEl.classList.add("babiaxraycasterclass"),this.sliderEl.id="timeline",this.sliderEl.setAttribute("scale",{x:2.3,y:2.3,z:2.3}),this.el.appendChild(this.sliderEl),this.controlsEl=document.createElement("a-entity"),this.controlsEl.setAttribute("babia-controls",""),this.controlsEl.classList.add("babiaxraycasterclass"),this.controlsEl.setAttribute("scale",{x:.15,y:.15,z:.3}),this.controlsEl.object3D.position.y=-.5,this.el.appendChild(this.controlsEl),this.stepControllerEl=document.createElement("a-entity"),this.stepControllerEl.setAttribute("babia-step-controller",""),this.stepControllerEl.classList.add("babiaxraycasterclass"),this.stepControllerEl.object3D.position.x=2.5,this.el.appendChild(this.stepControllerEl),this.speedControllerEl=document.createElement("a-entity"),this.speedControllerEl.setAttribute("babia-speed-controller",""),this.speedControllerEl.classList.add("babiaxraycasterclass"),this.speedControllerEl.object3D.position.x=3,this.el.appendChild(this.speedControllerEl)},updateSlider:function(t){let e=this.sliderEl.getAttribute("babia-slider").value;"skipNext"===t?e++:"skipPrev"===t&&e--,"skipPrev"===t&&e>=0||"skipNext"===t&&e<=this.sliderEl.max?(this.current=e,this.notiBuffer.set("babiaSetPosition"+this.current)):this.controlsEl.querySelector(".babiaPause")&&(this.current=e,processData("pause"))},registerBack:function(t){this.selector=t,this.prodComponent=t,this.prodComponent.navNotiBuffer&&(this.navNotiBufferId=this.prodComponent.navNotiBuffer.register(this.processData.bind(this)))},unregisterBack:function(t){t.navNotiBuffer.unregister(this.navNotiBufferId)},processData:function(t){"pause"==t?this.controlsEl.setAttribute("babia-controls","state","pause"):"rewind"==t?this.el.setAttribute("babia-navigator","direction","rewind"):"forward"==t?this.el.setAttribute("babia-navigator","direction","forward"):t.type&&("position"===t.type?(this.sliderEl||this.initializeControls(),"rewind"!=this.data.direction?this.current=t.value-1:this.current=t.value+1,this.current>=this.sliderEl.min&&this.current<=this.sliderEl.max&&(t.label?this.sliderEl.setAttribute("babia-slider",{label:t.label,value:this.current}):this.sliderEl.setAttribute("babia-slider","value",this.current))):"step"===t.type?this.stepControllerEl.setAttribute("babia-step-controller","value",t.value):"speed"===t.type&&this.speedControllerEl.setAttribute("babia-speed-controller","value",t.value))},prodComponent:void 0,navNotiBufferId:void 0,sliderComp:void 0,controlsComp:void 0,stepComp:void 0,speedComp:void 0,controlNavigator:function(t,e){"skipNext"==t||"skipPrev"==t?this.updateSlider(t):this.notiBuffer.set(t+e)}});let r=(t,e)=>{let i=document.getElementById(e);t.el.setAttribute("scale",{x:.1,y:.1,z:.1}),t.el.setAttribute("position",{x:0,y:0,z:-.1}),t.el.setAttribute("rotation",{x:-60}),i.appendChild(t.el),t.el.removeChild(t.controlsEl),t.controlsEl=document.createElement("a-entity"),t.controlsEl.setAttribute("babia-controls",""),t.controlsEl.classList.add("babiaxraycasterclass"),t.controlsEl.setAttribute("scale",{x:.15,y:.15,z:.3}),t.controlsEl.object3D.position.y=-.5,t.el.appendChild(t.controlsEl),a(t.handController,t.el)},a=(t,e)=>{let i=!0;document.getElementById(t).addEventListener("gripdown",function(){i?(i=!1,e.setAttribute("visible",!1)):(i=!0,e.setAttribute("visible",!0))})}},8630(){if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");AFRAME.registerComponent("babia-poster",{schema:{title:{type:"string",default:"New Poster"},titleColor:{type:"string",default:"black"},titleFont:{type:"string",default:"mozillavr"},titleWrapCount:{type:"number",default:24},body:{type:"string",default:"This poster has no body yet."},bodyColor:{type:"string",default:"black"},bodyFont:{type:"string",default:"mozillavr"},bodyWrapCount:{type:"number",default:30},openOn:{type:"string",default:"click"},active:{type:"boolean",default:!0},openIconImage:{type:"asset",default:""},openIconRadius:{type:"number",default:.3},openIconColor:{type:"string",default:"white"},closeIconImage:{type:"asset",default:""},closeIconRadius:{type:"number",default:.3},closeIconColor:{type:"string",default:"white"},image:{type:"string",default:""},imageWidth:{type:"number",default:2},imageHeight:{type:"number",default:2},posterBoxWidth:{type:"number",default:4},posterBoxHeight:{type:"number",default:4},posterBoxColor:{type:"string",default:"white"},posterBoxPadding:{type:"number",default:.2}},multiple:!0,posterPlaneEl:null,closeIconEl:null,titleEl:null,bodyEl:null,imageEl:null,hasImage:!1,init(){this.cameraEl=document.querySelector("[camera]"),this.generateOpenIcon(),this.spawnEntities(),this.el.emit("loaded")},tick(){this.isOpen&&this.positionPosterPlane()},remove(){const{openOn:t}=this.data;this.el.removeEventListener(t,this.togglePosterOpen.bind(this)),this.closeIconEl.removeEventListener(t,this.togglePosterOpen.bind(this))},update(){this.generateTitle(),this.generateBody(),this.generateImage()},togglePosterOpen(t){t.target.getAttribute("id")===`${this.el.getAttribute("id")}--close-icon`&&(this.posterPlaneEl.setAttribute("visible",!1),this.isOpen=!1),this.data.active&&t.target.getAttribute("id")===this.el.getAttribute("id")&&(this.positionPosterPlane(),this.posterPlaneEl.setAttribute("visible",!0),this.isOpen=!0)},generateOpenIcon(){const{openIconRadius:t,openIconColor:e,openIconImage:i,openOn:n}=this.data;this.el.setAttribute("geometry",{primitive:"circle",radius:t}),this.el.setAttribute("material",{color:e,src:i}),this.el.addEventListener(n,this.togglePosterOpen.bind(this))},generateCloseIcon(){const{closeIconRadius:t,closeIconColor:e,closeIconImage:i,posterBoxWidth:n,posterBoxHeight:r,openOn:a}=this.data,o=document.createElement("a-entity");return o.setAttribute("id",`${this.el.getAttribute("id")}--close-icon`),o.setAttribute("position",{x:n/2,y:r/2,z:.01}),o.setAttribute("geometry",{primitive:"circle",radius:t}),o.setAttribute("material",{color:e,src:i}),o.addEventListener(a,this.togglePosterOpen.bind(this)),this