Преглед изворни кода

env: insync w. bkg + recoverable from history (#28300)

ycw пре 1 година
родитељ
комит
6d53d239bd
2 измењених фајлова са 23 додато и 4 уклоњено
  1. 16 1
      editor/js/Sidebar.Scene.js
  2. 7 3
      editor/js/Viewport.js

+ 16 - 1
editor/js/Sidebar.Scene.js

@@ -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 );
@@ -563,6 +567,17 @@ function SidebarScene( editor ) {
 
 	} );
 
+	signals.sceneBackgroundChanged.add( function () {
+
+		if ( environmentType.getValue() === 'Background' ) {
+
+			onEnvironmentChanged();
+			refreshEnvironmentUI();
+
+		}
+
+	} );
+
 	return container;
 
 }

+ 7 - 3
editor/js/Viewport.js

@@ -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;