-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
174 lines (151 loc) · 7.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
170
171
172
173
174
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>Selfie 360</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel='stylesheet' type='text/css' media='screen' href='style/selfie-anywhere.css'>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script src="//code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.2"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/body-pix@2.0"></script>
<script src='js/html2canvas.min.js'></script>
<script type="text/javascript" src="https://unpkg.com/webcam-easy/dist/webcam-easy.min.js"></script>
<script src='js/webcam-ui-lib.js'></script>
<script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
<script src="https://supereggbert.github.io/aframe-htmlembed-component/dist/build.js"></script>
<script src="https://rawgit.com/donmccurdy/aframe-extras/master/dist/aframe-extras.loaders.min.js"></script>
</head>
<body>
<div id="intro">
<div id="title">
<p class="environment" id="title-format">SELFIE <img style="width: 200px;" src="images/logo.png"></p>
<p class="environment"><button onclick="start()">Start</button></p>
</div>
<div class="environment">
<p style="color: #25448b; font-size:22px;">Add Link to 360 Photo:</p>
<!-- Load from link -->
<input type="text" id="myUrl" value="please enter url"><button onclick="loadphoto()">Add</button>
<!-- Load from file -->
<p style="color: #25448b; font-size:22px; margin-top:5%;">Upload 360 Photo:</p>
<input type='file' id="loader" />
</div>
</div>
<a-scene vr-mode-ui="enabled: false">
<a-camera id="camera" cursor="rayOrigin: mouse"></a-camera>
<a-sky id="photobackground" src="" rotation="0 0 0"></a-sky>
<a-gltf-model id="3dmodel" src="#linktomodel" position="-1 0.5 -3" scale="0.3 0.3 0.3"></a-gltf-model>
<main id="selfie-anywhere-app">
<div class="form-control webcam-start" id="webcam-control">
<label class="form-switch">
<input type="checkbox" id="webcam-switch">
<i></i>
<span id="webcam-caption">Start Camera</span>
</label>
<button id="zoomIn" onclick="zoomIn();">Zoom In</button>
<button id="zoomOut" onclick="zoomOut();">Zoom Out</button>
</div>
<div id="errorMsg" class="col-12 alert-danger d-none">
Fail to start camera <br />
Please allow permision to access camera <br />
If you are browsing through social media built in browsers, <br />
you would need to open the page in Sarafi (iPhone)/ Chrome (Android)
</div>
<div class="row m-0 selfie-container">
<div class="col-8 offset-2 col-sm-5 offset-sm-4 col-lg-3 offset-lg-5">
<img src="images/selfie-outline.png" alt="selfie">
</div>
</div>
<div class="md-modal md-effect-12" style="z-index:9999;">
<div id="app-panel" class="app-panel md-content">
<div id="webcam-container" class="webcam-container d-none">
<video id="webcam" autoplay playsinline width="640" height="480"></video>
<div id="selfie-container">
<div id="background-container">
<div class="spinner-border d-none" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
<canvas id="canvasPerson" width="640" height="480"></canvas>
</div>
<div class="flash"></div>
<!--</div>
<img id="arrowLeft" src="images/arrow-left.png">
<img id="arrowRight" src="images/arrow-right.png">
-->
<div id="cameraControls" class="cameraControls">
<a href="#" id="exit-app" title="Exit App" class="d-none"><i
class="material-icons">exit_to_app</i></a>
<a href="#" id="take-photo" title="Take Photo"><i class="material-icons">camera_alt</i></a>
<a href="#" id="download-photo" download="selfie.png" target="_blank" title="Save Photo"
class="d-none"><i class="material-icons">file_download</i></a>
<a href="#" id="resume-camera" title="Resume Camera" class="d-none"><i
class="material-icons">camera_front</i></a>
</div>
</div>
</div>
<div class="md-overlay"></div>
</main>
</a-scene>
<script>
</script>
<script src='js/selfie-anywhere.js'></script>
<script>
// Load 360 image by link, hide intro page
function start() {
document.getElementById("title").style.display = "none"; // hide intro overlay
}
function loadphoto() {
var source = document.getElementById("myUrl").value;
document.getElementById('photobackground').setAttribute('src', source);
document.getElementById("intro").style.display = "none"; // hide intro overlay
}
// Upload local file, hid intro page
function myURL2(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#photobackground').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]); // convert to base64 string
document.getElementById("intro").style.display = "none"; // hide intro overlay
}
}
$("#loader").change(function () {
myURL2(this);
});
</script>
<script>
/*
// Load 3d model
var threedmodel = document.getElementById('3dmodel');
threedmodel.setAttribute('gltf-model',
'https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Duck/glTF/Duck.gltf');
*/
//Zoom in
function zoomIn() {
var mycam = document.getElementById('camera').getAttribute('camera');
var finalZoom = document.getElementById('camera').getAttribute('camera').zoom + 1;
if (finalZoom < 1)
finalZoom = 1;
if (finalZoom > 5)
finalZoom = 5;
mycam.zoom = finalZoom;
document.getElementById('camera').setAttribute('camera', mycam);
};
// Zoom out
function zoomOut() {
var mycam = document.getElementById('camera').getAttribute('camera');
var finalZoom = document.getElementById('camera').getAttribute('camera').zoom - 1;
if (finalZoom < 1)
finalZoom = 1;
if (finalZoom > 5)
finalZoom = 5;
mycam.zoom = finalZoom;
document.getElementById('camera').setAttribute('camera', mycam);
};
</script>
</body>
</html>