Skip to content

Commit

Permalink
XRManager: Fix background (#30348)
Browse files Browse the repository at this point in the history
* XRManager: Fix background clear in XR.

* Renderer: Update background even in XR.
  • Loading branch information
Mugen87 authored Jan 17, 2025
1 parent 8bbd48e commit 5b7a017
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
14 changes: 14 additions & 0 deletions src/renderers/common/Background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {

const clearColorValue = renderContext.clearColorValue;
Expand Down
6 changes: 1 addition & 5 deletions src/renderers/common/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

//

Expand Down
2 changes: 1 addition & 1 deletion src/renderers/common/XRManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ class XRManager extends EventDispatcher {
/**
* 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() {

Expand Down

0 comments on commit 5b7a017

Please sign in to comment.