|
|
@@ -7,6 +7,7 @@ import { viewZToOrthographicDepth, perspectiveDepthToViewZ } from './ViewportDep
|
|
|
|
|
|
import { HalfFloatType/*, FloatType*/ } from '../../constants.js';
|
|
|
import { Vector2 } from '../../math/Vector2.js';
|
|
|
+import { Vector4 } from '../../math/Vector4.js';
|
|
|
import { DepthTexture } from '../../textures/DepthTexture.js';
|
|
|
import { RenderTarget } from '../../core/RenderTarget.js';
|
|
|
|
|
|
@@ -323,10 +324,43 @@ class PassNode extends TempNode {
|
|
|
*/
|
|
|
this._mrt = null;
|
|
|
|
|
|
+ /**
|
|
|
+ * Layer object for configuring the camera that is used
|
|
|
+ * to produce the pass.
|
|
|
+ *
|
|
|
+ * @private
|
|
|
+ * @type {?Layers}
|
|
|
+ * @default null
|
|
|
+ */
|
|
|
this._layers = null;
|
|
|
|
|
|
+ /**
|
|
|
+ * Scales the resolution of the internal render taregt.
|
|
|
+ *
|
|
|
+ * @private
|
|
|
+ * @type {number}
|
|
|
+ * @default 1
|
|
|
+ */
|
|
|
this._resolution = 1;
|
|
|
|
|
|
+ /**
|
|
|
+ * Custom viewport definition.
|
|
|
+ *
|
|
|
+ * @private
|
|
|
+ * @type {?Vector4}
|
|
|
+ * @default null
|
|
|
+ */
|
|
|
+ this._customViewport = null;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Custom scissor definition.
|
|
|
+ *
|
|
|
+ * @private
|
|
|
+ * @type {?Vector4}
|
|
|
+ * @default null
|
|
|
+ */
|
|
|
+ this._customScissor = null;
|
|
|
+
|
|
|
/**
|
|
|
* This flag can be used for type testing.
|
|
|
*
|
|
|
@@ -374,7 +408,6 @@ class PassNode extends TempNode {
|
|
|
* Gets the current resolution of the pass.
|
|
|
*
|
|
|
* @return {number} The current resolution. A value of `1` means full resolution.
|
|
|
- * @default 1
|
|
|
*/
|
|
|
getResolution() {
|
|
|
|
|
|
@@ -382,6 +415,12 @@ class PassNode extends TempNode {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Sets the layer configuration that should be used when rendering the pass.
|
|
|
+ *
|
|
|
+ * @param {Layers} layers - The layers object to set.
|
|
|
+ * @return {PassNode} A reference to this pass.
|
|
|
+ */
|
|
|
setLayers( layers ) {
|
|
|
|
|
|
this._layers = layers;
|
|
|
@@ -390,6 +429,11 @@ class PassNode extends TempNode {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Gets the current layer configuration of the pass.
|
|
|
+ *
|
|
|
+ * @return {?Layers} .
|
|
|
+ */
|
|
|
getLayers() {
|
|
|
|
|
|
return this._layers;
|
|
|
@@ -680,6 +724,82 @@ class PassNode extends TempNode {
|
|
|
|
|
|
this.renderTarget.setSize( effectiveWidth, effectiveHeight );
|
|
|
|
|
|
+ if ( this._customScissor !== null ) this.renderTarget.scissor.copy( this._customScissor );
|
|
|
+ if ( this._customViewport !== null ) this.renderTarget.viewport.copy( this._customViewport );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * This method allows to define the pass's scissor rectangle. By default, the scissor rectangle is kept
|
|
|
+ * in sync with the pass's dimensions. To reverse the process and use auto-sizing again, call the method
|
|
|
+ * with `null` as the single argument.
|
|
|
+ *
|
|
|
+ * @param {?(number | Vector4)} x - The horizontal coordinate for the lower left corner of the box in logical pixel unit.
|
|
|
+ * Instead of passing four arguments, the method also works with a single four-dimensional vector.
|
|
|
+ * @param {number} y - The vertical coordinate for the lower left corner of the box in logical pixel unit.
|
|
|
+ * @param {number} width - The width of the scissor box in logical pixel unit.
|
|
|
+ * @param {number} height - The height of the scissor box in logical pixel unit.
|
|
|
+ */
|
|
|
+ setScissor( x, y, width, height ) {
|
|
|
+
|
|
|
+ if ( x === null ) {
|
|
|
+
|
|
|
+ this._customScissor = null;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if ( this._customScissor === null ) this._customScissor = new Vector4();
|
|
|
+
|
|
|
+ if ( x.isVector4 ) {
|
|
|
+
|
|
|
+ this._customScissor.copy( x );
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ this._customScissor.set( x, y, width, height );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ this._customScissor.multiplyScalar( this._pixelRatio * this._resolution ).floor();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * This method allows to define the pass's viewport. By default, the viewport is kept in sync
|
|
|
+ * with the pass's dimensions. To reverse the process and use auto-sizing again, call the method
|
|
|
+ * with `null` as the single argument.
|
|
|
+ *
|
|
|
+ * @param {number | Vector4} x - The horizontal coordinate for the lower left corner of the viewport origin in logical pixel unit.
|
|
|
+ * @param {number} y - The vertical coordinate for the lower left corner of the viewport origin in logical pixel unit.
|
|
|
+ * @param {number} width - The width of the viewport in logical pixel unit.
|
|
|
+ * @param {number} height - The height of the viewport in logical pixel unit.
|
|
|
+ */
|
|
|
+ setViewport( x, y, width, height ) {
|
|
|
+
|
|
|
+ if ( x === null ) {
|
|
|
+
|
|
|
+ this._customViewport = null;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if ( this._customViewport === null ) this._customViewport = new Vector4();
|
|
|
+
|
|
|
+ if ( x.isVector4 ) {
|
|
|
+
|
|
|
+ this._customViewport.copy( x );
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ this._customViewport.set( x, y, width, height );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ this._customViewport.multiplyScalar( this._pixelRatio * this._resolution ).floor();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|