Skip to content

Commit 35b0fbc

Browse files
authored
Editor: Add color space options for background textures. (#30794)
* Editor: Add color space options for background textures. * Editor: Improve color space select.
1 parent b36d77d commit 35b0fbc

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

editor/js/Sidebar.Scene.js

+30
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,23 @@ function SidebarScene( editor ) {
181181
backgroundEquirectangularTexture.setDisplay( 'none' );
182182
backgroundRow.add( backgroundEquirectangularTexture );
183183

184+
const backgroundColorSpaceRow = new UIRow();
185+
backgroundColorSpaceRow.setDisplay( 'none' );
186+
backgroundColorSpaceRow.setMarginLeft( '120px' );
187+
188+
const backgroundColorSpace = new UISelect().setOptions( {
189+
190+
[ THREE.NoColorSpace ]: 'No Color Space',
191+
[ THREE.LinearSRGBColorSpace ]: 'srgb-linear',
192+
[ THREE.SRGBColorSpace ]: 'srgb',
193+
194+
} ).setWidth( '150px' );
195+
backgroundColorSpace.setValue( THREE.NoColorSpace );
196+
backgroundColorSpace.onChange( onBackgroundChanged );
197+
backgroundColorSpaceRow.add( backgroundColorSpace );
198+
184199
container.add( backgroundRow );
200+
container.add( backgroundColorSpaceRow );
185201

186202
const backgroundEquirectRow = new UIRow();
187203
backgroundEquirectRow.setDisplay( 'none' );
@@ -205,6 +221,7 @@ function SidebarScene( editor ) {
205221
backgroundColor.getHexValue(),
206222
backgroundTexture.getValue(),
207223
backgroundEquirectangularTexture.getValue(),
224+
backgroundColorSpace.getValue(),
208225
backgroundBlurriness.getValue(),
209226
backgroundIntensity.getValue(),
210227
backgroundRotation.getValue()
@@ -222,6 +239,16 @@ function SidebarScene( editor ) {
222239
backgroundEquirectangularTexture.setDisplay( type === 'Equirectangular' ? '' : 'none' );
223240
backgroundEquirectRow.setDisplay( type === 'Equirectangular' ? '' : 'none' );
224241

242+
if ( type === 'Texture' || type === 'Equirectangular' ) {
243+
244+
backgroundColorSpaceRow.setDisplay( '' );
245+
246+
} else {
247+
248+
backgroundColorSpaceRow.setDisplay( 'none' );
249+
250+
}
251+
225252
}
226253

227254
// environment
@@ -412,13 +439,16 @@ function SidebarScene( editor ) {
412439

413440
}
414441

442+
backgroundColorSpace.setValue( scene.background.colorSpace );
443+
415444
}
416445

417446
} else {
418447

419448
backgroundType.setValue( 'None' );
420449
backgroundTexture.setValue( null );
421450
backgroundEquirectangularTexture.setValue( null );
451+
backgroundColorSpace.setValue( THREE.NoColorSpace );
422452

423453
}
424454

editor/js/Viewport.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ function Viewport( editor ) {
495495

496496
// background
497497

498-
signals.sceneBackgroundChanged.add( function ( backgroundType, backgroundColor, backgroundTexture, backgroundEquirectangularTexture, backgroundBlurriness, backgroundIntensity, backgroundRotation ) {
498+
signals.sceneBackgroundChanged.add( function ( backgroundType, backgroundColor, backgroundTexture, backgroundEquirectangularTexture, backgroundColorSpace, backgroundBlurriness, backgroundIntensity, backgroundRotation ) {
499499

500500
scene.background = null;
501501

@@ -511,6 +511,9 @@ function Viewport( editor ) {
511511

512512
if ( backgroundTexture ) {
513513

514+
backgroundTexture.colorSpace = backgroundColorSpace;
515+
backgroundTexture.needsUpdate = true;
516+
514517
scene.background = backgroundTexture;
515518

516519
}
@@ -522,6 +525,8 @@ function Viewport( editor ) {
522525
if ( backgroundEquirectangularTexture ) {
523526

524527
backgroundEquirectangularTexture.mapping = THREE.EquirectangularReflectionMapping;
528+
backgroundEquirectangularTexture.colorSpace = backgroundColorSpace;
529+
backgroundEquirectangularTexture.needsUpdate = true;
525530

526531
scene.background = backgroundEquirectangularTexture;
527532
scene.backgroundBlurriness = backgroundBlurriness;

0 commit comments

Comments
 (0)