From d7ac26fc626464abb8e788c01edeffdbdb335d9f Mon Sep 17 00:00:00 2001 From: mysterion <49054698+mysterion@users.noreply.github.com> Date: Thu, 4 Apr 2024 23:23:58 +0530 Subject: [PATCH] 1.3.1 --- index.html | 8 +++++++- static/index-ClBI3MFD.js | 5 ----- 2 files changed, 7 insertions(+), 6 deletions(-) delete mode 100644 static/index-ClBI3MFD.js diff --git a/index.html b/index.html index 2b382e3..ab867a9 100644 --- a/index.html +++ b/index.html @@ -8,7 +8,7 @@ aframe vr player - + @@ -59,6 +59,11 @@ + + + + + @@ -67,6 +72,7 @@ + diff --git a/static/index-ClBI3MFD.js b/static/index-ClBI3MFD.js deleted file mode 100644 index fa38e94..0000000 --- a/static/index-ClBI3MFD.js +++ /dev/null @@ -1,5 +0,0 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))s(n);new MutationObserver(n=>{for(const l of n)if(l.type==="childList")for(const h of l.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&s(h)}).observe(document,{childList:!0,subtree:!0});function i(n){const l={};return n.integrity&&(l.integrity=n.integrity),n.referrerPolicy&&(l.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?l.credentials="include":n.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function s(n){if(n.ep)return;n.ep=!0;const l=i(n);fetch(n.href,l)}})();const B="controls-hidden",P="controls-shown",L="controls";AFRAME.registerComponent("controls",{init:function(){this.system.register(this.el)},remove:function(){this.system.unregister(this.el)}});AFRAME.registerSystem("controls",{init:function(){this.entities=[],this.clickables=[]},register:function(e){this.entities.push(e)},unregister:function(e){var t=this.entities.indexOf(e);this.entities.splice(t,1)},hideControls:function(){for(let e in this.entities){let t=this.entities[e];this.clickables.push(t.hasAttribute("clickable")),this.clickables.at(-1)&&t.removeAttribute("clickable"),t.object3D.visible=!1}o.events.emit(L,B,!1)},showControls:function(){for(let e in this.entities){let t=this.entities[e];this.clickables[e]&&t.setAttribute("clickable",""),t.object3D.visible=!0}this.clickables=[],o.events.emit(L,P,!1)}});const I={SETTINGS:"Settings",VIDSTATE:"VideoState",CONTROLS:"Controls",ENVIRONMENT:"Environment"};AFRAME.registerComponent("events",{init:function(){console.log("Events initialized...")}});function Y(e,t){return e||(e="#FFF"),e==="#FFF"&&(t*=-1),"#"+e.replace(/^#/,"").replace(/../g,i=>("0"+Math.min(255,Math.max(0,parseInt(i,16)+t)).toString(16)).substr(-2))}function R(e){isNaN(e)&&(e=0);var t=new Date(null);return t.setSeconds(e),t.toISOString().substr(11,8)}function O(e){return e.replace(/^.*[\\/]/,"")}function r(e="a-entity",t={},i=[],s=null){const n=document.createElement(e);for(let l in t)n.setAttribute(l,t[l]);return i.length>0&&n.append(...i),s!==null&&s.appendChild(n),n}function Q(e,t){return e.getAttribute(t)}function c(e,t={}){for(let i in t)e.setAttribute(i,t[i])}function J(e,t){return Object.fromEntries(Object.entries(t).filter(([i,s])=>i in e&&e[i]!==s))}function z(e){for(const t in e)return!1;return!0}function X(e){return document.querySelector("#"+e)}AFRAME.registerComponent("timeline",{schema:{videoId:{type:"string",default:"video"}},init:function(){var e=this.el;this.video=document.getElementById(this.data.videoId);const{width:t,height:i}=e.getAttribute("geometry");this.seek=r("a-entity",{geometry:`primitive: box; width: ${t*.01}; height: ${i}; depth: 0.5;`,material:"color: #006cd8",position:`${-t/2} 0 0`},[],e),this.hoverEl=r("a-entity",{geometry:`primitive: box; width: ${t*.01}; height: ${i+1}; depth: 0.5; `,visible:!1,material:"color: #00FF00"},[],e),this.hoverTextEl=r("a-text",{position:"0 5 0",align:"center",value:"00:00:00",width:"40"},[r("a-entity",{geometry:"primitive: plane; width: 8; height: 2.5;",position:"0 0 -0.5",material:"color: #808080"})],this.hoverEl),this.bg=r("a-entity",{geometry:`primitive: plane; width: ${t+1.5}; height: ${i+1} `,material:"color: #006cd8",position:"0 0 -0.5"},[],e),this.videoText=r("a-entity",{position:"0 0 0.5",text:"value: 00:00:00/00:00:00; width: 40; align: center;",material:"color: #333; opacity: 0.5;"},[r("a-plane",{geometry:"primitive: plane; width: 15; height: 2.5;",position:"0 0 -0.1",material:"color: black; opacity: 0.5"})],e),this.updateElems=()=>{var s=this.video.currentTime/this.video.duration*t-t/2;this.seek.setAttribute("position",{x:s}),this.videoText.setAttribute("text",{value:`${R(this.video.currentTime)} /${R(this.video.duration)}`})},this.video.addEventListener("loadedmetadata",()=>{this.seek.setAttribute("position",{x:-t/2}),this.videoText.setAttribute("text",{value:`${R(this.video.currentTime)}/${R(this.video.duration)}`})}),this.video.addEventListener("timeupdate",this.updateElems),e.addEventListener("click",s=>{let n=this.video;if(n.readyState===0){console.log("no info available for video");return}var l=s.detail.intersection.uv.x;n.currentTime=(l*n.duration).toFixed(2)}),e.addEventListener("raycaster-intersected",s=>{this.raycaster=s.detail.el,this.hoverEl.setAttribute("visible",!0)}),e.addEventListener("raycaster-intersected-cleared",s=>{this.raycaster=null,this.hoverEl.setAttribute("visible",!1)})},tick:function(){var a,u,x;if(!this.raycaster)return;let e=this.raycaster.components.raycaster.getIntersection(this.el);if(!e||e.point.x===((a=this.previousIntersection)==null?void 0:a.x)&&e.point.y===((u=this.previousIntersection)==null?void 0:u.y)&&e.point.z===((x=this.previousIntersection)==null?void 0:x.z))return;let t=e.uv.x,i=timeline.getAttribute("geometry").width,s=t*i-i/2,n=Math.floor(t*video.duration),{y:l,z:h}=this.hoverEl.getAttribute("position");this.hoverEl.setAttribute("position",`${s} ${l} ${h}`),this.hoverTextEl.setAttribute("value",R(n)),this.previousIntersection=e.point},remove:function(){var e=this.el;e.removeAttribute("controls"),e.removeChild(this.seek),e.removeChild(this.hoverEl),e.removeChild(this.bg),e.removeChild(this.videoText)}});const v=function(){return{get:i=>JSON.parse(localStorage.getItem(i)),set:(i,s)=>{localStorage.setItem(i,JSON.stringify(s))}}}(),C="settings",g={RESUME_VIDEO:"resumeVideo",DEF_PRESET:"defaultPreset",SAVE_PRESET:"savePreset",DEF_EYE:"defaultEye",VIEW_ANG:"viewAngle",UI_ANG:"uiAngle"},_=e=>o.settings.getAttribute(C)[e];AFRAME.registerComponent(C,{schema:{[g.RESUME_VIDEO]:{type:"boolean",default:!0},[g.DEF_PRESET]:{type:"number",default:0},[g.SAVE_PRESET]:{type:"boolean",default:!0},[g.DEF_EYE]:{type:"string",default:"left"},[g.VIEW_ANG]:{type:"number",default:0},[g.UI_ANG]:{type:"number",default:0}},init:function(){let e=this.el,t=v.get("settings");if(!t)t=this.data,v.set("settings",t);else{for(let s in t)s in this.data||delete t[s];let i={};for(let s in this.data)s in t||(i[s]=this.data[s]);z(i)||v.set("settings",{...t,...i}),e.setAttribute(C,t)}},update:function(e){o.events.emit(I.SETTINGS,this.data,!1),v.set("settings",this.data)}});AFRAME.registerComponent("stereocam",{schema:{eye:{type:"string",default:"left"}},init:function(){this.onEyeChange=AFRAME.utils.bind(this.onEyeChange,this),this.layer_changed=!1,o.events.addEventListener(I.SETTINGS,this.onEyeChange)},onEyeChange:function(e){let t=e.detail[g.DEF_EYE];this.el.setAttribute("stereocam",`eye: ${t}`)},tick:function(e){var t=this.data;if(!this.layer_changed){var i;this.el.object3D.children.forEach(function(s){s.type=="PerspectiveCamera"&&(i=s)}),i?t.eye==="left"?(i.layers.enable(1),i.layers.disable(2)):t.eye==="right"?(i.layers.enable(2),i.layers.disable(1)):(i.layers.enable(1),i.layers.enable(2)):console.error("stereocam: Camera not found")}},remove:function(e){o.events.removeEventListener(I.SETTINGS,this.onEyeChange)}});AFRAME.registerComponent("button-highlight",{init:function(){this.color=this.el.getAttribute("material").color,this.el.addEventListener("raycaster-intersected",e=>{this.el.setAttribute("material",{color:Y(this.color,40)})}),this.el.addEventListener("raycaster-intersected-cleared",e=>{this.el.setAttribute("material",{color:this.color})})}});AFRAME.registerComponent("recenter",{schema:{},init:function(){var e=this.el;this.camera=document.getElementById("camera"),this.recenterCamera=!1,this.controlsVisible=!0,e.sceneEl.addEventListener("enter-vr",()=>{this.recenterCamera=!0}),e.sceneEl.addEventListener("exit-vr",()=>{this.recenterCamera=!1}),o.events.addEventListener(L,t=>{t.detail===B?this.controlsVisible=!1:t.detail===P&&(this.controlsVisible=!0)}),e.addEventListener("click",t=>{if(t.detail.intersectedEl===e){if(!this.controlsVisible){e.sceneEl.systems.controls.showControls();return}this.recenterCamera&&e.setAttribute("rotation",{y:-this.camera.getAttribute("rotation").y})}})}});AFRAME.registerComponent("cursor-util",{schema:{},init:function(){let e=this.el;this.checkVR=AFRAME.utils.bind(this.checkVR,this),e.sceneEl.addEventListener("enter-vr",this.checkVR),e.sceneEl.addEventListener("exit-vr",this.checkVR),this.cursorChild=r("a-entity",{geometry:"primitive: circle; radius: 0.2;",material:"color: aquamarine; shader: flat"}),this.checkVR()},checkVR:function(){let e=this.el;AFRAME.utils.device.checkVRSupport()?(c(e,{geometry:"primitive: ring; radiusInner: 0.2; radiusOuter: 0.4",material:"color: black; shader: flat"}),e.appendChild(this.cursorChild)):(e.setAttribute("cursor","rayOrigin: mouse"),e.replaceChildren())}});AFRAME.registerComponent("adjust-camera",{init:function(){let e=this.el;e.sceneEl.addEventListener("enter-vr",function(){e.setAttribute("position",{y:-1.6})}),e.sceneEl.addEventListener("exit-vr",function(){e.setAttribute("position",{y:0})})}});const w={EQ:"equirectangular",FE:"fisheye",FLAT:"flat"},E={EQ_180_SBS:"EQ_180_SBS",FE_180_SBS:"FE_180_SBS",FE_190_SBS:"FE_190_SBS",FE_200_SBS:"FE_200_SBS",FLAT_2D:"FLAT_2D",FLAT_3D:"FLAT_3D"},D=[{text:"180 SBS EQR",fn:()=>{c(o.env,{"env-manager":`preset: ${E.EQ_180_SBS}`})}},{text:"FLAT 2D",fn:()=>{c(o.env,{"env-manager":`preset: ${E.FLAT_2D}`})}},{text:"180 SBS FISH",fn:()=>{c(o.env,{"env-manager":`preset: ${E.FE_180_SBS}`})}},{text:"190 SBS FISH",fn:()=>{c(o.env,{"env-manager":`preset: ${E.FE_190_SBS}`})}},{text:"200 SBS FISH",fn:()=>{c(o.env,{"env-manager":`preset: ${E.FE_200_SBS}`})}}];function G(e){e==null&&(e="");for(let t in w)if(e.startsWith(t))return w[t]}AFRAME.registerComponent("env-manager",{schema:{preset:{type:"string",default:E.EQ_180_SBS},uiHidden:{type:"boolean",default:!1},defaultEye:{type:"string",default:"left"}},init:function(){this.data,this.onEyeChange=AFRAME.utils.bind(this.onEyeChange,this),this.onUIHide=AFRAME.utils.bind(this.onUIHide,this),o.events.addEventListener(L,this.onUIHide),o.events.addEventListener(I.SETTINGS,this.onEyeChange)},onEyeChange:function(e){let t=e.detail[g.DEF_EYE];this.el.setAttribute("env-manager",`defaultEye: ${t}`)},update:function(e){let t=this.data,i=this.el;switch(i.removeAttribute(G(e.preset)),t.preset){case E.EQ_180_SBS:i.setAttribute(w.EQ,{uiHidden:t.uiHidden,defaultEye:t.defaultEye});break;case E.FE_180_SBS:i.setAttribute(w.FE,{uiHidden:t.uiHidden,defaultEye:t.defaultEye});break;case E.FE_190_SBS:i.setAttribute(w.FE,{uiHidden:t.uiHidden,defaultEye:t.defaultEye,fov:190});break;case E.FE_200_SBS:i.setAttribute(w.FE,{uiHidden:t.uiHidden,defaultEye:t.defaultEye,fov:200});break;case E.FLAT_2D:i.setAttribute(w.FLAT,"");break;default:console.error("preset not found")}Object.keys(J(t,e)).every(n=>["uiHidden","defaultEye"].includes(n))||o.events.emit(I.ENVIRONMENT,t)},onUIHide:function(e){e.detail===B?this.el.setAttribute("env-manager","uiHidden: true"):e.detail===P&&this.el.setAttribute("env-manager","uiHidden: false")},remove:function(){o.events.removeEventListener(L,this.onUIHide),o.events.removeEventListener(I.SETTINGS,this.onEyeChange)}});const N=[90,60,45,30,0,-30,-45,-60,-90],H=[60,45,30,15,0,-15,-30,-45,-60];function T(e){e.removeAttribute("button-highlight"),e.removeAttribute("clickable"),e.setAttribute("visible",!1)}function V(e){e.setAttribute("button-highlight",""),e.setAttribute("clickable",""),e.setAttribute("visible",!0)}AFRAME.registerComponent("toggle-adjust-ui",{init:function(){this.viewAngleIdx=v.get("viewAngleIdx")??4,this.uiAngleIdx=v.get("uiAngleIdx")??4,this.viewUp=r("a-entity",{position:"0 4 0",geometry:"primitive: triangle; vertexA: 0 0.5 0; vertexB: -2 -1.5 0; vertexC: 2 -1.5 0;",material:"side: double; color: #808080; opacity: 1;",clickable:"","button-highlight":""},[r("a-entity",{position:"0 0 -0.25",geometry:"primitive: triangle; vertexA: 0 1 0; vertexB: -2.5 -1.5 0; vertexC: 2.5 -1.5 0;",material:"side: double; color: #006cd8; opacity: 1;","button-highlight":""})]),this.viewDown=r("a-entity",{position:"0 -4 0",geometry:"primitive: triangle; vertexA: 2 1.5 0; vertexB: 0 -0.5 0; vertexC: -2 1.5 0;",material:"side: double; color: #808080; opacity: 1;",clickable:"","button-highlight":""},[r("a-entity",{position:"0 0 -0.25",geometry:"primitive: triangle; vertexA: 2.5 1.5 0; vertexB: 0 -1 0; vertexC: -2.5 1.5 0;",material:"side: double; color: #006cd8; opacity: 1;","button-highlight":""})]),this.viewAngle=r("a-entity",{position:"-34 1.5 -59",material:"color: #808080; opacity: 1",rotation:"0 20 0",geometry:"primitive:plane; width:4.5; height: 4.5"},[r("a-text",{align:"center",value:`view -0`,width:"40",position:"0 0 0.2"}),r("a-entity",{position:"0 0 -0.2",material:"color: #006cd8; opacity: 1",geometry:"primitive:plane; width:5; height: 5"}),this.viewUp,this.viewDown],this.el),this.uiUp=r("a-entity",{position:"0 4 0",geometry:"primitive: triangle; vertexA: 0 0.5 0; vertexB: -2 -1.5 0; vertexC: 2 -1.5 0;",material:"side: double; color: #808080; opacity: 1;",clickable:"","button-highlight":""},[r("a-entity",{position:"0 0 -0.25",geometry:"primitive: triangle; vertexA: 0 1 0; vertexB: -2.5 -1.5 0; vertexC: 2.5 -1.5 0;",material:"side: double; color: #006cd8; opacity: 1;","button-highlight":""})]),this.uiDown=r("a-entity",{position:"0 -4 0",geometry:"primitive: triangle; vertexA: 2 1.5 0; vertexB: 0 -0.5 0; vertexC: -2 1.5 0;",material:"side: double; color: #808080; opacity: 1;",clickable:"","button-highlight":""},[r("a-entity",{position:"0 0 -0.25",geometry:"primitive: triangle; vertexA: 2.5 1.5 0; vertexB: 0 -1 0; vertexC: -2.5 1.5 0;",material:"side: double; color: #006cd8; opacity: 1;","button-highlight":""})]),this.uiAngle=r("a-entity",{position:"34 1.5 -59",rotation:"0 -20 0",material:"color: #808080; opacity: 1",geometry:"primitive:plane; width:4.5; height: 4.5"},[r("a-text",{align:"center",value:`ui -0`,width:"40",position:"0 0 0.2"}),r("a-entity",{position:"0 0 -0.2",material:"color: #006cd8; opacity: 1",geometry:"primitive:plane; width:5; height: 5"}),this.uiUp,this.uiDown],this.el),this.uiUp.addEventListener("click",()=>{this.uiAngleIdx-=1,this.update()}),this.uiDown.addEventListener("click",()=>{this.uiAngleIdx+=1,this.update()}),this.viewUp.addEventListener("click",()=>{this.viewAngleIdx-=1,this.update()}),this.viewDown.addEventListener("click",()=>{this.viewAngleIdx+=1,this.update()}),this.onEnvChange=AFRAME.utils.bind(this.onEnvChange,this),o.events.addEventListener(I.ENVIRONMENT,this.onEnvChange)},update:function(){this.uiAngleIdx===0?T(this.uiUp):V(this.uiUp),this.uiAngleIdx===H.length-1?T(this.uiDown):V(this.uiDown),this.viewAngleIdx===0?T(this.viewUp):V(this.viewUp),this.viewAngleIdx===N.length-1?T(this.viewDown):V(this.viewDown),this.curEnv===w.FLAT?(T(this.uiDown),T(this.uiUp),this.uiAngle.setAttribute("visible",!1)):this.uiAngle.setAttribute("visible",!0),o.cameraRig.setAttribute("rotation",`${-1*N[this.viewAngleIdx]} 0 0`),c(this.viewAngle.children[0],{value:`view -${N[this.viewAngleIdx]}`}),v.set("viewAngleIdx",this.viewAngleIdx),o.controls.setAttribute("rotation",`${H[this.uiAngleIdx]} 0 0`),c(this.uiAngle.children[0],{value:`ui -${H[this.uiAngleIdx]}`}),this.curEnv!==w.FLAT&&v.set("uiAngleIdx",this.uiAngleIdx)},onEnvChange:function(e){this.curEnv=G(e.detail.preset),this.update()},remove:function(){this.el.removeChild(this.viewAngle),this.el.removeChild(this.uiAngle)}});AFRAME.registerComponent("marq-text",{schema:{value:{type:"string",default:""},limit:{type:"number",default:30}},init:function(){this.timerId=null,this.st=0,this.marquee=AFRAME.utils.bind(this.marquee,this),this.txt=r("a-text",{align:"center",width:"35",position:"0 0 1"}),this.el.appendChild(this.txt),this.data.value.length>this.data.limit&&(this.el.addEventListener("raycaster-intersected",e=>{this.timerId=setInterval(this.marquee,200)}),this.el.addEventListener("raycaster-intersected-cleared",e=>{this.update()}))},update:function(){this.st=0,this.txt.setAttribute("value",this.data.value.substring(this.st,this.st+this.data.limit)),clearInterval(this.timerId)},remove:function(){clearInterval(this.timerId)},marquee:function(){this.st=(this.st+1)%this.data.value.length,this.data.value.length-this.st<20&&(this.st=0),this.txt.setAttribute("value",this.data.value.substring(this.st,this.st+this.data.limit))}});const M="video-state";AFRAME.registerComponent(M,{schema:{presetId:{type:"number",default:0},src:{type:"string",default:"static/sample.mp4"},fileName:{type:"string",default:"sample.mp4"},resumeVideo:{type:"boolean",default:!1}},init:function(){this.onVideoLoad=AFRAME.utils.bind(this.onVideoLoad,this),this.saveVidTime=AFRAME.utils.bind(this.saveVidTime,this),this.setupKeys=AFRAME.utils.bind(this.setupKeys,this),this.video=document.querySelector("#video"),this.toggleModeBtn=r("a-entity",{position:"0 -12 -60",clickable:"",controls:"",material:"color: #808080; opacity: 1",geometry:"primitive:plane; width:15; height: 3","button-highlight":""},[],o.controls),this.toggleModeBtnTxt=r("a-text",{value:D[this.data.presetId].text,width:40,align:"center",position:"0 0 0.5"},[],this.toggleModeBtn),this.toggleBtnHandler=AFRAME.utils.bind(this.toggleBtnHandler,this),this.toggleModeBtn.addEventListener("click",this.toggleBtnHandler),this.setupKeys(this.data.src),this.lastUpdate=Date.now(),this.video.readyState>=1&&this.onVideoLoad,this.video.addEventListener("loadedmetadata",this.onVideoLoad)},update:function(e){var t=this.data;e.src&&e.src!==t.src&&(this.setupKeys(t.src),this.video.src=t.src,this.video.play()),_(g.RESUME_VIDEO)?this.video.addEventListener("timeupdate",this.saveVidTime):this.video.removeEventListener("timeupdate",this.saveVidTime),D[t.presetId].fn(),this.toggleModeBtnTxt.setAttribute("value",D[t.presetId].text)},onVideoLoad:function(){if(this.lastUpdate=Date.now(),_(g.RESUME_VIDEO)){let e=v.get(this.timeKey);e&&(this.video.currentTime=e)}if(_(g.SAVE_PRESET)){let e=v.get(this.presetKey);e!=null&&c(this.el,{[M]:{presetId:e}})}},toggleBtnHandler:function(){if(this.video.readyState>=1){let e=(this.data.presetId+1)%D.length;c(this.el,{[M]:{presetId:e}}),_(g.SAVE_PRESET)&&v.set(this.presetKey,e)}},saveVidTime:function(){let e=Date.now();e-this.lastUpdate>5e3&&(this.lastUpdate=e,v.set(this.timeKey,this.video.currentTime))},setupKeys:function(e){this.fileName=O(e),this.presetKey=`VID_P_${this.fileName}`,this.timeKey=`VID_T_${this.fileName}`},remove:function(){o.controls.removeChild(this.toggleModeBtn),this.video.removeEventListener("timeupdate",this.saveVidTime),this.video.removeEventListener("loadedmetadata",this.onVideoLoad)}});AFRAME.registerComponent("dialog-utils",{schema:{screen:{type:"string",default:""}},init:function(){let e=this.el;o.events.addEventListener(L,t=>{if(t.detail!==B)return!1;e.object3D.visible=!1,e.removeAttribute("clickable"),e.replaceChildren()})}});const f=60,y=30,Z="https://192.168.1.50:5000/list",ee="https://192.168.1.50:5000/file",A="dialog-files",F=5,j=-y*.125,q=y*.15;async function te(e,t){e.setAttribute("dialog-loading","");let i=await fetch(Z+"/"+t),{files:s,folders:n}=await i.json();e.setAttribute(A,{filesFolders:{files:s,folders:n}}),e.removeAttribute("dialog-loading")}function ie(e,t,i,s,n){var b,$;let l=((b=n[t])==null?void 0:b.files)??0,h=(($=n[t])==null?void 0:$.folders)??0,a=e.getAttribute("geometry"),u=r("a-plane",{geometry:`primitive:plane; width:${a.width}; height: 3`,position:`0 ${a.height/2} 0.2`,material:"color: #808080"},[r("a-entity",{text:`value: folder:/${t}; align: center; width: 30;`,position:"0 0 0.2"})]);e.appendChild(u),e.append(r("a-image",{src:"#asset-movie-icon",position:`-${a.width/2} 0 0.1`,"background-color":"blue",scale:"4 4 1"}),r("a-image",{src:"#asset-folder",position:`${a.width/2} 0 0.1`,"background-color":"blue",scale:"4 4 1"}));let x=r("a-image",{src:"#asset-refresh",scale:"4 4 1",position:`-${a.width*.1} ${a.height*.35} 0.3`,clickable:"","button-highlight":""});x.addEventListener("click",()=>{this.fetchFiles(e,t)});let d=r("a-image",{src:"#asset-back",scale:"4 4 1",position:`${a.width*.1} ${a.height*.35} 0.3`,clickable:"","button-highlight":""});if(d.addEventListener("click",()=>{e.setAttribute(A,{url:t.substr(0,t.lastIndexOf("/"))})}),e.append(x,d),i.length>F){if(l!=0){let p=r("a-image",{src:"#asset-up",scale:"3 3 1",position:`-${a.width*.25} ${a.height*.3} 0.2`,clickable:"","button-highlight":""});p.addEventListener("click",()=>{e.setAttribute(A,{offset:{...n,[t]:{files:l-F,folders:h}}})}),e.appendChild(p)}if(l+F{e.setAttribute(A,{offset:{...n,[t]:{files:l+F,folders:h}}})}),e.appendChild(p)}}if(s.length>F){if(h!=0){let p=r("a-image",{src:"#asset-up",scale:"3 3 1",position:`${a.width*.25} ${a.height*.3} 0.2`,clickable:"","button-highlight":""});p.addEventListener("click",()=>{e.setAttribute(A,{offset:{...n,[t]:{files:l,folders:h-F}}})}),e.appendChild(p)}if(h+F{e.setAttribute(A,{offset:{...n,[t]:{files:l,folders:h+F}}})}),e.appendChild(p)}}}function se(e,t,i,s,n){var u,x;e.replaceChildren(),e.setAttribute("clickable",""),e.object3D.visible=!0;let l=((u=n[t])==null?void 0:u.files)??0,h=((x=n[t])==null?void 0:x.folders)??0,a=q;for(let d=l;d{let $=ee+t+"/"+i[d];$=URL.createObjectURL(await this.fileHandles[d].getFile()),o.videoState.setAttribute(M,{src:$,fileName:i[d]})},e.appendChild(b),a+=j}a=q;for(let d=h;d{e.setAttribute(A,{url:t+"/"+s[d]}),console.log("going : ",t+"/"+s[d])},e.appendChild(b),a+=j}this.insertFolderUI(e,t,i,s,n)}AFRAME.registerComponent(A,{schema:{url:{type:"string",default:""},filesFolders:{default:{files:[],folders:[]},parse:function(e){return typeof e=="object"?e:JSON.parse(e)},stringify:function(e){return typeof e=="string"?e:JSON.stringify(e)}},offset:{default:{"":{files:0,folders:0}},parse:function(e){return typeof e=="object"?e:JSON.parse(e)},stringify:function(e){return typeof e=="string"?e:JSON.stringify(e)}},reRender:{type:"string",default:""}},init:function(){let e=this.el;e.setAttribute("geometry",`primitive: plane; width: ${f}; height: ${y}`),e.setAttribute("material","color: teal"),e.setAttribute("dialog-utils",{screen:A}),e.object3D.visible=!0,this.fetchFiles=AFRAME.utils.bind(te,this),this.insertFolderUI=AFRAME.utils.bind(ie,this),this.renderFiles=AFRAME.utils.bind(se,this)},update:function(e){var t=this.data,i=this.el;if(t.reRender&&t.reRender.length>0){i.setAttribute("dialog-utils",{screen:A}),i.setAttribute(A,{reRender:""});return}t.url!==e.url?this.fetchFiles(this.el,t.url):this.renderFiles(i,t.url,t.filesFolders.files,t.filesFolders.folders,t.offset)},remove:function(){let e=this.el;e.replaceChildren(),e.removeAttribute("clickable"),e.setAttribute("dialog-utils",{screen:""})}});const S="dialog-settings",U=5,ne=-y*.125,re=y*.15;document.querySelector("a-scene");function le(e,t,i){var s=["left","right"],n=s.indexOf(i);let l=r("a-plane",{geometry:`width: ${f*.4}; height: ${y*.1}`,material:"color: #A15807;",position:`${f*.25} ${t} 0.2`,clickable:"","button-highlight":""},[r("a-entity",{text:`value: ${i}; align: center; width: 35;`,position:"0 0 0.2"})]),h=l.children[0];l.onclick=()=>{n=(n+1)%s.length,h.setAttribute("text",`value: ${s[n]}`),o.settings.setAttribute(C,{defaultEye:s[n]})},e.appendChild(l)}function oe(e,t,i){var s=[!1,!0],n=s.indexOf(i);let l=r("a-plane",{geometry:`width: ${f*.4}; height: ${y*.1}`,material:"color: #A15807;",position:`${f*.25} ${t} 0.2`,clickable:"","button-highlight":""},[r("a-entity",{text:`value: ${i?"ON":"OFF"}; align: center; width: 35;`,position:"0 0 0.2"})]),h=l.children[0];l.onclick=()=>{let a=s[++n%s.length];h.setAttribute("text",`value: ${a?"ON":"OFF"}`),o.settings.setAttribute(C,{savePreset:a})},e.appendChild(l)}function ae(e,t,i){var s=[!1,!0],n=s.indexOf(i);let l=r("a-plane",{geometry:`width: ${f*.4}; height: ${y*.1}`,material:"color: #A15807;",position:`${f*.25} ${t} 0.2`,clickable:"","button-highlight":""},[r("a-entity",{text:`value: ${i?"ON":"OFF"}; align: center; width: 35;`,position:"0 0 0.2"})]),h=l.children[0];l.addEventListener("click",()=>{let a=s[++n%s.length];h.setAttribute("text",`value: ${a?"ON":"OFF"}`),o.settings.setAttribute(C,{resumeVideo:a})}),e.appendChild(l)}const k=[{name:"save preset per video",render:oe,storeKey:g.SAVE_PRESET},{name:"resume video",render:ae,storeKey:g.RESUME_VIDEO},{name:"default eye",render:le,storeKey:g.DEF_EYE}];function he(e,t){let i=e.getAttribute("geometry");if(e.appendChild(r("a-entity",{geometry:`primitive:plane; width:${i.width}; height: 3`,position:`0 ${i.height/2} 0.2`,material:"color: grey"},[r("a-entity",{text:"value: Settings; align: center; width: 30;",position:"0 0 0.2"})])),k.length>U){if(t!=0){let s=r("a-image",{src:"#asset-up",scale:"3 3 1",position:`0 ${i.height*.3} 0.2`,clickable:"","button-highlight":""});s.addEventListener("click",()=>{e.setAttribute(C,{offset:t-1})}),e.appendChild(s)}if(t+U{e.setAttribute(C,{offset:t+1})}),e.appendChild(s)}}}function de(e,t){e.replaceChildren(),e.setAttribute("clickable",""),e.object3D.visible=!0,he(e,t);let i=Q(o.settings,C),s=re;for(let n=t;n0){i.setAttribute("dialog-utils",{screen:S}),i.setAttribute(S,{reRender:""});return}de(i,t.offset)},remove:function(){let e=this.el;e.replaceChildren(),e.removeAttribute("clickable"),e.setAttribute("dialog-utils",{screen:""})}});AFRAME.registerComponent("dialog-loading",{schema:{},init:function(){let e=this.el,t=this.loader=r("a-entity",{geometry:`primitive: plane; width: ${f}; height: ${y}`,material:"color: teal; opacity: 0.2",position:"0 0 3",clickable:""});e.appendChild(t);let i=r("a-image",{src:"#asset-loading",position:"0 0 1",scale:"4 4 1"}),s=r("a-text",{value:"loading",width:2,align:"center",position:"0 -0.5 0.1"});t.append(i,s)},remove:function(){this.el.contains(this.loader)&&this.el.removeChild(this.loader)}});AFRAME.registerComponent("eq-sphere",{schema:{eye:{type:"string",default:"left"},fov:{type:"number",default:180},side:{type:"string",default:"left"}},init:function(){let e=this.el.object3D.children[0],t=this.data,i=this.el.getAttribute("geometry"),s=new THREE.SphereGeometry(i.radius||100,i.segmentsWidth||32,i.segmentsHeight||32,Math.PI,Math.PI,0,Math.PI),n={repeat:{x:-.5,y:1},offset:{x:.5,y:0}};t.side==="right"&&(n.offset.x+=.5);let l=s.attributes.uv;for(let h=0;h{o.file.click()});return}}});AFRAME.registerComponent("btn-pause-play",{init:function(){let e=this.el;this.video=document.getElementById("video"),this.pausePlay=()=>{this.video.paused?this.video.play():this.video.pause()},this.onPause=()=>e.setAttribute("src","#asset-vp-play"),this.onPlay=()=>e.setAttribute("src","#asset-vp-pause"),e.addEventListener("click",this.pausePlay),this.video.addEventListener("playing",this.onPlay),this.video.addEventListener("pause",this.onPause)},remove:function(){el.removeEventListener("click",this.pausePlay),this.video.removeEventListener("playing",this.onPlay),this.video.removeEventListener("pause",this.onPause)}});AFRAME.registerComponent("btn-seek-back",{init:function(){let e=this.el;this.video=document.getElementById("video"),e.addEventListener("click",()=>{this.video.currentTime-=15})}});AFRAME.registerComponent("btn-seek-forw",{init:function(){let e=this.el;this.video=document.getElementById("video"),e.addEventListener("click",()=>{this.video.currentTime+=15})}});AFRAME.registerComponent("btn-vol",{schema:{vol:{type:"number",default:1}},init:function(){let e=this.el;this.setVolume=AFRAME.utils.bind(this.setVolume,this);let t=this.width=10;c(e,{geometry:{primitive:"plane",width:t+1,height:5},material:"color: #808080"});let i=this.txt=r("a-text",{width:40,align:"center",value:"100",position:"0 0 0.3"});e.appendChild(i);let s=this.bar=r("a-entity",{material:"color: #005073",geometry:"primitive: plane;width: width;height: 4;"});e.appendChild(s),e.addEventListener("click",n=>{this.setVolume(n.detail.intersection.uv.x)}),this.setVolume(v.get("volume")??1)},setVolume:function(e){e>=.9&&(e=1),e<=.1&&(e=.1);let t=this.width*e,i=t/2;o.video.volume=e,v.set("volume",e),this.txt.setAttribute("value",`${Math.round(o.video.volume*100)}`),this.bar.setAttribute("position",`${i-this.width/2} 0 0.2`),this.bar.setAttribute("geometry",{width:t})}});AFRAME.registerComponent("btn-hide-controls",{init:function(){let e=this.el;e.addEventListener("click",()=>{e.sceneEl.systems.controls.hideControls()})}});AFRAME.registerComponent("btn-settings",{schema:{},init:function(){this.el.addEventListener("click",()=>{o.dialog.hasAttribute(S)?o.dialog.object3D.visible?o.dialog.getAttribute("dialog-utils").screen===S?(o.dialog.removeAttribute("clickable"),o.dialog.replaceChildren(),o.dialog.object3D.visible=!1):o.dialog.setAttribute(S,{reRender:"rerender"}):o.dialog.setAttribute(S,{reRender:"rerender"}):(o.dialog.setAttribute(S,""),o.dialog.object3D.visible=!0)})}});const o={ascene:document.querySelector("a-scene"),video:document.getElementById("video"),env:document.getElementById("env"),file:document.getElementById("fileInput"),cameraRig:document.getElementById("cameraRig"),controls:document.getElementById("controls"),events:document.getElementById("events"),settings:document.getElementById("settings"),videoState:document.getElementById("video-state"),dialog:document.getElementById("dialog")};