diff --git a/docs/api/en/renderers/WebGLRenderer.html b/docs/api/en/renderers/WebGLRenderer.html index 85d49698d4376941f2b1b17d969aa3a53e4b401c..ac7fa18fd21543669210ec35eabe4c9841c7987f 100644 --- a/docs/api/en/renderers/WebGLRenderer.html +++ b/docs/api/en/renderers/WebGLRenderer.html @@ -348,8 +348,12 @@
Returns the current RenderTarget, if any.
-Returns the current viewport.
+
+ [page:Vector4 target] — the result will be copied into this Vector4.
+
+ Returns the current viewport.
+
diff --git a/examples/js/objects/Lensflare.js b/examples/js/objects/Lensflare.js index 67cdd0eeb0bcc9dc5c2caa1d8ac57d115ccdae8b..57a92cd36779ce7d79062c432dc10c0af5a05d7e 100644 --- a/examples/js/objects/Lensflare.js +++ b/examples/js/objects/Lensflare.js @@ -162,7 +162,7 @@ THREE.Lensflare = function () { this.onBeforeRender = function ( renderer, scene, camera ) { - viewport.copy( renderer.getCurrentViewport() ); + renderer.getCurrentViewport( viewport ); var invAspect = viewport.w / viewport.z; var halfViewportWidth = viewport.z / 2.0; diff --git a/src/renderers/WebGLRenderer.d.ts b/src/renderers/WebGLRenderer.d.ts index ddce1122bc453905b5672d36410850dcf3773149..981e4665a53083f82fdc78e6e0de66d723af9cd9 100644 --- a/src/renderers/WebGLRenderer.d.ts +++ b/src/renderers/WebGLRenderer.d.ts @@ -214,7 +214,7 @@ export class WebGLRenderer implements Renderer { */ setSize(width: number, height: number, updateStyle?: boolean): void; - getCurrentViewport(): Vector4; + getCurrentViewport(target: Vector4): Vector4; /** * Sets the viewport to render from (x, y) to (x + width, y + height). */ diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 43700355664f695155ce0922cb2f3d4326f58ad5..78b5f8b062093d99e49ed9a0fef84ee8d99763dc 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -429,9 +429,17 @@ function WebGLRenderer( parameters ) { }; - this.getCurrentViewport = function () { + this.getCurrentViewport = function ( target ) { - return _currentViewport; + if ( target === undefined ) { + + console.warn( 'WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument' ); + + target = new Vector4(); + + } + + return target.copy( _currentViewport ); };