export default { postData: (url, data) => { return fetch(url, { body: JSON.stringify(data), // cache: 'no-cache', // credentials: 'same-origin', headers: { // 'user-agent': 'Mozilla/4.0 MDN Example', 'content-type': 'application/json' }, method: 'POST', // mode: 'cors', // redirect: 'follow', // referrer: 'no-referrer', }) .then(response => response.json()) }, createVideoElement: (path) => { return new Promise((resolve, reject) => { let videoName = path.split("/")[path.split("/").length-1].split(".")[0] let oldVideo = document.getElementById(videoName) if(oldVideo) { oldVideo.currentTime = 0 oldVideo.isLoaded = true resolve(oldVideo) } else { let video = document.createElement("video") video.src = path video.id = videoName video.crossOrigin = "anonymous" video.playsinline = "playsinline" video.autoplay = "autoplay" video.muted = "muted" document.getElementById("videoTextureBox").appendChild(video) video.onloadeddata = () => { resolve(video); } } }); }, createVideoElement0: (path) => { let videoName = path.split("/")[path.split("/").length-1].split(".")[0] let oldVideo = document.getElementById(videoName) if(oldVideo) { oldVideo.currentTime = 0 oldVideo.isLoaded = true return oldVideo } let video = document.createElement("video") video.src = path video.id = videoName video.crossOrigin = "anonymous" video.playsinline = "playsinline" video.autoplay = "autoplay" video.muted = "muted" document.getElementById("videoTextureBox").appendChild(video) return video }, getLengthBetweenVec3: (v1, v2) => { return Math.sqrt( (v1.x - v2.x) * (v1.x - v2.x) + (v1.y - v2.y) * (v1.y - v2.y) + (v1.z - v2.z) * (v1.z - v2.z) ) } }