@@ -20,96 +20,89 @@ function SidebarProjectRenderer( editor ) {
2020 // Antialias
2121
2222 var antialiasRow = new UIRow ( ) ;
23- var antialiasBoolean = new UIBoolean ( config . getKey ( 'project/renderer/antialias' ) ) . onChange ( function ( ) {
24-
25- createRenderer ( ) ;
26-
27- } ) ;
23+ container . add ( antialiasRow ) ;
2824
2925 antialiasRow . add ( new UIText ( strings . getKey ( 'sidebar/project/antialias' ) ) . setWidth ( '90px' ) ) ;
26+
27+ var antialiasBoolean = new UIBoolean ( config . getKey ( 'project/renderer/antialias' ) ) . onChange ( createRenderer ) ;
3028 antialiasRow . add ( antialiasBoolean ) ;
3129
32- container . add ( antialiasRow ) ;
30+ // Physically Correct lights
3331
34- // Shadows
32+ var physicallyCorrectLightsRow = new UIRow ( ) ;
33+ container . add ( physicallyCorrectLightsRow ) ;
3534
36- var shadowsRow = new UIRow ( ) ;
37- var shadowsBoolean = new UIBoolean ( config . getKey ( 'project/renderer/shadows' ) ) . onChange ( function ( ) {
35+ physicallyCorrectLightsRow . add ( new UIText ( strings . getKey ( 'sidebar/project/physicallyCorrectLights' ) ) . setWidth ( '90px' ) ) ;
3836
39- currentRenderer . shadowMap . enabled = this . getValue ( ) ;
37+ var physicallyCorrectLightsBoolean = new UIBoolean ( config . getKey ( 'project/renderer/physicallyCorrectLights' ) ) . onChange ( function ( ) {
38+
39+ currentRenderer . physicallyCorrectLights = this . getValue ( ) ;
4040 signals . rendererUpdated . dispatch ( ) ;
4141
4242 } ) ;
43+ physicallyCorrectLightsRow . add ( physicallyCorrectLightsBoolean ) ;
44+
45+ // Shadows
46+
47+ var shadowsRow = new UIRow ( ) ;
48+ container . add ( shadowsRow ) ;
4349
4450 shadowsRow . add ( new UIText ( strings . getKey ( 'sidebar/project/shadows' ) ) . setWidth ( '90px' ) ) ;
51+
52+ var shadowsBoolean = new UIBoolean ( config . getKey ( 'project/renderer/shadows' ) ) . onChange ( updateShadows ) ;
4553 shadowsRow . add ( shadowsBoolean ) ;
4654
4755 var shadowTypeSelect = new UISelect ( ) . setOptions ( {
4856 0 : 'Basic' ,
4957 1 : 'PCF' ,
50- 2 : 'PCF ( Soft) ' ,
58+ 2 : 'PCF Soft' ,
5159 // 3: 'VSM'
52- } ) . setWidth ( '125px' ) . onChange ( function ( ) {
53-
54- currentRenderer . shadowMap . type = parseFloat ( this . getValue ( ) ) ;
55- signals . rendererUpdated . dispatch ( ) ;
56-
57- } ) ;
60+ } ) . setWidth ( '125px' ) . onChange ( updateShadows ) ;
5861 shadowTypeSelect . setValue ( config . getKey ( 'project/renderer/shadowType' ) ) ;
59-
6062 shadowsRow . add ( shadowTypeSelect ) ;
6163
62- container . add ( shadowsRow ) ;
63-
64- // Physically Correct lights
64+ function updateShadows ( ) {
6565
66- var physicallyCorrectLightsRow = new UIRow ( ) ;
67- var physicallyCorrectLightsBoolean = new UIBoolean ( config . getKey ( 'project/renderer/physicallyCorrectLights' ) ) . onChange ( function ( ) {
66+ currentRenderer . shadowMap . enabled = shadowsBoolean . getValue ( ) ;
67+ currentRenderer . shadowMap . type = parseFloat ( shadowTypeSelect . getValue ( ) ) ;
6868
69- currentRenderer . physicallyCorrectLights = this . getValue ( ) ;
7069 signals . rendererUpdated . dispatch ( ) ;
7170
72- } ) ;
73-
74- physicallyCorrectLightsRow . add ( new UIText ( strings . getKey ( 'sidebar/project/physicallyCorrectLights' ) ) . setWidth ( '90px' ) ) ;
75- physicallyCorrectLightsRow . add ( physicallyCorrectLightsBoolean ) ;
76-
77- container . add ( physicallyCorrectLightsRow ) ;
71+ }
7872
7973 // Tonemapping
8074
8175 var toneMappingRow = new UIRow ( ) ;
76+ container . add ( toneMappingRow ) ;
77+
78+ toneMappingRow . add ( new UIText ( strings . getKey ( 'sidebar/project/toneMapping' ) ) . setWidth ( '90px' ) ) ;
79+
8280 var toneMappingSelect = new UISelect ( ) . setOptions ( {
83- 0 : 'None ' ,
81+ 0 : 'No ' ,
8482 1 : 'Linear' ,
8583 2 : 'Reinhard' ,
8684 3 : 'Cineon' ,
8785 4 : 'ACESFilmic'
88- } ) . setWidth ( '120px' ) . onChange ( function ( ) {
89-
90- currentRenderer . toneMapping = parseFloat ( this . getValue ( ) ) ;
91- toneMappingExposure . setDisplay ( currentRenderer . toneMapping === 0 ? 'none' : '' ) ;
92- signals . rendererUpdated . dispatch ( ) ;
93-
94- } ) ;
86+ } ) . setWidth ( '120px' ) . onChange ( updateToneMapping ) ;
9587 toneMappingSelect . setValue ( config . getKey ( 'project/renderer/toneMapping' ) ) ;
96-
97- toneMappingRow . add ( new UIText ( strings . getKey ( 'sidebar/project/toneMapping' ) ) . setWidth ( '90px' ) ) ;
9888 toneMappingRow . add ( toneMappingSelect ) ;
9989
10090 var toneMappingExposure = new UINumber ( config . getKey ( 'project/renderer/toneMappingExposure' ) ) ;
10191 toneMappingExposure . setDisplay ( toneMappingSelect . getValue ( ) === '0' ? 'none' : '' ) ;
10292 toneMappingExposure . setWidth ( '30px' ) . setMarginLeft ( '10px' ) ;
10393 toneMappingExposure . setRange ( 0 , 10 ) ;
104- toneMappingExposure . onChange ( function ( ) {
94+ toneMappingExposure . onChange ( updateToneMapping ) ;
95+ toneMappingRow . add ( toneMappingExposure ) ;
10596
106- currentRenderer . toneMappingExposure = this . getValue ( ) ;
107- signals . rendererUpdated . dispatch ( ) ;
97+ function updateToneMapping ( ) {
10898
109- } ) ;
110- toneMappingRow . add ( toneMappingExposure ) ;
99+ toneMappingExposure . setDisplay ( toneMappingSelect . getValue ( ) === '0' ? 'none' : '' ) ;
111100
112- container . add ( toneMappingRow ) ;
101+ currentRenderer . toneMapping = parseFloat ( toneMappingSelect . getValue ( ) ) ;
102+ currentRenderer . toneMappingExposure = toneMappingExposure . getValue ( ) ;
103+ signals . rendererUpdated . dispatch ( ) ;
104+
105+ }
113106
114107 //
115108
@@ -129,32 +122,27 @@ function SidebarProjectRenderer( editor ) {
129122
130123 createRenderer ( ) ;
131124
132- // signals
125+
126+ // Signals
133127
134128 signals . editorCleared . add ( function ( ) {
135129
136130 currentRenderer . physicallyCorrectLights = false ;
137131 currentRenderer . shadowMap . enabled = true ;
138- currentRenderer . shadowMap . type = 1 ;
139- currentRenderer . toneMapping = 0 ;
132+ currentRenderer . shadowMap . type = THREE . PCFShadowMap ;
133+ currentRenderer . toneMapping = THREE . NoToneMapping ;
140134 currentRenderer . toneMappingExposure = 1 ;
141135
142- refreshRendererUI ( ) ;
143-
144- signals . rendererUpdated . dispatch ( ) ;
145-
146- } ) ;
147-
148- function refreshRendererUI ( ) {
149-
150136 physicallyCorrectLightsBoolean . setValue ( currentRenderer . physicallyCorrectLights ) ;
151137 shadowsBoolean . setValue ( currentRenderer . shadowMap . enabled ) ;
152138 shadowTypeSelect . setValue ( currentRenderer . shadowMap . type ) ;
153139 toneMappingSelect . setValue ( currentRenderer . toneMapping ) ;
154140 toneMappingExposure . setValue ( currentRenderer . toneMappingExposure ) ;
155141 toneMappingExposure . setDisplay ( currentRenderer . toneMapping === 0 ? 'none' : '' ) ;
156142
157- }
143+ signals . rendererUpdated . dispatch ( ) ;
144+
145+ } ) ;
158146
159147 signals . rendererUpdated . add ( function ( ) {
160148
0 commit comments