Skip to content
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

WebXRManager: Allow early set of foveation. #25282

Merged
merged 1 commit into from
Jan 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions src/renderers/webxr/WebXRManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class WebXRManager extends EventDispatcher {

let referenceSpace = null;
let referenceSpaceType = 'local-floor';
// Set default foveation to maximum.
let foveation = 1.0;
let customReferenceSpace = null;

let pose = null;
Expand Down Expand Up @@ -338,8 +340,7 @@ class WebXRManager extends EventDispatcher {

newRenderTarget.isXRRenderTarget = true; // TODO Remove this when possible, see #23278

// Set foveation to maximum.
this.setFoveation( 1.0 );
this.setFoveation( foveation );

customReferenceSpace = null;
referenceSpace = await session.requestReferenceSpace( referenceSpaceType );
Expand Down Expand Up @@ -568,36 +569,32 @@ class WebXRManager extends EventDispatcher {

this.getFoveation = function () {

if ( glProjLayer !== null ) {

return glProjLayer.fixedFoveation;

}

if ( glBaseLayer !== null ) {
if ( glProjLayer === null && glBaseLayer === null ) {

return glBaseLayer.fixedFoveation;
return undefined;

}

return undefined;
return foveation;

};

this.setFoveation = function ( foveation ) {
this.setFoveation = function ( value ) {

// 0 = no foveation = full resolution
// 1 = maximum foveation = the edges render at lower resolution

foveation = value;

if ( glProjLayer !== null ) {

glProjLayer.fixedFoveation = foveation;
glProjLayer.fixedFoveation = value;

}

if ( glBaseLayer !== null && glBaseLayer.fixedFoveation !== undefined ) {

glBaseLayer.fixedFoveation = foveation;
glBaseLayer.fixedFoveation = value;

}

Expand Down