Skip to content

Commit

Permalink
suppor access to current canvas target
Browse files Browse the repository at this point in the history
  • Loading branch information
aardgoose committed Feb 9, 2024
1 parent b95ef12 commit 28cc3d1
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
4 changes: 2 additions & 2 deletions examples/jsm/nodes/display/PassNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ class PassNode extends TempNode {
const { renderer } = frame;
const { scene, camera } = this;

this._pixelRatio = renderer.getPixelRatio();
this._pixelRatio = renderer.getActivePixelRatio();

const size = renderer.getSize( new Vector2() );
const size = renderer.getActiveSize( new Vector2() );

this.setSize( size.width, size.height );

Expand Down
4 changes: 2 additions & 2 deletions examples/jsm/nodes/display/ViewportNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ class ViewportNode extends Node {

if ( this.scope === ViewportNode.VIEWPORT ) {

renderer.getViewport( viewportResult );
renderer.getActiveViewport( viewportResult );

} else {

renderer.getDrawingBufferSize( resolution );
renderer.getActiveDrawingBufferSize( resolution );

}

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/display/ViewportTextureNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ViewportTextureNode extends TextureNode {
updateBefore( frame ) {

const renderer = frame.renderer;
renderer.getDrawingBufferSize( _size );
renderer.getActiveDrawingBufferSize( _size );

//

Expand Down
4 changes: 2 additions & 2 deletions examples/jsm/nodes/utils/ReflectorNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ReflectorNode extends TextureNode {

const resolution = this.resolution;

renderer.getDrawingBufferSize( _size );
renderer.getActiveDrawingBufferSize( _size );

renderTarget.setSize( Math.round( _size.width * resolution ), Math.round( _size.height * resolution ) );

Expand Down Expand Up @@ -126,7 +126,7 @@ class ReflectorNode extends TextureNode {
const virtualCamera = this.getVirtualCamera( camera );
const renderTarget = this.getRenderTarget( virtualCamera );

renderer.getDrawingBufferSize( _size );
renderer.getActiveDrawingBufferSize( _size );

this._updateResolution( renderTarget, renderer );

Expand Down
21 changes: 21 additions & 0 deletions examples/jsm/renderers/common/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class Renderer {
this._background = null;

this._defaultCanvasRenderTarget = new CanvasRenderTarget( Object.assign( {}, parameters, { domElement: this.domElement } ) );
this._activeCanvas = null;
this._currentRenderContext = null;

this._opaqueSort = null;
Expand Down Expand Up @@ -412,6 +413,8 @@ class Renderer {
renderContext.width = renderTarget.domElement.width;
renderContext.height = renderTarget.domElement.height;

this._activeCanvas = renderTarget;

} else {

this._textures.updateRenderTarget( renderTarget, activeMipmapLevel );
Expand Down Expand Up @@ -526,18 +529,36 @@ class Renderer {

}

getActivePixelRatio() {

return this._activeCanvas.pixelRatio;

}

getDrawingBufferSize( target ) {

return this._defaultCanvasRenderTarget.getDrawingBufferSize( target );

}

getActiveDrawingBufferSize( target ) {

return this._activeCanvas.getDrawingBufferSize( target );

}

getSize( target ) {

return this._defaultCanvasRenderTarget.getSize( target );

}

getActiveSize( target ) {

return this._activeCanvas.getSize( target );

}

setPixelRatio( value = 1 ) {

this._defaultCanvasRenderTarget.setPixelRatio( value );
Expand Down

0 comments on commit 28cc3d1

Please sign in to comment.