Explorar el Código

XRManager: Fix background (#30348)

* XRManager: Fix background clear in XR.

* Renderer: Update background even in XR.
Michael Herzog hace 1 año
padre
commit
5b7a017532

+ 14 - 0
src/renderers/common/Background.js

@@ -142,6 +142,20 @@ class Background extends DataMap {
 
 
 		//
 		//
 
 
+		const environmentBlendMode = renderer.xr.getEnvironmentBlendMode();
+
+		if ( environmentBlendMode === 'additive' ) {
+
+			_clearColor.set( 0, 0, 0, 1 );
+
+		} else if ( environmentBlendMode === 'alpha-blend' ) {
+
+			_clearColor.set( 0, 0, 0, 0 );
+
+		}
+
+		//
+
 		if ( renderer.autoClear === true || forceClear === true ) {
 		if ( renderer.autoClear === true || forceClear === true ) {
 
 
 			const clearColorValue = renderContext.clearColorValue;
 			const clearColorValue = renderContext.clearColorValue;

+ 1 - 5
src/renderers/common/Renderer.js

@@ -1350,11 +1350,7 @@ class Renderer {
 
 
 		//
 		//
 
 
-		if ( xr.enabled === false || xr.isPresenting === false ) {
-
-			this._background.update( sceneRef, renderList, renderContext );
-
-		}
+		this._background.update( sceneRef, renderList, renderContext );
 
 
 		//
 		//
 
 

+ 1 - 1
src/renderers/common/XRManager.js

@@ -475,7 +475,7 @@ class XRManager extends EventDispatcher {
 	/**
 	/**
 	 * Returns the environment blend mode from the current XR session.
 	 * Returns the environment blend mode from the current XR session.
 	 *
 	 *
-	 * @return {'opaque'|'additive'|'alpha-blend'} The environment blend mode.
+	 * @return {('opaque'|'additive'|'alpha-blend')?} The environment blend mode. Returns `null` when used outside of a XR session.
 	 */
 	 */
 	getEnvironmentBlendMode() {
 	getEnvironmentBlendMode() {
 
 

粤ICP备19079148号