UNPKG

aframe-course-components

Version:
2 lines 7.37 kB
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var o=t();for(var n in o)("object"==typeof exports?exports:e)[n]=o[n]}}(self,(()=>(()=>{var e={803:(e,t,o)=>{o(133),o(686),o(258)},133:e=>{var t=AFRAME.utils.styleParser;if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");e.exports=AFRAME.registerComponent("new-event-set",{schema:{default:"",parse:function(e){console.log("value: ",e);let t=function(e){function t(e){return"-"+e[0].toLowerCase()}var o,n,i,s,l=AFRAME.utils.styleParser.parse(e);for(o in l)n=o.split(".")[0],i=o.split(".").slice(1).join("."),n!==(s=n.replace(/([A-Z])/g,t))&&AFRAME.components[s]&&!AFRAME.components[n]&&(l[s.concat(".",i)]=l[o],delete l[o]);return l}(e);return console.log("parsed: ",t),t},stringify:function(e){return console.log("stringify: ",e),t.stringify(e)}},multiple:!0,init:function(){this.eventHandler=null,this.eventName=null},update:function(e){this.removeEventListener(),this.updateEventListener(),this.addEventListener()},pause:function(){this.removeEventListener()},play:function(){this.addEventListener()},updateEventListener:function(){var e,t,o,n=this.data,i=this.el;e=n._event||this.id,t=n._target,o=t?i.sceneEl.querySelector(t):i,this.eventName=e;const s=()=>{var e;for(e in n)"_event"!==e&&"_target"!==e&&AFRAME.utils.entity.setComponentProperty.call(this,o,e,n[e])};isNaN(n._delay)?this.eventHandler=s:this.eventHandler=()=>{setTimeout(s,parseFloat(n._delay))}},addEventListener:function(){this.el.addEventListener(this.eventName,this.eventHandler)},removeEventListener:function(){this.el.removeEventListener(this.eventName,this.eventHandler)}})},258:e=>{let t=AFRAME.registerComponent("playvideo",{schema:{type:"selector",default:"video"},init:function(){console.log("Playing video",this.data);try{this.data.loop=!1,this.data.play()}catch(e){console.log(e)}let e=null;e=this.el.components.videotarget&&this.el.components.videotarget.data?this.el.components.videotarget.data:this.el,console.log("Playing on: ",e),e.setAttribute("src",this.el.components.playvideo.attrValue),setTimeout(function(){this.el.removeAttribute("playvideo")}.bind(this),100)},remove:function(){console.log("Removing playvideo")}}),o=AFRAME.registerComponent("loopvideo",{schema:{type:"selector",default:"video"},init:function(){console.log("Looping video",this.data);try{this.data.loop=!0,this.data.play()}catch(e){console.log(e)}let e=null;e=this.el.components.videotarget&&this.el.components.videotarget.data?this.el.components.videotarget.data:this.el,console.log("Playing on: ",e),e.setAttribute("src",this.el.components.loopvideo.attrValue),setTimeout(function(){this.el.removeAttribute("loopvideo")}.bind(this),100)},remove:function(){console.log("Removing loopvideo")}}),n=AFRAME.registerComponent("stopallvideos",{init:function(){if(console.log("Stopping all videos"),this.el.components.videoset)console.log(this.el.components.videoset.data),this.el.components.videoset.data.forEach((function(e){e.pause(),e.currentTime=0}));else if(this.el.getAttribute("src")){let e=document.querySelector(this.el.getAttribute("src"));e&&"video"===e.tagName.toLowerCase()?(console.log("Stopping video on self: ",e),e.pause(),e.currentTime=0):console.warn("No video found in the current entity.")}setTimeout(function(){this.el.removeAttribute("stopallvideos")}.bind(this),100)},remove:function(){console.log("Removing stopallvideos")}}),i=AFRAME.registerComponent("pauseallvideos",{init:function(){if(console.log("Pausing all videos"),this.el.components.videoset)console.log(this.el.components.videoset.data),this.el.components.videoset.data.forEach((function(e){e.pause()}));else if(this.el.getAttribute("src")){let e=document.querySelector(this.el.getAttribute("src"));e&&"video"===e.tagName.toLowerCase()?(console.log("Pausing video on self: ",e),e.pause()):console.warn("No video found in the current entity.")}setTimeout(function(){this.el.removeAttribute("pauseallvideos")}.bind(this),100)},remove:function(){console.log("Removing pauseallvideos")}}),s=AFRAME.registerComponent("videotarget",{schema:{type:"selector",default:"a-video"},init:function(){}}),l=AFRAME.registerComponent("videoset",{schema:{type:"selectorAll",default:"videos"},init:function(){}});e.exports=[t,o,n,i,s,l]},686:e=>{if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");const t=AFRAME.utils.bind;function o(e,t){var o;for(o=0;o<t.length;o++)e.emit(t[o],null),console.log("emmited: ",t[o])}e.exports=AFRAME.registerComponent("toggle-controls",{schema:{enabled:{default:!0,type:"boolean"},toggled:{default:!1,type:"boolean"},events:{type:"array",default:[]},type:{oneOf:["single","double"],default:"single"},onEvents:{type:"array"},offEvents:{type:"array"},toggleTimeout:{type:"int",default:400},eventCond:{default:""}},multiple:!0,init:function(){this.clickTimer=null,this.onToggle=t(this.onToggle,this)},update:function(e){const t=this.data;this.toggled=t.toggled,this.eventCond=t.eventCond&&2==t.eventCond.split("=").length?t.eventCond.split("="):null},play:function(){this.addEventListeners()},pause:function(){this.removeEventListeners()},remove:function(){this.pause()},addEventListeners:function(){!function(e,t,o){var n;for(n=0;n<t.length;n++){const i=t[n];i.includes("key")?window.addEventListener(i,o):e.addEventListener(i,o)}}(this.el,this.data.events,this.onToggle)},removeEventListeners:function(){!function(e,t,o){var n;for(n=0;n<t.length;n++){const i=t[n];i.includes("key")?window.removeEventListener(i,o):e.removeEventListener(i,o)}}(this.el,this.data.events,this.onToggle)},onToggle:function(e){const t=this.data;t.enabled&&(this.eventCond&&e[this.eventCond[0]]!==this.eventCond[1]||(console.log(e.target.tagName),"double"===t.type?null==this.clickTimer?this.clickTimer=setTimeout((()=>{this.clickTimer=null}),t.toggleTimeout):(clearTimeout(this.clickTimer),this.clickTimer=null,this._toggle()):this._toggle()))},_toggle:function(){const e=this.data;this.toggled?o(this.el,e.offEvents):o(this.el,e.onEvents),console.log(this.toggled),this.toggled=!this.toggled}})},467:e=>{e.exports=AFRAME.registerComponent("autoportal",{dependencies:["aabb-collider"],schema:{rig:{type:"string",default:"#rig"},debug:{type:"boolean",default:!1}},init:function(){console.log("Initting Auto Portal Component")},update:function(){if(this.rig=this.el.sceneEl.querySelector(this.data.rig),this.rig){this.rig.setAttribute("data-aabb-collider-dynamic");let e=rig.querySelector("[camera]")||rig.querySelector("a-camera"),t=document.createElement("a-cylinder");t.setAttribute("radius","0.2"),t.setAttribute("height","2"),t.setAttribute("visible","false"),e.appendChild(t)}else console.warn("Could not find player rig! Check 'rig' property: ",this.data.rig);this.el.setAttribute("aabb-collider","objects",this.data.rig),this.el.setAttribute("aabb-collider","debug",this.data.debug),this.el.addEventListener("hitstart",function(){console.log("Auto Portal hit. Openning target"),document.location.href=this.el.getAttribute("href")}.bind(this))}})},64:(e,t,o)=>{o(467)}},t={};function o(n){var i=t[n];if(void 0!==i)return i.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,o),s.exports}return o(803),o(64),{}})())); //# sourceMappingURL=aframe-course.min.js.map