-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.js
64 lines (57 loc) · 1.65 KB
/
ui.js
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
53
54
55
56
57
58
59
60
61
62
63
64
import {
Component,
html
} from "https://unpkg.com/htm@2/preact/standalone.module.js";
import { getModelName } from "./store.js";
const isARQuickLookAvailable = document
.createElement("a")
.relList.supports("ar");
const isAndroid = /android/i.test(navigator.userAgent);
const ARLink = props => html`
<a ...${props} class="ar-link"><img src=""/></a>
`;
export class UI extends Component {
constructor({ store }) {
super();
store.subscribe(state => this.setState(state));
}
dispatch(state) {
this.props.store.dispatch(state);
}
render() {
const { showTitle, waiting, running } = this.state;
const showTutorial = !showTitle && !running;
const modelName = getModelName(this.state);
let quickLookButton = null;
if (isARQuickLookAvailable) {
const attrs = {
href: `./models/${modelName}.usdz`,
rel: "ar"
};
quickLookButton = html`
<${ARLink} ...${attrs} />
`;
}
if (isAndroid) {
attrs = {
href: `intent://${modelName}.glb#Intent;scheme=https;package=com.google.ar.core;action=android.intent.action.VIEW;S.browser_fallback_url=https://one-night-game-jam.github.io/omikuji-kun;end;`
};
quickLookButton = html`
<${ARLink} ...${attrs} />
`;
}
return html`
<div class="container">
<img
class="image ${showTitle ? "image--visible" : ""}"
src="./images/TAP_ME_TO_START.png"
/>
<img
class="image ${showTutorial ? "image--visible" : ""}"
src="./images/SHAKE_or_TAP_ME.png"
/>
${!showTitle && !waiting && !running && quickLookButton}
</div>
`;
}
}