-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
190 lines (169 loc) · 6.26 KB
/
Copy pathindex.html
File metadata and controls
190 lines (169 loc) · 6.26 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
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Streaming viewer</title>
<link rel="icon" type="image/x-icon" href="favicon.ico">
<style>
html, body {
padding:0;
margin:0;
height: 100%;
}
iframe {
position: absolute;
bottom: 0px;
left: 0px;
height: 100%;
width: 500px;
background: white;
padding: 0px;
margin: 0px;
border: 0px;
}
webots-view {
position: absolute!important;
left: 500px;
width: calc(100% - 500px);
border: 0px;
margin: 0px;
min-width: 320px;
overflow-x:hidden;
}
.menu-button .arrow-right{
border: solid white;
border-width: 0 2px 2px 0;
display: inline-block;
padding: 4px;
transform: rotate(-45deg);
-webkit-transform: rotate(-45deg);
position: absolute;
top: calc(50% - 5px);
left: calc(50% - 10px);
pointer-events: none;
}
.menu-button .arrow-left{
border: solid white;
border-width: 0 2px 2px 0;
display: inline-block;
padding: 4px;
transform: rotate(135deg);
-webkit-transform: rotate(135deg);
position: absolute;
top: calc(50% - 5px);
left: calc(50% - 5px);
pointer-events: none;
}
.menu-button {
position: absolute;
top:calc(50% - 15px);
left: 500px;
width: 26px;
height: 52px;
border-top-right-radius: 24px;
border-bottom-right-radius: 24px;
background-color: #333;
border-color: transparent;
z-index: 2;
display: none;
}
</style>
</head>
<body>
<button class="menu-button" id="menuButton" title="Show/Hide the robot window."><div class="arrow-left" id="arrow"></div></button>
<script type="module">
import WebotsView from "https://cyberbotics.com/wwi/R2022b/WebotsView.js";
let showRobotWindow = true;
let webotsView = new WebotsView();
webotsView.id = 'webotsView';
webotsView.showQuit = false;
webotsView.showReset = false;
webotsView.showStep = false;
webotsView.showRobotWindow = false;
document.body.appendChild(webotsView);
webotsView.onready = displayRobotWindow;
webotsView.connect('https://simulation.webots.cloud/1999/session?url=https://github.com/cyberbotics/artificialbrains/blob/main/worlds/e-puck.wbt', undefined, undefined, undefined, 900);
function displayRobotWindow() {
if (webotsView._view && webotsView._view.x3dScene && webotsView._view.x3dScene.prefix) {
let serverUrl = webotsView._view.x3dScene.prefix;
let url = serverUrl + 'robot_windows/simple_e-puck/simple_e-puck.html?name=e-puck';
let iframe = document.createElement('iframe');
iframe.src = url;
iframe.id = 'robotWindow',
document.body.appendChild(iframe)
if (document.getElementById('fullscreen-button'))
document.getElementById('fullscreen-button').onclick = () => toggleRobotComponentFullScreen();
if (document.getElementById('windowed-button')) {
document.getElementById('windowed-button').onclick = () => toggleRobotComponentFullScreen();
document.getElementById('windowed-button').style.display = 'none';
}
const menuButton = document.getElementById('menuButton');
if (menuButton)
menuButton.style.display = 'block';
autoPlay();
if (document.getElementsByClassName('menu-button').length !== 0)
document.getElementsByClassName('menu-button')[0].onclick = () => toggleDeviceComponent();
}else setTimeout(function () {
displayRobotWindow()
}, 100);
}
function toggleRobotComponentFullScreen(robot) {
if (document.fullscreenElement) {
document.getElementById('fullscreen-button').style.display = '';
document.getElementById('windowed-button').style.display = 'none';
if (document.exitFullscreen)
document.exitFullscreen();
} else {
document.getElementById('fullscreen-button').style.display = 'none';
document.getElementById('windowed-button').style.display = '';
if (document.body.requestFullscreen) {
document.body.requestFullscreen();
}
}
}webotsView
function autoPlay(){
if (webotsView.toolbar)
webotsView.toolbar._triggerPlayPauseButton();
else
setTimeout(() => autoPlay(), 100);
}
function showButton() {
if (document.getElementsByClassName('menu-button').length !== 0)
document.getElementsByClassName('menu-button')[0].style.display = '';
}
function hideButton() {
if (document.getElementsByClassName('menu-button').length !== 0)
document.getElementsByClassName('menu-button')[0].style.display = 'none';
}
function toggleDeviceComponent() {
showRobotWindow = !showRobotWindow;
updateRobotWindowDimension();
let arrow = document.getElementById('arrow');
if (arrow) {
if (arrow.className === 'arrow-right')
arrow.className = 'arrow-left';
else if (arrow.className === 'arrow-left')
arrow.className = 'arrow-right';
}
}
function updateRobotWindowDimension() {
const robotWindow = document.getElementById('robotWindow');
const webotsView = document.getElementById('webotsView');
const menuButton = document.getElementById('menuButton');
if (showRobotWindow === true) {
robotWindow.style.display = '';
webotsView.style.width = 'calc(100% - 500px)';
webotsView.style.left = '500px'
menuButton.style.left = '500px';
} else {
robotWindow.style.display = 'none';
webotsView.style.width = '100%';
webotsView.style.left = '0px';
menuButton.style.left = '0px';
}
webotsView.resize();
}
</script>
</body>
</html>