Skip to content

Commit 7805aba

Browse files
committed
PassNode: Remove auto* properties.
1 parent bc6d536 commit 7805aba

File tree

1 file changed

+46
-37
lines changed

1 file changed

+46
-37
lines changed

src/nodes/display/PassNode.js

Lines changed: 46 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -205,24 +205,6 @@ class PassNode extends TempNode {
205205
*/
206206
this.options = options;
207207

208-
/**
209-
* Whether the viewport should automatically kept in sync with the
210-
* pass node's dimension.
211-
*
212-
* @type {boolean}
213-
* @default true
214-
*/
215-
this.autoViewport = true;
216-
217-
/**
218-
* Whether the scissor rectangle should automatically kept in sync with the
219-
* pass node's dimension.
220-
*
221-
* @type {boolean}
222-
* @default true
223-
*/
224-
this.autoScissor = true;
225-
226208
/**
227209
* The pass's pixel ratio. Will be kept automatically kept in sync with the renderer's pixel ratio.
228210
*
@@ -365,17 +347,19 @@ class PassNode extends TempNode {
365347
* Custom viewport definition.
366348
*
367349
* @private
368-
* @type {Vector4}
350+
* @type {?Vector4}
351+
* @default null
369352
*/
370-
this._customViewport = new Vector4();
353+
this._customViewport = null;
371354

372355
/**
373356
* Custom scissor definition.
374357
*
375358
* @private
376-
* @type {Vector4}
359+
* @type {?Vector4}
360+
* @default null
377361
*/
378-
this._customScissor = new Vector4();
362+
this._customScissor = null;
379363

380364
/**
381365
* This flag can be used for type testing.
@@ -740,38 +724,53 @@ class PassNode extends TempNode {
740724

741725
this.renderTarget.setSize( effectiveWidth, effectiveHeight );
742726

743-
if ( this.autoScissor === false ) this.renderTarget.scissor.copy( this._customScissor );
744-
if ( this.autoViewport === false ) this.renderTarget.viewport.copy( this._customViewport );
727+
if ( this._customScissor !== null ) this.renderTarget.scissor.copy( this._customScissor );
728+
if ( this._customViewport ) this.renderTarget.viewport.copy( this._customViewport );
745729

746730
}
747731

748732
/**
749-
* Defines the scissor rectangle.
733+
* By default, the scissor rectangle is kept in sync with the pass's
734+
* resolution. This method allows to define a custom scissor rectangle.
735+
* To reverse the process and use auto-sizing again, call the method with `null`
736+
* as the single argument.
750737
*
751-
* @param {number | Vector4} x - The horizontal coordinate for the lower left corner of the box in logical pixel unit.
738+
* @param {?(number | Vector4)} x - The horizontal coordinate for the lower left corner of the box in logical pixel unit.
752739
* Instead of passing four arguments, the method also works with a single four-dimensional vector.
753740
* @param {number} y - The vertical coordinate for the lower left corner of the box in logical pixel unit.
754741
* @param {number} width - The width of the scissor box in logical pixel unit.
755742
* @param {number} height - The height of the scissor box in logical pixel unit.
756743
*/
757744
setScissor( x, y, width, height ) {
758745

759-
if ( x.isVector4 ) {
746+
if ( x === null ) {
760747

761-
this._customScissor.copy( x );
748+
this._customScissor = null;
762749

763750
} else {
764751

765-
this._customScissor.set( x, y, width, height );
752+
if ( this._customScissor === null ) this._customScissor = new Vector4();
766753

767-
}
754+
if ( x.isVector4 ) {
755+
756+
this._customScissor.copy( x );
757+
758+
} else {
759+
760+
this._customScissor.set( x, y, width, height );
768761

769-
this._customScissor.multiplyScalar( this._pixelRatio ).floor();
762+
}
763+
764+
this._customScissor.multiplyScalar( this._pixelRatio ).floor();
765+
766+
}
770767

771768
}
772769

773770
/**
774-
* Defines the viewport.
771+
* By default, the viewport is kept in sync with the pass's resolution.
772+
* This method allows to define a custom viewport. To reverse the process and use
773+
* auto-sizing again, call the method with `null` as the single argument.
775774
*
776775
* @param {number | Vector4} x - The horizontal coordinate for the lower left corner of the viewport origin in logical pixel unit.
777776
* @param {number} y - The vertical coordinate for the lower left corner of the viewport origin in logical pixel unit.
@@ -780,17 +779,27 @@ class PassNode extends TempNode {
780779
*/
781780
setViewport( x, y, width, height ) {
782781

783-
if ( x.isVector4 ) {
782+
if ( x === null ) {
784783

785-
this._customViewport.copy( x );
784+
this._customViewport = null;
786785

787786
} else {
788787

789-
this._customViewport.set( x, y, width, height );
788+
if ( this._customViewport === null ) this._customViewport = new Vector4();
790789

791-
}
790+
if ( x.isVector4 ) {
791+
792+
this._customViewport.copy( x );
793+
794+
} else {
795+
796+
this._customViewport.set( x, y, width, height );
792797

793-
this._customViewport.multiplyScalar( this._pixelRatio ).floor();
798+
}
799+
800+
this._customViewport.multiplyScalar( this._pixelRatio ).floor();
801+
802+
}
794803

795804
}
796805

0 commit comments

Comments
 (0)