forked from itzzmeakhi/Invitation-AR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
169 lines (122 loc) · 6.6 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<!DOCTYPE html>
<html>
<head>
<title> AR Invitation </title>
<meta name="viewport" content="width=device-width,height=device-height">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="https://aframe.io/releases/0.8.2/aframe.min.js"></script>
<script src="https://cdn.rawgit.com/jeromeetienne/AR.js/1.5.5/aframe/build/aframe-ar.js"></script>
<script>
// Invitation Video Handler
AFRAME.registerComponent('video-vidhandler', {
init: function() {
console.log('video init entered');
this.toggle = false;
this.vid = document.querySelector("#invitation");
this.vid.pause();
},
tick: function() {
if (this.el.object3D.visible == true) {
if (!this.toggle) {
this.toggle = true;
this.vid.play();
}
} else {
this.toggle = false;
this.vid.pause();
}
}
});
// Count down Timer and Countdown Timer Component
AFRAME.registerComponent('clock-text', {
init: function() {
console.log('Timer init entered');
var el = this.el;
this.ready = false;
el.addEventListener('textfontset', function() {
this.ready = true;
}.bind(this));
},
tick: function() {
var el = this.el;
if (!this.ready) {
return;
}
var endTime = new Date("May 29, 2020 00:54:00").getTime();
var timeRem;
var timer = setInterval(function() {
var currTime = new Date().getTime();
var diff = endTime - currTime;
if(diff > 0) {
var days = Math.floor(diff / (1000 * 60 * 60 * 24));
var hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var mins = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60));
var secs = Math.floor((diff % (1000 * 60)) / 1000);
//console.log(days, hours, mins, secs);
var timeRem = days + " days " + hours + " hrs " + mins + " mins " + secs + " secs ";
//console.log(timeRem);
} else {
var timeRem = "Finally! The day has come.";
}
el.setAttribute('value', timeRem);
}, 1000);
}
});
// Mappoint component
AFRAME.registerComponent('mappoint-handler', {
init: function() {
//console.log("I was triggered");
const marker3 = document.querySelector("#marker3");
const imgMap = document.querySelector("#img-map");
marker3.addEventListener('click', function(ev, target) {
const intersectedElement = ev && ev.detail && ev.detail.intersectedEl;
if (imgMap && intersectedElement === imgMap) {
console.log("Clicked");
document.location.href = "https://goo.gl/maps/gRsth6SHo5AgwMbT7";
}
});
}
});
</script>
</head>
<body>
<a-scene id="scene" arjs='trackingMethod: best; debugUIEnabled: false;' vr-mode-ui="enabled: false" ar-template >
<a-assets>
<!-- Invitation Video -->
<video preload="none" id="invitation" response-type="arraybuffer" loop="false" crossorigin webkit-playsinline playsinline controls>
<source src="videos/invitation.mp4">
</video>
<!-- Map point Image -->
<img id="map-point" src="images/map-navigate.jpg">
<!-- Texture Image -->
<img id="texture" src="images/texture.jpg">
</a-assets>
<!-- Invitation Video Marker -->
<a-marker id="marker1" type='pattern' url='markers/invi-pattern-marker.patt' video-vidhandler>
<!--<a-box position='0 0 0' material='color: red;'></a-box>-->
<a-plane scale = "4 2" position='0 0.1 0' rotation="-90 0 0" material='transparent:true;src:#invitation' controls></a-plane>
<!--<a-entity text="font: https://cdn.aframe.io/fonts/mozillavr.fnt; value: Fun Moments"></a-entity>-->
</a-marker>
<!-- Count down Timer Marker -->
<a-marker id="marker2" type='pattern' url='markers/timer-pattern-marker.patt'>
<!--<a-box position='0 0 0' material='color: red;'></a-box>-->
<!--<a-plane scale = "4 2" position='0 0.1 0' rotation="-90 0 0" material='transparent:true;src:#invitation' controls></a-plane>-->
<!--<a-entity text="font: https://cdn.aframe.io/fonts/mozillavr.fnt; value: Fun Moments"></a-entity>-->
<a-plane scale="2 1" position="0 0.1 0" rotation="-90 0 0" src="#texture">
<a-text id="timer" clock-text value="00:00:00:00" width="1.5" height="1" position="-0.451 0.041 0.000" color="#FFFFFF"></a-text>
</a-plane>
</a-marker>
<!-- Map Location Marker -->
<a-marker id="marker3" type='pattern' url='markers/map-pattern-marker.patt' emitevents="true" cursor="rayOrigin: mouse" mappoint-handler>
<!--<a-box position='0 0 0' material='color: red;'></a-box>-->
<a-plane id="img-map" scale = "2 2" position='0 0.1 0' rotation="-90 0 0" material='transparent:true;src:#map-point'></a-plane>
<!--<a-entity text="font: https://cdn.aframe.io/fonts/mozillavr.fnt; value: Fun Moments"></a-entity>-->
</a-marker>
<!-- Camera -->
<a-entity camera></a-entity>
</a-scene>
</body>
</html>