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

WebGLRenderer: Improve offscreen rendering in WebXR. #26160

Merged
merged 15 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from 8 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
81 changes: 33 additions & 48 deletions build/three.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9733,6 +9733,7 @@ class BufferAttribute {

this.usage = StaticDrawUsage;
this.updateRange = { offset: 0, count: - 1 };
this.gpuType = FloatType;

this.version = 0;

Expand Down Expand Up @@ -9763,6 +9764,7 @@ class BufferAttribute {
this.normalized = source.normalized;

this.usage = source.usage;
this.gpuType = source.gpuType;

return this;

Expand Down Expand Up @@ -10083,18 +10085,6 @@ class Int8BufferAttribute extends BufferAttribute {

super( new Int8Array( array ), itemSize, normalized );

this.gpuType = FloatType;

}

copy( source ) {

super.copy( source );

this.gpuType = source.gpuType;

return this;

}

}
Expand All @@ -10105,18 +10095,6 @@ class Uint8BufferAttribute extends BufferAttribute {

super( new Uint8Array( array ), itemSize, normalized );

this.gpuType = FloatType;

}

copy( source ) {

super.copy( source );

this.gpuType = source.gpuType;

return this;

}

}
Expand All @@ -10137,18 +10115,6 @@ class Int16BufferAttribute extends BufferAttribute {

super( new Int16Array( array ), itemSize, normalized );

this.gpuType = FloatType;

}

copy( source ) {

super.copy( source );

this.gpuType = source.gpuType;

return this;

}

}
Expand All @@ -10159,18 +10125,6 @@ class Uint16BufferAttribute extends BufferAttribute {

super( new Uint16Array( array ), itemSize, normalized );

this.gpuType = FloatType;

}

copy( source ) {

super.copy( source );

this.gpuType = source.gpuType;

return this;

}

}
Expand Down Expand Up @@ -26130,6 +26084,9 @@ class WebXRManager extends EventDispatcher {
const controllers = [];
const controllerInputSources = [];

const currentSize = new Vector2();
let currentPixelRatio = null;

//

let userCamera = null;
Expand Down Expand Up @@ -26272,6 +26229,8 @@ class WebXRManager extends EventDispatcher {

//

renderer.setDrawingBufferSize( currentSize.width, currentSize.height, currentPixelRatio );

animation.stop();

scope.isPresenting = false;
Expand Down Expand Up @@ -26328,6 +26287,12 @@ class WebXRManager extends EventDispatcher {

};

this.getRenderTarget = function () {

return newRenderTarget;

};

this.getFrame = function () {

return xrFrame;
Expand Down Expand Up @@ -26376,6 +26341,7 @@ class WebXRManager extends EventDispatcher {
glBaseLayer = new XRWebGLLayer( session, gl, layerInit );

session.updateRenderState( { baseLayer: glBaseLayer } );
renderer.setDrawingBufferSize( glBaseLayer.framebufferWidth, glBaseLayer.framebufferHeight, 1 );

newRenderTarget = new WebGLRenderTarget(
glBaseLayer.framebufferWidth,
Expand Down Expand Up @@ -26413,6 +26379,7 @@ class WebXRManager extends EventDispatcher {
glProjLayer = glBinding.createProjectionLayer( projectionlayerInit );

session.updateRenderState( { layers: [ glProjLayer ] } );
renderer.setDrawingBufferSize( glProjLayer.textureWidth, glProjLayer.textureHeight, 1 );

newRenderTarget = new WebGLRenderTarget(
glProjLayer.textureWidth,
Expand All @@ -26438,6 +26405,9 @@ class WebXRManager extends EventDispatcher {
customReferenceSpace = null;
referenceSpace = await session.requestReferenceSpace( referenceSpaceType );

currentPixelRatio = renderer.getPixelRatio();
renderer.getDrawingBufferSize( currentSize );

animation.setContext( session );
animation.start();

Expand Down Expand Up @@ -29858,6 +29828,13 @@ class WebGLRenderer {

this.setRenderTarget = function ( renderTarget, activeCubeFace = 0, activeMipmapLevel = 0 ) {

// Render to base layer instead of canvas in WebXR
if ( renderTarget === null && this.xr.isPresenting ) {

renderTarget = this.xr.getRenderTarget();

}

_currentRenderTarget = renderTarget;
_currentActiveCubeFace = activeCubeFace;
_currentActiveMipmapLevel = activeMipmapLevel;
Expand Down Expand Up @@ -45869,6 +45846,14 @@ class PositionalAudio extends Audio {

}

connect() {

super.connect();

this.panner.connect( this.gain );

}

disconnect() {

super.disconnect();
Expand Down
81 changes: 33 additions & 48 deletions build/three.js
Original file line number Diff line number Diff line change
Expand Up @@ -9738,6 +9738,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated

this.usage = StaticDrawUsage;
this.updateRange = { offset: 0, count: - 1 };
this.gpuType = FloatType;

this.version = 0;

Expand Down Expand Up @@ -9768,6 +9769,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
this.normalized = source.normalized;

this.usage = source.usage;
this.gpuType = source.gpuType;

return this;

Expand Down Expand Up @@ -10088,18 +10090,6 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated

super( new Int8Array( array ), itemSize, normalized );

this.gpuType = FloatType;

}

copy( source ) {

super.copy( source );

this.gpuType = source.gpuType;

return this;

}

}
Expand All @@ -10110,18 +10100,6 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated

super( new Uint8Array( array ), itemSize, normalized );

this.gpuType = FloatType;

}

copy( source ) {

super.copy( source );

this.gpuType = source.gpuType;

return this;

}

}
Expand All @@ -10142,18 +10120,6 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated

super( new Int16Array( array ), itemSize, normalized );

this.gpuType = FloatType;

}

copy( source ) {

super.copy( source );

this.gpuType = source.gpuType;

return this;

}

}
Expand All @@ -10164,18 +10130,6 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated

super( new Uint16Array( array ), itemSize, normalized );

this.gpuType = FloatType;

}

copy( source ) {

super.copy( source );

this.gpuType = source.gpuType;

return this;

}

}
Expand Down Expand Up @@ -26135,6 +26089,9 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
const controllers = [];
const controllerInputSources = [];

const currentSize = new Vector2();
let currentPixelRatio = null;

//

let userCamera = null;
Expand Down Expand Up @@ -26277,6 +26234,8 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated

//

renderer.setDrawingBufferSize( currentSize.width, currentSize.height, currentPixelRatio );

animation.stop();

scope.isPresenting = false;
Expand Down Expand Up @@ -26333,6 +26292,12 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated

};

this.getRenderTarget = function () {

return newRenderTarget;

};

this.getFrame = function () {

return xrFrame;
Expand Down Expand Up @@ -26381,6 +26346,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
glBaseLayer = new XRWebGLLayer( session, gl, layerInit );

session.updateRenderState( { baseLayer: glBaseLayer } );
renderer.setDrawingBufferSize( glBaseLayer.framebufferWidth, glBaseLayer.framebufferHeight, 1 );

newRenderTarget = new WebGLRenderTarget(
glBaseLayer.framebufferWidth,
Expand Down Expand Up @@ -26418,6 +26384,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
glProjLayer = glBinding.createProjectionLayer( projectionlayerInit );

session.updateRenderState( { layers: [ glProjLayer ] } );
renderer.setDrawingBufferSize( glProjLayer.textureWidth, glProjLayer.textureHeight, 1 );

newRenderTarget = new WebGLRenderTarget(
glProjLayer.textureWidth,
Expand All @@ -26443,6 +26410,9 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
customReferenceSpace = null;
referenceSpace = await session.requestReferenceSpace( referenceSpaceType );

currentPixelRatio = renderer.getPixelRatio();
renderer.getDrawingBufferSize( currentSize );

animation.setContext( session );
animation.start();

Expand Down Expand Up @@ -29863,6 +29833,13 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated

this.setRenderTarget = function ( renderTarget, activeCubeFace = 0, activeMipmapLevel = 0 ) {

// Render to base layer instead of canvas in WebXR
if ( renderTarget === null && this.xr.isPresenting ) {

renderTarget = this.xr.getRenderTarget();

}

_currentRenderTarget = renderTarget;
_currentActiveCubeFace = activeCubeFace;
_currentActiveMipmapLevel = activeMipmapLevel;
Expand Down Expand Up @@ -45874,6 +45851,14 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated

}

connect() {

super.connect();

this.panner.connect( this.gain );

}

disconnect() {

super.disconnect();
Expand Down
2 changes: 1 addition & 1 deletion build/three.min.js

Large diffs are not rendered by default.

Loading