Przeglądaj źródła

Add damp accessor to WebGL AfterimagePass class (#31035)

* Added damp accessor with clamping to WebGL AfterimagePass

* Updated Afterimage example GUI

* Removed damp clamp and setter JSDocs, tweak getter JSDocs to include range
Neil Rackett 8 miesięcy temu
rodzic
commit
3be0076eed

+ 18 - 1
examples/jsm/postprocessing/AfterimagePass.js

@@ -43,7 +43,7 @@ class AfterimagePass extends Pass {
 		 */
 		this.uniforms = UniformsUtils.clone( AfterimageShader.uniforms );
 
-		this.uniforms[ 'damp' ].value = damp;
+		this.damp = damp;
 
 		/**
 		 * The composition material.
@@ -89,6 +89,23 @@ class AfterimagePass extends Pass {
 
 	}
 
+	/**
+	 * The damping intensity, from 0.0 to 1.0. A higher value means a stronger after image effect.
+	 * 
+	 * @type {number}
+	 */
+	get damp() {
+
+		return this.uniforms[ 'damp' ].value;
+
+	}
+
+	set damp( value ) {
+
+		this.uniforms[ 'damp' ].value = value;
+
+	}
+
 	/**
 	 * Performs the after image pass.
 	 *

+ 1 - 1
examples/webgl_postprocessing_afterimage.html

@@ -73,7 +73,7 @@
 				window.addEventListener( 'resize', onWindowResize );
 
 				const gui = new GUI( { title: 'Damp setting' } );
-				gui.add( afterimagePass.uniforms[ 'damp' ], 'value', 0, 1 ).step( 0.001 );
+				gui.add( afterimagePass, 'damp', 0, 1 ).step( 0.001 );
 				gui.add( params, 'enable' );
 
 			}

粤ICP备19079148号