-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnimbus_ui.js
165 lines (141 loc) · 4.76 KB
/
nimbus_ui.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
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
import { Nimbus3DRenderSingle } from './nimbus_3D.js';
import { NimbusRPC } from './nimbusRPC.js';
// Variables
// resolution height and width
var resolutionHeight = 288;
var resolutionWidth = 352;
var animationDT = 666;
var nimbusRPC = new NimbusRPC(location.host);
// On document loaded
$( document ).ready(function() {
// connect clicks
$( 'button.toggleFullScreen' ).click( function() { toggleFullScreen( $( this ) ) });
$( 'button#globalSettingsButton' ).click( function() { toggleGlobalSettings() });
$( 'button#AutoExposureButton' ).click( function() { toggleAutoExposure() });
$( 'button#HDRButton' ).click( function() { toggleHDR() });
$( 'button#showInfoButton' ).click( function() { toggleTopInfos() });
});
var switchStatus = false;
$("#HDRSwitch").on('change', function() {
nimbusRPC.getExposureMode().then( ExposureMode => {
if(ExposureMode == 1){
document.getElementById("hdrSlider").disabled = true
nimbusRPC.setExposureMode(0);
HDRSwitch.checked=0
}
else if(ExposureMode == 3){
document.getElementById("hdrSlider").disabled = true
nimbusRPC.setExposureMode(2);
HDRSwitch.checked=0
}
else if(ExposureMode == 0){
nimbusRPC.setExposureMode(1);
document.getElementById("hdrSlider").disabled = false
HDRSwitch.checked=1
}
else if(ExposureMode == 2){
nimbusRPC.setExposureMode(3);
document.getElementById("hdrSlider").disabled = false
HDRSwitch.checked=1
}
})
});
$("#AutoExposureSwitch").on('change', function() {
nimbusRPC.getExposureMode().then( ExposureMode => {
if(ExposureMode == 2){
nimbusRPC.setExposureMode(0);
AutoExposureSwitch.checked=0
}
else if(ExposureMode == 3){
nimbusRPC.setExposureMode(1);
AutoExposureSwitch.checked=0
}
else if(ExposureMode == 0){
nimbusRPC.setExposureMode(2);
AutoExposureSwitch.checked=1
}
else if(ExposureMode == 1){
nimbusRPC.setExposureMode(3);
AutoExposureSwitch.checked=1
}
})
});
function checkExposureMode(){
nimbusRPC.getExposureMode().then( ExposureMode => {
if(ExposureMode == 0){
AutoExposureSwitch.checked=0
document.getElementById("hdrSlider").disabled = true
HDRSwitch.checked=0
}
else if(ExposureMode == 1){
AutoExposureSwitch.checked=0
document.getElementById("hdrSlider").disabled = false
HDRSwitch.checked=1
}
else if(ExposureMode == 2){
AutoExposureSwitch.checked=1
document.getElementById("hdrSlider").disabled = true
HDRSwitch.checked=0
}
else if(ExposureMode == 3){
AutoExposureSwitch.checked=1
document.getElementById("hdrSlider").disabled = false
HDRSwitch.checked=1
}
})
}
function toggleGlobalSettings() {
checkExposureMode()
$( '#globalSettingsContainer' ).slideToggle( animationDT );
}
function toggleTopInfos() {
$( '#infoContainer' ).slideToggle( animationDT );
}
function toggleFullScreen( button ) {
var NB3D_docElement = document.getElementById( 'container3D' );
var parentContainer = button.parent( '.viewContainer' )
var n3DRender = Nimbus3DRenderSingle.getInstance(NB3D_docElement);
console.log(n3DRender);
if( parentContainer.hasClass( 'fullScreen' ) ) {
parentContainer.removeClass( 'fullScreen' );
$( 'h1' ).show();
parentContainer.siblings( '.viewContainer' ).show();
parentContainer.height( resolutionHeight );
parentContainer.width( resolutionWidth );
var canvas = parentContainer.children( 'canvas' );
canvas.height( resolutionHeight );
canvas.width( resolutionWidth );
n3DRender.resize(resolutionWidth, resolutionHeight);
button.css( 'position', 'absolute' );
$('html, body').css( {
overflow: 'inherit',
height: 'inherit'
});
button.removeClass( 'toNormal' );
}
else {
parentContainer.addClass( 'fullScreen' );
$( 'h1' ).hide();
parentContainer.siblings( '.viewContainer' ).hide();
parentContainer.height( $( window ).height() );
parentContainer.width( $( window ).width() );
var parentHfactor = parentContainer.innerHeight() / resolutionHeight;
var parentWfactor = parentContainer.innerWidth() / resolutionWidth;
var canvas = parentContainer.children( 'canvas' );
n3DRender.resize($( window ).width(), $( window ).height());
if( parentHfactor < parentWfactor ) {
canvas.height( parentContainer.innerHeight() );
canvas.width( resolutionWidth * parentHfactor );
}
else {
canvas.height( resolutionHeight * parentWfactor );
canvas.width( parentContainer.innerWidth() );
}
button.css( 'position', 'fixed' );
$('html, body').css( {
overflow: 'hidden',
height: '100%'
});
button.addClass( 'toNormal' );
}
}