Skip to content

Commit

Permalink
env: insync w. bkg + recoverable from history (#28300)
Browse files Browse the repository at this point in the history
  • Loading branch information
ycw committed May 7, 2024
1 parent 64b0a7c commit 6d53d23
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
17 changes: 16 additions & 1 deletion editor/js/Sidebar.Scene.js
Expand Up @@ -424,7 +424,11 @@ function SidebarScene( editor ) {

if ( scene.environment ) {

if ( scene.environment.mapping === THREE.EquirectangularReflectionMapping ) {
if ( scene.background && scene.background.isTexture && scene.background.uuid === scene.environment.uuid ) {

environmentType.setValue( 'Background' );

} else if ( scene.environment.mapping === THREE.EquirectangularReflectionMapping ) {

environmentType.setValue( 'Equirectangular' );
environmentEquirectangularTexture.setValue( scene.environment );
Expand Down Expand Up @@ -563,6 +567,17 @@ function SidebarScene( editor ) {

} );

signals.sceneBackgroundChanged.add( function () {

if ( environmentType.getValue() === 'Background' ) {

onEnvironmentChanged();
refreshEnvironmentUI();

}

} );

return container;

}
Expand Down
10 changes: 7 additions & 3 deletions editor/js/Viewport.js
Expand Up @@ -538,9 +538,13 @@ function Viewport( editor ) {

useBackgroundAsEnvironment = true;

scene.environment = scene.background;
scene.environment.mapping = THREE.EquirectangularReflectionMapping;
scene.environmentRotation.y = scene.backgroundRotation.y;
if ( scene.background !== null && scene.background.isTexture ) {

scene.environment = scene.background;
scene.environment.mapping = THREE.EquirectangularReflectionMapping;
scene.environmentRotation.y = scene.backgroundRotation.y;

}

break;

Expand Down

0 comments on commit 6d53d23

Please sign in to comment.