-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix CubeCamera breaking in WebXR #19439
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mugen87
approved these changes
May 24, 2020
Thanks! |
@Mugen87 What do you think about using this pattern? diff --git a/src/cameras/CubeCamera.js b/src/cameras/CubeCamera.js
index d2fa6ee17..156862d65 100644
--- a/src/cameras/CubeCamera.js
+++ b/src/cameras/CubeCamera.js
@@ -27,36 +27,42 @@ function CubeCamera( near, far, renderTarget ) {
this.renderTarget = renderTarget;
var cameraPX = new PerspectiveCamera( fov, aspect, near, far );
+ cameraPX.isInternal = true;
cameraPX.layers = this.layers;
cameraPX.up.set( 0, - 1, 0 );
cameraPX.lookAt( new Vector3( 1, 0, 0 ) );
this.add( cameraPX );
var cameraNX = new PerspectiveCamera( fov, aspect, near, far );
+ cameraNX.isInternal = true;
cameraNX.layers = this.layers;
cameraNX.up.set( 0, - 1, 0 );
cameraNX.lookAt( new Vector3( - 1, 0, 0 ) );
this.add( cameraNX );
var cameraPY = new PerspectiveCamera( fov, aspect, near, far );
+ cameraPY.isInternal = true;
cameraPY.layers = this.layers;
cameraPY.up.set( 0, 0, 1 );
cameraPY.lookAt( new Vector3( 0, 1, 0 ) );
this.add( cameraPY );
var cameraNY = new PerspectiveCamera( fov, aspect, near, far );
+ cameraNY.isInternal = true;
cameraNY.layers = this.layers;
cameraNY.up.set( 0, 0, - 1 );
cameraNY.lookAt( new Vector3( 0, - 1, 0 ) );
this.add( cameraNY );
var cameraPZ = new PerspectiveCamera( fov, aspect, near, far );
+ cameraPZ.isInternal = true;
cameraPZ.layers = this.layers;
cameraPZ.up.set( 0, - 1, 0 );
cameraPZ.lookAt( new Vector3( 0, 0, 1 ) );
this.add( cameraPZ );
var cameraNZ = new PerspectiveCamera( fov, aspect, near, far );
+ cameraNZ.isInternal = true;
cameraNZ.layers = this.layers;
cameraNZ.up.set( 0, - 1, 0 );
cameraNZ.lookAt( new Vector3( 0, 0, - 1 ) );
diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js
index cd5578850..5178a8ae2 100644
--- a/src/renderers/WebGLRenderer.js
+++ b/src/renderers/WebGLRenderer.js
@@ -1161,7 +1161,7 @@ function WebGLRenderer( parameters ) {
if ( camera.parent === null ) camera.updateMatrixWorld();
- if ( xr.enabled && xr.isPresenting ) {
+ if ( camera.isInternal !== true && xr.enabled && xr.isPresenting ) {
camera = xr.getCamera( camera );
Do you think this would work with |
Um, not sure. Enabling/disabling XR is related to the cases when code renders to a texture. This can also happen with the same camera that is used to render the scene. If so, you would have to toggle |
Ah, right. Okay 👍 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
implements @Mugen87's fix to #19428 by disabling WebXR before updating the cube render target and reenabling afterwards.
Tested locally on an existing WebXR project and confirmed working (after slight refactoring to accommodate the new WebGLCubeRenderTarget injection method per #19137).
Fixed #19428.