-
Notifications
You must be signed in to change notification settings - Fork 10
/
theta_360.html
98 lines (87 loc) · 3.11 KB
/
theta_360.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
<!DOCTYPE html>
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<title>THETA Viewer</title>
<style>
body {
background-color: #ffffff;
margin: 0px;
overflow: hidden;
}
</style>
<!-- The MIT License (MIT) Copyright (c) 2015 mganeko -->
</head>
<body style="margin: 0px; padding:0px;">
<div id="container" style="position:absolute; top: 0px; left:0px; width:100%; "></div>
<div style="position:absolute; top:0px; left:4px; background-color: #fcfcfc; opacity: 0.9; padding: 2px;">
<button id='start_button' onclick="startViewer();">start</button>
<button id='stop_button' onclick="stopViewer();">stop</button>
<input type="checkbox" id="sense_orientation_check" _not_checked="checked" onclick="toggleSenseOrientation()">Sense Orientation</input>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r73/three.min.js"></script>
<script src="js/theta_gl.js"></script>
<script type="text/javascript">
//var RTCPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection;
//var RTCSessionDescription = window.RTCSessionDescription || window.mozRTCSessionDescription;
//var RTCIceCandidate = window.RTCIceCandidate || window.mozRTCIceCandidate;
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
var cameraStream = null;
var cameraURL = null;
function startViewer() {
navigator.getUserMedia({video: true},
function(stream) {
cameraStream = stream;
cameraURL = window.URL.createObjectURL(stream);
THETA_GL.setVideoSrc(cameraURL);
THETA_GL.startAnimate();
},
function(err) {
console.error('getUserMedia Error:', err);
}
);
}
function stopViewer() {
THETA_GL.stopVideoSrc();
if (cameraURL) {
window.URL.revokeObjectURL(cameraURL);
cameraURL = null;
}
if (cameraStream) {
stopStream(cameraStream);
cameraStream = null;
}
}
function stopStream(stream) {
var tracks = stream.getTracks();
if (! tracks) {
console.warn('NO tracks');
return;
}
for (index in tracks) {
tracks[index].stop();
}
}
var senseOrientationCheckElement = document.getElementById('sense_orientation_check');
function isSenseOrientationChecked() {
if (! senseOrientationCheckElement) {
return false;
}
if (senseOrientationCheckElement.checked) {
return true;
}
else {
return false;
}
}
function toggleSenseOrientation() {
var senseOrientation = isSenseOrientationChecked();
console.log('isSenseOrientationChecked() :' + senseOrientation);
THETA_GL.followOrientation(senseOrientation);
}
THETA_GL.init(/* divId */ 'container', /* autoResuze */ true, /* debug */ false);
</script>
</body>
</html>