-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
126 lines (121 loc) · 3.61 KB
/
index.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Sustainability Report</title>
<!-- Include A-Frame library -->
<script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
<!-- Include AR.js library for AR functionality -->
<script src="https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar.js"></script>
<style>
/* Styles for the loading overlay */
.arjs-loader {
height: 100%;
width: 100%;
position: absolute;
top: 0;
left: 0;
background-color: rgba(0, 0, 0, 0.8);
z-index: 9999;
display: flex;
justify-content: center;
align-items: center;
}
.arjs-loader div {
text-align: center;
font-size: 1.25em;
color: white;
}
</style>
</head>
<body style="margin: 0px; overflow: hidden;">
<!-- Loading overlay -->
<div class="arjs-loader">
<div>Loading, please wait...</div>
</div>
<!-- A-Frame scene setup -->
<a-scene
vr-mode-ui="enabled: false;"
renderer="logarithmicDepthBuffer: true;"
embedded
arjs="trackingMethod: best; sourceType: webcam; debugUIEnabled: false;"
>
<!-- Asset management system -->
<a-assets>
<!-- Video asset -->
<video
id="video"
src="video.mp4"
preload="auto"
response-type="arraybuffer"
loop
crossorigin
webkit-playsinline
playsinline
></video>
</a-assets>
<!-- AR marker -->
<a-marker type="pattern" url="pattern-logo.patt">
<!-- Video element in AR -->
<a-video
src="#video"
scale="1 1 1"
position="0 0 0"
rotation="-90 0 0"
class="clickable"
gesture-handler
></a-video>
</a-marker>
<!-- Camera entity -->
<a-entity camera></a-entity>
</a-scene>
<script>
window.onload = function() {
// Get references to DOM elements
const marker = document.querySelector("a-marker");
const video = document.querySelector("#video");
const videoEntity = document.querySelector("a-video");
const loader = document.querySelector(".arjs-loader");
// Remove the loader once the scene is loaded
document.querySelector('a-scene').addEventListener('loaded', function () {
loader.style.display = 'none';
});
// Play video and fade in when marker is found
marker.addEventListener("markerFound", function() {
video.play();
fadeIn(videoEntity);
});
// Pause video and fade out when marker is lost
marker.addEventListener("markerLost", function() {
video.pause();
fadeOut(videoEntity);
});
};
// Function to fade in an element
function fadeIn(element) {
let opacity = 0;
element.setAttribute("material", "opacity", 0);
const interval = setInterval(function() {
if (opacity < 1) {
opacity += 0.1;
element.setAttribute("material", "opacity", opacity);
} else {
clearInterval(interval);
}
}, 50);
}
// Function to fade out an element
function fadeOut(element) {
let opacity = 1;
const interval = setInterval(function() {
if (opacity > 0) {
opacity -= 0.1;
element.setAttribute("material", "opacity", opacity);
} else {
clearInterval(interval);
}
}, 50);
}
</script>
</body>
</html>