export default { uuid: () => { let S4 = () => { return (((1+Math.random())*0x10000)|0).toString(16).substring(1); } return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4()); }, vec3UE4ToBABYLON(vec) { return BABYLON.Vector3.TransformCoordinates( new BABYLON.Vector3(vec.x, vec.y, vec.z), BABYLON.Matrix.FromArray([ -0.01, 0, 0, 0, 0, 0, 0.01, 0, 0, 0.01, 0, 0, 0, 0, 0, 1 ]) ) }, vec3BABYLONToUE4(vec) { return BABYLON.Vector3.TransformCoordinates( new BABYLON.Vector3(vec.x, vec.y, vec.z), BABYLON.Matrix.FromArray([ -100, 0, 0, 0, 0, 0, 100, 0, 0, 100, 0, 0, 0, 0, 0, 1 ]) ) }, 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) ) } }