Răsfoiți Sursa

Merge pull request #15807 from WestLangley/dev-set_scissor

WebGLRenderer: support Vector4 arg in setScissor()
Mr.doob 6 ani în urmă
părinte
comite
e25ab6b19f

+ 8 - 2
docs/api/en/renderers/WebGLRenderer.html

@@ -440,9 +440,15 @@
 		This method sets the active rendertarget. If the parameter is omitted the canvas is set as the active rendertarget.
 		This method sets the active rendertarget. If the parameter is omitted the canvas is set as the active rendertarget.
 		</p>
 		</p>
 
 
-		<h3>[method:null setScissor]( [param:Integer x], [param:Integer y], [param:Integer width], [param:Integer height] )</h3>
+		<h3>[method:null setScissor]( [param:Integer x], [param:Integer y], [param:Integer width], [param:Integer height] )<br />
+		[method:null setScissor]( [param:Vector4 vector] )</h3>
+
 		<p>
 		<p>
-		Sets the scissor area from (x, y) to (x + width, y + height)
+		The x, y, width, and height parameters of the scissor region.<br />
+		Optionally, a 4-component vector specifying the parameters of the region.<br /><br />
+
+		Sets the scissor region from (x, y) to (x + width, y + height).<br />
+		(x, y) is the lower-left corner of the scissor region.
 		</p>
 		</p>
 
 
 		<h3>[method:null setScissorTest]( [param:Boolean boolean] )</h3>
 		<h3>[method:null setScissorTest]( [param:Boolean boolean] )</h3>

+ 1 - 1
src/renderers/WebGLRenderer.d.ts

@@ -235,7 +235,7 @@ export class WebGLRenderer implements Renderer {
   /**
   /**
    * Sets the scissor area from (x, y) to (x + width, y + height).
    * Sets the scissor area from (x, y) to (x + width, y + height).
    */
    */
-  setScissor(x: number, y: number, width: number, height: number): void;
+  setScissor(x: Vector4 | number, y?: number, width?: number, height?: number): void;
 
 
   /**
   /**
    * Returns true if scissor test is enabled; returns false otherwise.
    * Returns true if scissor test is enabled; returns false otherwise.

+ 10 - 1
src/renderers/WebGLRenderer.js

@@ -474,7 +474,16 @@ function WebGLRenderer( parameters ) {
 
 
 	this.setScissor = function ( x, y, width, height ) {
 	this.setScissor = function ( x, y, width, height ) {
 
 
-		_scissor.set( x, y, width, height );
+		if ( x.isVector4 ) {
+
+			_scissor.set( x.x, x.y, x.z, x.w );
+
+		} else {
+
+			_scissor.set( x, y, width, height );
+
+		}
+
 		state.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ) );
 		state.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ) );
 
 
 	};
 	};