-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathar0804-ui-dom-button.html
95 lines (82 loc) · 2.75 KB
/
ar0804-ui-dom-button.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<!-- Correcting zooming issue -->
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<title>WebAR: UI using CSS</title>
<!-- Library untuk VR membangun 3D -->
<script src="./js/aframe/aframe.min.js"></script>
<!-- Library untuk AR yang melakukan pengenalan marker dan menyematkan kamera-->
<script src="./js/arjs/aframe-ar.js"></script>
<style>
/* Mengatur posisi elemen pada halaman */
#UI {
position: fixed;
top: 1rem;
left: 1rem;
}
/* Styling */
#UI {
font-family: Arial, Helvetica, sans-serif;
font-size: 2em;
font-weight: 400;
text-align: center;
color: orange;
background-color: blue;
display: block;
width: 10em;
}
.buttons {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 5em;
display: flex;
justify-content: center;
align-items: center;
z-index: 10;
}
.say-hi-button {
padding: 0.25em;
border-radius: 4px;
border: none;
background: white;
color: black;
width: 4em;
height: 2em;
}
</style>
</head>
<body style="margin : 0px; overflow: hidden;">
<a-scene embedded vr-mode-ui="enabled: false" arjs='debugUIEnabled: false;'>
<!-- add a hiro marker-->
<a-marker preset="hiro">
<a-box position="0 0.5 0" material="color: green; opacity: 0.5;">
<a-text value="Marker Hiro" position="0 0.55 0" rotation="-90 0 0" color="magenta" align="center"></a-text>
</a-box>
</a-marker>
<!-- add a simple camera -->
<a-entity camera></a-entity>
</a-scene>
<!-- UI Element outside a-scene -->
<div id="UI">Gunakan marker hiro</div>
<div class="buttons">
<button class="say-hi-button">SAY HI!</button>
</div>
<script>
window.onload = function() {
document
.querySelector(".say-hi-button")
.addEventListener("click", function() {
// here you can change also a-scene or a-entity properties, like
// changing your 3D model source, size, position and so on
// or you can just open links, trigger actions...
alert("Hi there!");
});
};
</script>
<!-- reference: https://ar-js-org.github.io/AR.js-Docs/ui-events/ -->
</body>
</html>