-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathpreview.html
52 lines (50 loc) · 2.04 KB
/
preview.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<html>
<head>
<title>Digital Bacon - Preview</title>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="theme-color" content="#ffebfd"/>
<link rel="apple-touch-icon" sizes="180x180" href="/images/favicons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicons/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicons/favicon-32x32.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="stylesheet" href="./css/app.css">
<link rel="stylesheet" href="https://fonts.cdnfonts.com/css/montserrat">
<!-- SHIM FOR WEBRTC CAUSE FIREFOX IS OLD MAN -->
<script async src="https://cdnjs.cloudflare.com/ajax/libs/webrtc-adapter/8.2.0/adapter.min.js"></script>
<script type="importmap">
{
"imports": {
"DigitalBacon": "/scripts/core/DigitalBacon.js",
"three": "/node_modules/three/build/three.module.js"
}
}
</script>
</head>
<body>
<div id="container">
<h1 style="color: #4723D9; padding-top: 24px;">Please wait for your project to load</h1>
</div>
<script type="module">
import { setup } from 'DigitalBacon';
let messageReceived = false;
let projectReceived = false;
window.addEventListener('message', (event) => {
if(!event.data || !event.data.topic) return;
messageReceived = true;
if(event.data.topic == 'PREVIEW') {
event.source.postMessage('READY_FOR_PREVIEW_PROJECT', '*');
} else if(event.data.topic == 'PREVIEW_PROJECT') {
if(projectReceived) {
console.error("ERROR: Received PREVIEW_PROJECT message more than once");
return;
}
projectReceived = true;
let blob = event.data.blob;
let params = { projectFilePath: blob };
setup("container", params);
}
});
setTimeout(() => { if(!messageReceived) window.location = '/app'; },5000);
</script>
</body>
</html>