This repository has been archived by the owner on Mar 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.js
58 lines (52 loc) · 2.15 KB
/
main.js
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
import Store from './store.js';
import createCameraView from './views/camera-view.js';
import createBatteryLowView from './views/battery-low-view.js';
import createBatteryChargingView from './views/battery-charging-view.js';
import CozmoController from './controllers/cozmo-controller.js';
import createMouseController from './controllers/mouse-controller.js';
import createKeyboardController from './controllers/keyboard-controller.js';
import createTouchController from './controllers/touch-controller.js';
import createGyroscopeController from './controllers/gyroscope-controller.js';
import createFullscreenController from './controllers/fullscreen-controller.js';
import createVisibilityChangeController from './controllers/visibilitychange-controller.js';
import createSocket from './socket.js';
window.addEventListener('load', () => {
const dependencies = {
env: {
SERVER: process.env.SERVER || 'localhost:5001',
HTTP: process.env.SSL === 'yes' ? 'https' : 'http',
WS: process.env.SSL === 'yes' ? 'wss' : 'ws',
},
store: new Store({
connected: false,
isFreeplayEnabled: false,
isHeadlightEnabled: false,
isShiftDown: 0,
isAltDown: 0,
isCtrlDown: 0,
batteryVoltage: 4.5,
isCharging: false,
isFalling: false,
isPickedUp: false,
}),
}
dependencies.cozmoController = new CozmoController(dependencies)
createCameraView(dependencies);
createBatteryLowView(dependencies);
createBatteryChargingView(dependencies);
createMouseController(dependencies);
createKeyboardController(dependencies);
createTouchController(dependencies);
createGyroscopeController(dependencies);
createFullscreenController(dependencies);
createVisibilityChangeController(dependencies);
dependencies.socket = createSocket(dependencies);
// On mobile, clicking and holding opens the context menu,
// Since our controls require holding we should disable the context menu.
document.addEventListener('contextmenu', event => {
event.preventDefault();
return false
})
// Disable IOS Safari's bouncing and overflow
document.addEventListener('touchmove', event => event.preventDefault())
});