Просмотр исходного кода

Storage*Texture: Add `.setSize()` (#31502)

sunag 5 месяцев назад
Родитель
Сommit
a4d93efe86

+ 21 - 0
src/renderers/common/Storage3DTexture.js

@@ -74,6 +74,27 @@ class Storage3DTexture extends Texture {
 
 
 	}
 	}
 
 
+	/**
+	 * Sets the size of the storage 3d texture.
+	 *
+	 * @param {number} width - The new width of the storage texture.
+	 * @param {number} height - The new height of the storage texture.
+	 * @param {number} depth - The new depth of the storage texture.
+	 */
+	setSize( width, height, depth ) {
+
+		if ( this.image.width !== width || this.image.height !== height || this.image.depth !== depth ) {
+
+			this.image.width = width;
+			this.image.height = height;
+			this.image.depth = depth;
+
+			this.dispose();
+
+		}
+
+	}
+
 }
 }
 
 
 export default Storage3DTexture;
 export default Storage3DTexture;

+ 21 - 0
src/renderers/common/StorageArrayTexture.js

@@ -58,6 +58,27 @@ class StorageArrayTexture extends Texture {
 
 
 	}
 	}
 
 
+	/**
+	 * Sets the size of the storage array texture.
+	 *
+	 * @param {number} width - The new width of the storage texture.
+	 * @param {number} height - The new height of the storage texture.
+	 * @param {number} depth - The new depth of the storage texture.
+	 */
+	setSize( width, height, depth ) {
+
+		if ( this.image.width !== width || this.image.height !== height || this.image.depth !== depth ) {
+
+			this.image.width = width;
+			this.image.height = height;
+			this.image.depth = depth;
+
+			this.dispose();
+
+		}
+
+	}
+
 }
 }
 
 
 export default StorageArrayTexture;
 export default StorageArrayTexture;

+ 19 - 0
src/renderers/common/StorageTexture.js

@@ -54,6 +54,25 @@ class StorageTexture extends Texture {
 
 
 	}
 	}
 
 
+	/**
+	 * Sets the size of the storage texture.
+	 *
+	 * @param {number} width - The new width of the storage texture.
+	 * @param {number} height - The new height of the storage texture.
+	 */
+	setSize( width, height ) {
+
+		if ( this.image.width !== width || this.image.height !== height ) {
+
+			this.image.width = width;
+			this.image.height = height;
+
+			this.dispose();
+
+		}
+
+	}
+
 }
 }
 
 
 export default StorageTexture;
 export default StorageTexture;

粤ICP备19079148号