Explorar o código

TSL: Fix `convertToTexture()` auto resize (#31277)

* fix auto resize update

* rename `autoSize` to `autoResize`
sunag hai 6 meses
pai
achega
6e73a322e3
Modificáronse 1 ficheiros con 13 adicións e 5 borrados
  1. 13 5
      src/nodes/utils/RTTNode.js

+ 13 - 5
src/nodes/utils/RTTNode.js

@@ -131,7 +131,7 @@ class RTTNode extends TextureNode {
 	 * @readonly
 	 * @readonly
 	 * @default true
 	 * @default true
 	 */
 	 */
-	get autoSize() {
+	get autoResize() {
 
 
 		return this.width === null;
 		return this.width === null;
 
 
@@ -188,13 +188,21 @@ class RTTNode extends TextureNode {
 
 
 		//
 		//
 
 
-		if ( this.autoSize === true ) {
-
-			this.pixelRatio = renderer.getPixelRatio();
+		if ( this.autoResize === true ) {
 
 
+			const pixelRatio = renderer.getPixelRatio();
 			const size = renderer.getSize( _size );
 			const size = renderer.getSize( _size );
 
 
-			this.setSize( size.width, size.height );
+			const effectiveWidth = size.width * pixelRatio;
+			const effectiveHeight = size.height * pixelRatio;
+
+			if ( effectiveWidth !== this.renderTarget.width || effectiveHeight !== this.renderTarget.height ) {
+
+				this.renderTarget.setSize( effectiveWidth, effectiveHeight );
+
+				this.textureNeedsUpdate = true;
+
+			}
 
 
 		}
 		}
 
 

粤ICP备19079148号