-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
82 lines (69 loc) · 2.63 KB
/
index.html
File metadata and controls
82 lines (69 loc) · 2.63 KB
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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="https://cdn.jsdelivr.net/npm/mind-ar-js@1.2.5/dist/mindar-image.prod.js"></script>
<script src="https://aframe.io/releases/1.5.0/aframe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/mind-ar@1.2.5/dist/mindar-image-aframe.prod.js"></script>
</head>
<body>
<a-scene mindar-image="imageTargetSrc: ./targets.mind;" vr-mode-ui="enabled: false" device-orientation-permission-ui="enabled: false">
<!-- Asset loader for video 1 -->
<a-assets>
<video id="my-image" autoplay loop muted playsinline crossorigin="anonymous">
<source src="assets/vid1.mp4" type="video/mp4" />
</video>
</a-assets>
<!-- Asset loader for video 2 -->
<a-assets>
<video id="my-image2" autoplay loop muted playsinline crossorigin="anonymous">
<source src="assets/vid2.mp4" type="video/mp4" />
</video>
</a-assets>
<!-- Camera -->
<a-camera position="0 0 0" look-controls="enabled: false"></a-camera>
<!-- Tracked image target for vid1 -->
<a-entity mindar-image-target="targetIndex: 0">
<a-plane
position="0 0 0"
width="1"
height="0.562"
material="shader: flat; src: #my-image"
></a-plane>
</a-entity>
<!-- Tracked image target for vid2 -->
<a-entity mindar-image-target="targetIndex: 1">
<a-plane
position="0 0 0"
width="1"
height="0.562"
material="shader: flat; src: #my-image2"
></a-plane>
</a-entity>
</a-scene>
<script>
// Play video on click
window.addEventListener("click", () => {
const vid1 = document.querySelector("#my-image");
const vid2 = document.querySelector("#my-image2");
if (vid1 && vid1.paused) {
vid1.play().catch((err) => console.log("Video 1 play error:", err));
}
if (vid2 && vid2.paused) {
vid2.play().catch((err) => console.log("Video 2 play error:", err));
}
});
// Play video on page load
window.addEventListener("DOMContentLoaded", () => {
const vid1 = document.querySelector("#my-image");
const vid2 = document.querySelector("#my-image2");
if (vid1 && vid1.paused) {
vid1.play().catch((err) => console.log("Initial video 1 play error:", err));
}
if (vid2 && vid2.paused) {
vid2.play().catch((err) => console.log("Initial video 2 play error:", err));
}
});
</script>
</body>
</html>