Browse Source

Examples: Move postprocessing to ES6. (#21621)

* Examples: Move postprocessing to ES6.

* Examples: Clean up.
Michael Herzog 4 years ago
parent
commit
5bc2515443
55 changed files with 4188 additions and 4087 deletions
  1. 23 17
      examples/js/WebGL.js
  2. 127 91
      examples/js/postprocessing/AdaptiveToneMappingPass.js
  3. 39 35
      examples/js/postprocessing/AfterimagePass.js
  4. 51 53
      examples/js/postprocessing/BloomPass.js
  5. 49 48
      examples/js/postprocessing/BokehPass.js
  6. 13 12
      examples/js/postprocessing/ClearPass.js
  7. 35 34
      examples/js/postprocessing/CubeTexturePass.js
  8. 23 22
      examples/js/postprocessing/DotScreenPass.js
  9. 119 106
      examples/js/postprocessing/EffectComposer.js
  10. 24 23
      examples/js/postprocessing/FilmPass.js
  11. 34 32
      examples/js/postprocessing/GlitchPass.js
  12. 28 26
      examples/js/postprocessing/HalftonePass.js
  13. 25 23
      examples/js/postprocessing/MaskPass.js
  14. 268 219
      examples/js/postprocessing/OutlinePass.js
  15. 43 40
      examples/js/postprocessing/Pass.js
  16. 22 21
      examples/js/postprocessing/RenderPass.js
  17. 162 157
      examples/js/postprocessing/SAOPass.js
  18. 88 86
      examples/js/postprocessing/SMAAPass.js
  19. 53 48
      examples/js/postprocessing/SSAARenderPass.js
  20. 158 148
      examples/js/postprocessing/SSAOPass.js
  21. 266 259
      examples/js/postprocessing/SSRPass.js
  22. 210 203
      examples/js/postprocessing/SSRrPass.js
  23. 32 29
      examples/js/postprocessing/SavePass.js
  24. 22 21
      examples/js/postprocessing/ShaderPass.js
  25. 20 24
      examples/js/postprocessing/TAARenderPass.js
  26. 26 25
      examples/js/postprocessing/TexturePass.js
  27. 191 185
      examples/js/postprocessing/UnrealBloomPass.js
  28. 17 17
      examples/jsm/WebGL.js
  29. 46 45
      examples/jsm/nodes/postprocessing/NodePass.js
  30. 103 106
      examples/jsm/postprocessing/AdaptiveToneMappingPass.js
  31. 32 35
      examples/jsm/postprocessing/AfterimagePass.js
  32. 42 51
      examples/jsm/postprocessing/BloomPass.js
  33. 50 52
      examples/jsm/postprocessing/BokehPass.js
  34. 11 13
      examples/jsm/postprocessing/ClearPass.js
  35. 31 33
      examples/jsm/postprocessing/CubeTexturePass.js
  36. 19 22
      examples/jsm/postprocessing/DotScreenPass.js
  37. 104 115
      examples/jsm/postprocessing/EffectComposer.js
  38. 20 23
      examples/jsm/postprocessing/FilmPass.js
  39. 28 33
      examples/jsm/postprocessing/GlitchPass.js
  40. 28 29
      examples/jsm/postprocessing/HalftonePass.js
  41. 21 26
      examples/jsm/postprocessing/MaskPass.js
  42. 243 241
      examples/jsm/postprocessing/OutlinePass.js
  43. 37 51
      examples/jsm/postprocessing/Pass.js
  44. 17 19
      examples/jsm/postprocessing/RenderPass.js
  45. 155 156
      examples/jsm/postprocessing/SAOPass.js
  46. 88 90
      examples/jsm/postprocessing/SMAAPass.js
  47. 44 46
      examples/jsm/postprocessing/SSAARenderPass.js
  48. 156 158
      examples/jsm/postprocessing/SSAOPass.js
  49. 258 260
      examples/jsm/postprocessing/SSRPass.js
  50. 200 203
      examples/jsm/postprocessing/SSRrPass.js
  51. 23 26
      examples/jsm/postprocessing/SavePass.js
  52. 21 23
      examples/jsm/postprocessing/ShaderPass.js
  53. 50 28
      examples/jsm/postprocessing/TAARenderPass.js
  54. 22 25
      examples/jsm/postprocessing/TexturePass.js
  55. 171 174
      examples/jsm/postprocessing/UnrealBloomPass.js

+ 23 - 17
examples/js/WebGL.js

@@ -1,11 +1,12 @@
 ( function () {
 ( function () {
 
 
-	var WEBGL = {
-		isWebGLAvailable: function () {
+	class WEBGL {
+
+		static isWebGLAvailable() {
 
 
 			try {
 			try {
 
 
-				var canvas = document.createElement( 'canvas' );
+				const canvas = document.createElement( 'canvas' );
 				return !! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) );
 				return !! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) );
 
 
 			} catch ( e ) {
 			} catch ( e ) {
@@ -14,12 +15,13 @@
 
 
 			}
 			}
 
 
-		},
-		isWebGL2Available: function () {
+		}
+
+		static isWebGL2Available() {
 
 
 			try {
 			try {
 
 
-				var canvas = document.createElement( 'canvas' );
+				const canvas = document.createElement( 'canvas' );
 				return !! ( window.WebGL2RenderingContext && canvas.getContext( 'webgl2' ) );
 				return !! ( window.WebGL2RenderingContext && canvas.getContext( 'webgl2' ) );
 
 
 			} catch ( e ) {
 			} catch ( e ) {
@@ -28,29 +30,32 @@
 
 
 			}
 			}
 
 
-		},
-		getWebGLErrorMessage: function () {
+		}
+
+		static getWebGLErrorMessage() {
 
 
 			return this.getErrorMessage( 1 );
 			return this.getErrorMessage( 1 );
 
 
-		},
-		getWebGL2ErrorMessage: function () {
+		}
+
+		static getWebGL2ErrorMessage() {
 
 
 			return this.getErrorMessage( 2 );
 			return this.getErrorMessage( 2 );
 
 
-		},
-		getErrorMessage: function ( version ) {
+		}
 
 
-			var names = {
+		static getErrorMessage( version ) {
+
+			const names = {
 				1: 'WebGL',
 				1: 'WebGL',
 				2: 'WebGL 2'
 				2: 'WebGL 2'
 			};
 			};
-			var contexts = {
+			const contexts = {
 				1: window.WebGLRenderingContext,
 				1: window.WebGLRenderingContext,
 				2: window.WebGL2RenderingContext
 				2: window.WebGL2RenderingContext
 			};
 			};
-			var message = 'Your $0 does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">$1</a>';
-			var element = document.createElement( 'div' );
+			let message = 'Your $0 does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">$1</a>';
+			const element = document.createElement( 'div' );
 			element.id = 'webglmessage';
 			element.id = 'webglmessage';
 			element.style.fontFamily = 'monospace';
 			element.style.fontFamily = 'monospace';
 			element.style.fontSize = '13px';
 			element.style.fontSize = '13px';
@@ -77,7 +82,8 @@
 			return element;
 			return element;
 
 
 		}
 		}
-	};
+
+	}
 
 
 	THREE.WEBGL = WEBGL;
 	THREE.WEBGL = WEBGL;
 
 

+ 127 - 91
examples/js/postprocessing/AdaptiveToneMappingPass.js

@@ -8,81 +8,108 @@
  * Full-screen tone-mapping shader based on http://www.graphics.cornell.edu/~jaf/publications/sig02_paper.pdf
  * Full-screen tone-mapping shader based on http://www.graphics.cornell.edu/~jaf/publications/sig02_paper.pdf
  */
  */
 
 
-	var AdaptiveToneMappingPass = function ( adaptive, resolution ) {
-
-		THREE.Pass.call( this );
-		this.resolution = resolution !== undefined ? resolution : 256;
-		this.needsInit = true;
-		this.adaptive = adaptive !== undefined ? !! adaptive : true;
-		this.luminanceRT = null;
-		this.previousLuminanceRT = null;
-		this.currentLuminanceRT = null;
-		if ( THREE.CopyShader === undefined ) console.error( 'THREE.AdaptiveToneMappingPass relies on THREE.CopyShader' );
-		var copyShader = THREE.CopyShader;
-		this.copyUniforms = THREE.UniformsUtils.clone( copyShader.uniforms );
-		this.materialCopy = new THREE.ShaderMaterial( {
-			uniforms: this.copyUniforms,
-			vertexShader: copyShader.vertexShader,
-			fragmentShader: copyShader.fragmentShader,
-			blending: THREE.NoBlending,
-			depthTest: false
-		} );
-		if ( THREE.LuminosityShader === undefined ) console.error( 'THREE.AdaptiveToneMappingPass relies on THREE.LuminosityShader' );
-		this.materialLuminance = new THREE.ShaderMaterial( {
-			uniforms: THREE.UniformsUtils.clone( THREE.LuminosityShader.uniforms ),
-			vertexShader: THREE.LuminosityShader.vertexShader,
-			fragmentShader: THREE.LuminosityShader.fragmentShader,
-			blending: THREE.NoBlending
-		} );
-		this.adaptLuminanceShader = {
-			defines: {
-				'MIP_LEVEL_1X1': ( Math.log( this.resolution ) / Math.log( 2.0 ) ).toFixed( 1 )
-			},
-			uniforms: {
-				'lastLum': {
-					value: null
-				},
-				'currentLum': {
-					value: null
-				},
-				'minLuminance': {
-					value: 0.01
+	class AdaptiveToneMappingPass extends THREE.Pass {
+
+		constructor( adaptive, resolution ) {
+
+			super();
+			this.resolution = resolution !== undefined ? resolution : 256;
+			this.needsInit = true;
+			this.adaptive = adaptive !== undefined ? !! adaptive : true;
+			this.luminanceRT = null;
+			this.previousLuminanceRT = null;
+			this.currentLuminanceRT = null;
+			if ( THREE.CopyShader === undefined ) console.error( 'THREE.AdaptiveToneMappingPass relies on THREE.CopyShader' );
+			const copyShader = THREE.CopyShader;
+			this.copyUniforms = THREE.UniformsUtils.clone( copyShader.uniforms );
+			this.materialCopy = new THREE.ShaderMaterial( {
+				uniforms: this.copyUniforms,
+				vertexShader: copyShader.vertexShader,
+				fragmentShader: copyShader.fragmentShader,
+				blending: THREE.NoBlending,
+				depthTest: false
+			} );
+			if ( THREE.LuminosityShader === undefined ) console.error( 'THREE.AdaptiveToneMappingPass relies on THREE.LuminosityShader' );
+			this.materialLuminance = new THREE.ShaderMaterial( {
+				uniforms: THREE.UniformsUtils.clone( THREE.LuminosityShader.uniforms ),
+				vertexShader: THREE.LuminosityShader.vertexShader,
+				fragmentShader: THREE.LuminosityShader.fragmentShader,
+				blending: THREE.NoBlending
+			} );
+			this.adaptLuminanceShader = {
+				defines: {
+					'MIP_LEVEL_1X1': ( Math.log( this.resolution ) / Math.log( 2.0 ) ).toFixed( 1 )
 				},
 				},
-				'delta': {
-					value: 0.016
+				uniforms: {
+					'lastLum': {
+						value: null
+					},
+					'currentLum': {
+						value: null
+					},
+					'minLuminance': {
+						value: 0.01
+					},
+					'delta': {
+						value: 0.016
+					},
+					'tau': {
+						value: 1.0
+					}
 				},
 				},
-				'tau': {
-					value: 1.0
-				}
-			},
-			vertexShader: [ 'varying vec2 vUv;', 'void main() {', '	vUv = uv;', '	gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );', '}' ].join( '\n' ),
-			fragmentShader: [ 'varying vec2 vUv;', 'uniform sampler2D lastLum;', 'uniform sampler2D currentLum;', 'uniform float minLuminance;', 'uniform float delta;', 'uniform float tau;', 'void main() {', '	vec4 lastLum = texture2D( lastLum, vUv, MIP_LEVEL_1X1 );', '	vec4 currentLum = texture2D( currentLum, vUv, MIP_LEVEL_1X1 );', '	float fLastLum = max( minLuminance, lastLum.r );', '	float fCurrentLum = max( minLuminance, currentLum.r );', //The adaption seems to work better in extreme lighting differences
-				//if the input luminance is squared.
-				'	fCurrentLum *= fCurrentLum;', // Adapt the luminance using Pattanaik's technique
-				'	float fAdaptedLum = fLastLum + (fCurrentLum - fLastLum) * (1.0 - exp(-delta * tau));', // "fAdaptedLum = sqrt(fAdaptedLum);",
-				'	gl_FragColor.r = fAdaptedLum;', '}' ].join( '\n' )
-		};
-		this.materialAdaptiveLum = new THREE.ShaderMaterial( {
-			uniforms: THREE.UniformsUtils.clone( this.adaptLuminanceShader.uniforms ),
-			vertexShader: this.adaptLuminanceShader.vertexShader,
-			fragmentShader: this.adaptLuminanceShader.fragmentShader,
-			defines: Object.assign( {}, this.adaptLuminanceShader.defines ),
-			blending: THREE.NoBlending
-		} );
-		if ( THREE.ToneMapShader === undefined ) console.error( 'THREE.AdaptiveToneMappingPass relies on THREE.ToneMapShader' );
-		this.materialToneMap = new THREE.ShaderMaterial( {
-			uniforms: THREE.UniformsUtils.clone( THREE.ToneMapShader.uniforms ),
-			vertexShader: THREE.ToneMapShader.vertexShader,
-			fragmentShader: THREE.ToneMapShader.fragmentShader,
-			blending: THREE.NoBlending
-		} );
-		this.fsQuad = new THREE.Pass.FullScreenQuad( null );
-
-	};
-
-	AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
-		constructor: AdaptiveToneMappingPass,
-		render: function ( renderer, writeBuffer, readBuffer, deltaTime
+				vertexShader: `varying vec2 vUv;
+
+				void main() {
+
+					vUv = uv;
+					gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+				}`,
+				fragmentShader: `varying vec2 vUv;
+
+				uniform sampler2D lastLum;
+				uniform sampler2D currentLum;
+				uniform float minLuminance;
+				uniform float delta;
+				uniform float tau;
+
+				void main() {
+
+					vec4 lastLum = texture2D( lastLum, vUv, MIP_LEVEL_1X1 );
+					vec4 currentLum = texture2D( currentLum, vUv, MIP_LEVEL_1X1 );
+
+					float fLastLum = max( minLuminance, lastLum.r );
+					float fCurrentLum = max( minLuminance, currentLum.r );
+
+					//The adaption seems to work better in extreme lighting differences
+					//if the input luminance is squared.
+					fCurrentLum *= fCurrentLum;
+
+					// Adapt the luminance using Pattanaik's technique
+					float fAdaptedLum = fLastLum + (fCurrentLum - fLastLum) * (1.0 - exp(-delta * tau));
+					// "fAdaptedLum = sqrt(fAdaptedLum);
+					gl_FragColor.r = fAdaptedLum;
+				}`
+			};
+			this.materialAdaptiveLum = new THREE.ShaderMaterial( {
+				uniforms: THREE.UniformsUtils.clone( this.adaptLuminanceShader.uniforms ),
+				vertexShader: this.adaptLuminanceShader.vertexShader,
+				fragmentShader: this.adaptLuminanceShader.fragmentShader,
+				defines: Object.assign( {}, this.adaptLuminanceShader.defines ),
+				blending: THREE.NoBlending
+			} );
+			if ( THREE.ToneMapShader === undefined ) console.error( 'THREE.AdaptiveToneMappingPass relies on THREE.ToneMapShader' );
+			this.materialToneMap = new THREE.ShaderMaterial( {
+				uniforms: THREE.UniformsUtils.clone( THREE.ToneMapShader.uniforms ),
+				vertexShader: THREE.ToneMapShader.vertexShader,
+				fragmentShader: THREE.ToneMapShader.fragmentShader,
+				blending: THREE.NoBlending
+			} );
+			this.fsQuad = new THREE.FullScreenQuad( null );
+
+		}
+
+		render( renderer, writeBuffer, readBuffer, deltaTime
 			/*, maskActive*/
 			/*, maskActive*/
 		) {
 		) {
 
 
@@ -135,8 +162,9 @@
 
 
 			}
 			}
 
 
-		},
-		reset: function () {
+		}
+
+		reset() {
 
 
 			// render targets
 			// render targets
 			if ( this.luminanceRT ) {
 			if ( this.luminanceRT ) {
@@ -157,7 +185,7 @@
 
 
 			}
 			}
 
 
-			var pars = {
+			const pars = {
 				minFilter: THREE.LinearFilter,
 				minFilter: THREE.LinearFilter,
 				magFilter: THREE.LinearFilter,
 				magFilter: THREE.LinearFilter,
 				format: THREE.RGBAFormat
 				format: THREE.RGBAFormat
@@ -192,8 +220,9 @@
 			// renderer.render( this.scene, this.camera, this.previousLuminanceRT );
 			// renderer.render( this.scene, this.camera, this.previousLuminanceRT );
 			// renderer.render( this.scene, this.camera, this.currentLuminanceRT );
 			// renderer.render( this.scene, this.camera, this.currentLuminanceRT );
 
 
-		},
-		setAdaptive: function ( adaptive ) {
+		}
+
+		setAdaptive( adaptive ) {
 
 
 			if ( adaptive ) {
 			if ( adaptive ) {
 
 
@@ -211,8 +240,9 @@
 
 
 			this.materialToneMap.needsUpdate = true;
 			this.materialToneMap.needsUpdate = true;
 
 
-		},
-		setAdaptionRate: function ( rate ) {
+		}
+
+		setAdaptionRate( rate ) {
 
 
 			if ( rate ) {
 			if ( rate ) {
 
 
@@ -220,8 +250,9 @@
 
 
 			}
 			}
 
 
-		},
-		setMinLuminance: function ( minLum ) {
+		}
+
+		setMinLuminance( minLum ) {
 
 
 			if ( minLum ) {
 			if ( minLum ) {
 
 
@@ -230,8 +261,9 @@
 
 
 			}
 			}
 
 
-		},
-		setMaxLuminance: function ( maxLum ) {
+		}
+
+		setMaxLuminance( maxLum ) {
 
 
 			if ( maxLum ) {
 			if ( maxLum ) {
 
 
@@ -239,8 +271,9 @@
 
 
 			}
 			}
 
 
-		},
-		setAverageLuminance: function ( avgLum ) {
+		}
+
+		setAverageLuminance( avgLum ) {
 
 
 			if ( avgLum ) {
 			if ( avgLum ) {
 
 
@@ -248,8 +281,9 @@
 
 
 			}
 			}
 
 
-		},
-		setMiddleGrey: function ( middleGrey ) {
+		}
+
+		setMiddleGrey( middleGrey ) {
 
 
 			if ( middleGrey ) {
 			if ( middleGrey ) {
 
 
@@ -257,8 +291,9 @@
 
 
 			}
 			}
 
 
-		},
-		dispose: function () {
+		}
+
+		dispose() {
 
 
 			if ( this.luminanceRT ) {
 			if ( this.luminanceRT ) {
 
 
@@ -303,7 +338,8 @@
 			}
 			}
 
 
 		}
 		}
-	} );
+
+	}
 
 
 	THREE.AdaptiveToneMappingPass = AdaptiveToneMappingPass;
 	THREE.AdaptiveToneMappingPass = AdaptiveToneMappingPass;
 
 

+ 39 - 35
examples/js/postprocessing/AfterimagePass.js

@@ -1,36 +1,38 @@
 ( function () {
 ( function () {
 
 
-	var AfterimagePass = function ( damp ) {
-
-		THREE.Pass.call( this );
-		if ( THREE.AfterimageShader === undefined ) console.error( 'THREE.AfterimagePass relies on THREE.AfterimageShader' );
-		this.shader = THREE.AfterimageShader;
-		this.uniforms = THREE.UniformsUtils.clone( this.shader.uniforms );
-		this.uniforms[ 'damp' ].value = damp !== undefined ? damp : 0.96;
-		this.textureComp = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, {
-			minFilter: THREE.LinearFilter,
-			magFilter: THREE.NearestFilter,
-			format: THREE.RGBAFormat
-		} );
-		this.textureOld = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, {
-			minFilter: THREE.LinearFilter,
-			magFilter: THREE.NearestFilter,
-			format: THREE.RGBAFormat
-		} );
-		this.shaderMaterial = new THREE.ShaderMaterial( {
-			uniforms: this.uniforms,
-			vertexShader: this.shader.vertexShader,
-			fragmentShader: this.shader.fragmentShader
-		} );
-		this.compFsQuad = new THREE.Pass.FullScreenQuad( this.shaderMaterial );
-		var material = new THREE.MeshBasicMaterial();
-		this.copyFsQuad = new THREE.Pass.FullScreenQuad( material );
-
-	};
-
-	AfterimagePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
-		constructor: AfterimagePass,
-		render: function ( renderer, writeBuffer, readBuffer ) {
+	class AfterimagePass extends THREE.Pass {
+
+		constructor( damp = 0.96 ) {
+
+			super();
+			if ( THREE.AfterimageShader === undefined ) console.error( 'THREE.AfterimagePass relies on THREE.AfterimageShader' );
+			this.shader = THREE.AfterimageShader;
+			this.uniforms = THREE.UniformsUtils.clone( this.shader.uniforms );
+			this.uniforms[ 'damp' ].value = damp;
+			this.textureComp = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, {
+				minFilter: THREE.LinearFilter,
+				magFilter: THREE.NearestFilter,
+				format: THREE.RGBAFormat
+			} );
+			this.textureOld = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, {
+				minFilter: THREE.LinearFilter,
+				magFilter: THREE.NearestFilter,
+				format: THREE.RGBAFormat
+			} );
+			this.shaderMaterial = new THREE.ShaderMaterial( {
+				uniforms: this.uniforms,
+				vertexShader: this.shader.vertexShader,
+				fragmentShader: this.shader.fragmentShader
+			} );
+			this.compFsQuad = new THREE.FullScreenQuad( this.shaderMaterial );
+			const material = new THREE.MeshBasicMaterial();
+			this.copyFsQuad = new THREE.FullScreenQuad( material );
+
+		}
+
+		render( renderer, writeBuffer, readBuffer
+			/*, deltaTime, maskActive*/
+		) {
 
 
 			this.uniforms[ 'tOld' ].value = this.textureOld.texture;
 			this.uniforms[ 'tOld' ].value = this.textureOld.texture;
 			this.uniforms[ 'tNew' ].value = readBuffer.texture;
 			this.uniforms[ 'tNew' ].value = readBuffer.texture;
@@ -52,18 +54,20 @@
 			} // Swap buffers.
 			} // Swap buffers.
 
 
 
 
-			var temp = this.textureOld;
+			const temp = this.textureOld;
 			this.textureOld = this.textureComp;
 			this.textureOld = this.textureComp;
 			this.textureComp = temp; // Now textureOld contains the latest image, ready for the next frame.
 			this.textureComp = temp; // Now textureOld contains the latest image, ready for the next frame.
 
 
-		},
-		setSize: function ( width, height ) {
+		}
+
+		setSize( width, height ) {
 
 
 			this.textureComp.setSize( width, height );
 			this.textureComp.setSize( width, height );
 			this.textureOld.setSize( width, height );
 			this.textureOld.setSize( width, height );
 
 
 		}
 		}
-	} );
+
+	}
 
 
 	THREE.AfterimagePass = AfterimagePass;
 	THREE.AfterimagePass = AfterimagePass;
 
 

+ 51 - 53
examples/js/postprocessing/BloomPass.js

@@ -1,57 +1,53 @@
 ( function () {
 ( function () {
 
 
-	var BloomPass = function ( strength, kernelSize, sigma, resolution ) {
-
-		THREE.Pass.call( this );
-		strength = strength !== undefined ? strength : 1;
-		kernelSize = kernelSize !== undefined ? kernelSize : 25;
-		sigma = sigma !== undefined ? sigma : 4.0;
-		resolution = resolution !== undefined ? resolution : 256; // render targets
-
-		var pars = {
-			minFilter: THREE.LinearFilter,
-			magFilter: THREE.LinearFilter,
-			format: THREE.RGBAFormat
-		};
-		this.renderTargetX = new THREE.WebGLRenderTarget( resolution, resolution, pars );
-		this.renderTargetX.texture.name = 'BloomPass.x';
-		this.renderTargetY = new THREE.WebGLRenderTarget( resolution, resolution, pars );
-		this.renderTargetY.texture.name = 'BloomPass.y'; // copy material
-
-		if ( THREE.CopyShader === undefined ) console.error( 'THREE.BloomPass relies on THREE.CopyShader' );
-		var copyShader = THREE.CopyShader;
-		this.copyUniforms = THREE.UniformsUtils.clone( copyShader.uniforms );
-		this.copyUniforms[ 'opacity' ].value = strength;
-		this.materialCopy = new THREE.ShaderMaterial( {
-			uniforms: this.copyUniforms,
-			vertexShader: copyShader.vertexShader,
-			fragmentShader: copyShader.fragmentShader,
-			blending: THREE.AdditiveBlending,
-			transparent: true
-		} ); // convolution material
-
-		if ( THREE.ConvolutionShader === undefined ) console.error( 'THREE.BloomPass relies on THREE.ConvolutionShader' );
-		var convolutionShader = THREE.ConvolutionShader;
-		this.convolutionUniforms = THREE.UniformsUtils.clone( convolutionShader.uniforms );
-		this.convolutionUniforms[ 'uImageIncrement' ].value = BloomPass.blurX;
-		this.convolutionUniforms[ 'cKernel' ].value = THREE.ConvolutionShader.buildKernel( sigma );
-		this.materialConvolution = new THREE.ShaderMaterial( {
-			uniforms: this.convolutionUniforms,
-			vertexShader: convolutionShader.vertexShader,
-			fragmentShader: convolutionShader.fragmentShader,
-			defines: {
-				'KERNEL_SIZE_FLOAT': kernelSize.toFixed( 1 ),
-				'KERNEL_SIZE_INT': kernelSize.toFixed( 0 )
-			}
-		} );
-		this.needsSwap = false;
-		this.fsQuad = new THREE.Pass.FullScreenQuad( null );
-
-	};
-
-	BloomPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
-		constructor: BloomPass,
-		render: function ( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {
+	class BloomPass extends THREE.Pass {
+
+		constructor( strength = 1, kernelSize = 25, sigma = 4, resolution = 256 ) {
+
+			super(); // render targets
+
+			const pars = {
+				minFilter: THREE.LinearFilter,
+				magFilter: THREE.LinearFilter,
+				format: THREE.RGBAFormat
+			};
+			this.renderTargetX = new THREE.WebGLRenderTarget( resolution, resolution, pars );
+			this.renderTargetX.texture.name = 'BloomPass.x';
+			this.renderTargetY = new THREE.WebGLRenderTarget( resolution, resolution, pars );
+			this.renderTargetY.texture.name = 'BloomPass.y'; // copy material
+
+			if ( THREE.CopyShader === undefined ) console.error( 'THREE.BloomPass relies on THREE.CopyShader' );
+			const copyShader = THREE.CopyShader;
+			this.copyUniforms = THREE.UniformsUtils.clone( copyShader.uniforms );
+			this.copyUniforms[ 'opacity' ].value = strength;
+			this.materialCopy = new THREE.ShaderMaterial( {
+				uniforms: this.copyUniforms,
+				vertexShader: copyShader.vertexShader,
+				fragmentShader: copyShader.fragmentShader,
+				blending: THREE.AdditiveBlending,
+				transparent: true
+			} ); // convolution material
+
+			if ( THREE.ConvolutionShader === undefined ) console.error( 'THREE.BloomPass relies on THREE.ConvolutionShader' );
+			const convolutionShader = THREE.ConvolutionShader;
+			this.convolutionUniforms = THREE.UniformsUtils.clone( convolutionShader.uniforms );
+			this.convolutionUniforms[ 'uImageIncrement' ].value = BloomPass.blurX;
+			this.convolutionUniforms[ 'cKernel' ].value = THREE.ConvolutionShader.buildKernel( sigma );
+			this.materialConvolution = new THREE.ShaderMaterial( {
+				uniforms: this.convolutionUniforms,
+				vertexShader: convolutionShader.vertexShader,
+				fragmentShader: convolutionShader.fragmentShader,
+				defines: {
+					'KERNEL_SIZE_FLOAT': kernelSize.toFixed( 1 ),
+					'KERNEL_SIZE_INT': kernelSize.toFixed( 0 )
+				}
+			} );
+			this.needsSwap = false;
+			this.fsQuad = new THREE.FullScreenQuad( null );
+
+		}
+
+		render( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {
 
 
 			if ( maskActive ) renderer.state.buffers.stencil.setTest( false ); // Render quad with blured scene into texture (convolution pass 1)
 			if ( maskActive ) renderer.state.buffers.stencil.setTest( false ); // Render quad with blured scene into texture (convolution pass 1)
 
 
@@ -76,7 +72,9 @@
 			this.fsQuad.render( renderer );
 			this.fsQuad.render( renderer );
 
 
 		}
 		}
-	} );
+
+	}
+
 	BloomPass.blurX = new THREE.Vector2( 0.001953125, 0.0 );
 	BloomPass.blurX = new THREE.Vector2( 0.001953125, 0.0 );
 	BloomPass.blurY = new THREE.Vector2( 0.0, 0.001953125 );
 	BloomPass.blurY = new THREE.Vector2( 0.0, 0.001953125 );
 
 

+ 49 - 48
examples/js/postprocessing/BokehPass.js

@@ -4,67 +4,67 @@
  * Depth-of-field post-process with bokeh shader
  * Depth-of-field post-process with bokeh shader
  */
  */
 
 
-	var BokehPass = function ( scene, camera, params ) {
+	class BokehPass extends THREE.Pass {
 
 
-		THREE.Pass.call( this );
-		this.scene = scene;
-		this.camera = camera;
-		var focus = params.focus !== undefined ? params.focus : 1.0;
-		var aspect = params.aspect !== undefined ? params.aspect : camera.aspect;
-		var aperture = params.aperture !== undefined ? params.aperture : 0.025;
-		var maxblur = params.maxblur !== undefined ? params.maxblur : 1.0; // render targets
+		constructor( scene, camera, params ) {
 
 
-		var width = params.width || window.innerWidth || 1;
-		var height = params.height || window.innerHeight || 1;
-		this.renderTargetDepth = new THREE.WebGLRenderTarget( width, height, {
-			minFilter: THREE.NearestFilter,
-			magFilter: THREE.NearestFilter
-		} );
-		this.renderTargetDepth.texture.name = 'BokehPass.depth'; // depth material
+			super();
+			this.scene = scene;
+			this.camera = camera;
+			const focus = params.focus !== undefined ? params.focus : 1.0;
+			const aspect = params.aspect !== undefined ? params.aspect : camera.aspect;
+			const aperture = params.aperture !== undefined ? params.aperture : 0.025;
+			const maxblur = params.maxblur !== undefined ? params.maxblur : 1.0; // render targets
 
 
-		this.materialDepth = new THREE.MeshDepthMaterial();
-		this.materialDepth.depthPacking = THREE.RGBADepthPacking;
-		this.materialDepth.blending = THREE.NoBlending; // bokeh material
+			const width = params.width || window.innerWidth || 1;
+			const height = params.height || window.innerHeight || 1;
+			this.renderTargetDepth = new THREE.WebGLRenderTarget( width, height, {
+				minFilter: THREE.NearestFilter,
+				magFilter: THREE.NearestFilter
+			} );
+			this.renderTargetDepth.texture.name = 'BokehPass.depth'; // depth material
 
 
-		if ( THREE.BokehShader === undefined ) {
+			this.materialDepth = new THREE.MeshDepthMaterial();
+			this.materialDepth.depthPacking = THREE.RGBADepthPacking;
+			this.materialDepth.blending = THREE.NoBlending; // bokeh material
 
 
-			console.error( 'THREE.BokehPass relies on THREE.BokehShader' );
+			if ( THREE.BokehShader === undefined ) {
+
+				console.error( 'THREE.BokehPass relies on THREE.BokehShader' );
+
+			}
+
+			const bokehShader = THREE.BokehShader;
+			const bokehUniforms = THREE.UniformsUtils.clone( bokehShader.uniforms );
+			bokehUniforms[ 'tDepth' ].value = this.renderTargetDepth.texture;
+			bokehUniforms[ 'focus' ].value = focus;
+			bokehUniforms[ 'aspect' ].value = aspect;
+			bokehUniforms[ 'aperture' ].value = aperture;
+			bokehUniforms[ 'maxblur' ].value = maxblur;
+			bokehUniforms[ 'nearClip' ].value = camera.near;
+			bokehUniforms[ 'farClip' ].value = camera.far;
+			this.materialBokeh = new THREE.ShaderMaterial( {
+				defines: Object.assign( {}, bokehShader.defines ),
+				uniforms: bokehUniforms,
+				vertexShader: bokehShader.vertexShader,
+				fragmentShader: bokehShader.fragmentShader
+			} );
+			this.uniforms = bokehUniforms;
+			this.needsSwap = false;
+			this.fsQuad = new THREE.FullScreenQuad( this.materialBokeh );
+			this._oldClearColor = new THREE.Color();
 
 
 		}
 		}
 
 
-		var bokehShader = THREE.BokehShader;
-		var bokehUniforms = THREE.UniformsUtils.clone( bokehShader.uniforms );
-		bokehUniforms[ 'tDepth' ].value = this.renderTargetDepth.texture;
-		bokehUniforms[ 'focus' ].value = focus;
-		bokehUniforms[ 'aspect' ].value = aspect;
-		bokehUniforms[ 'aperture' ].value = aperture;
-		bokehUniforms[ 'maxblur' ].value = maxblur;
-		bokehUniforms[ 'nearClip' ].value = camera.near;
-		bokehUniforms[ 'farClip' ].value = camera.far;
-		this.materialBokeh = new THREE.ShaderMaterial( {
-			defines: Object.assign( {}, bokehShader.defines ),
-			uniforms: bokehUniforms,
-			vertexShader: bokehShader.vertexShader,
-			fragmentShader: bokehShader.fragmentShader
-		} );
-		this.uniforms = bokehUniforms;
-		this.needsSwap = false;
-		this.fsQuad = new THREE.Pass.FullScreenQuad( this.materialBokeh );
-		this._oldClearColor = new THREE.Color();
-
-	};
-
-	BokehPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
-		constructor: BokehPass,
-		render: function ( renderer, writeBuffer, readBuffer
+		render( renderer, writeBuffer, readBuffer
 			/*, deltaTime, maskActive*/
 			/*, deltaTime, maskActive*/
 		) {
 		) {
 
 
 			// Render depth into texture
 			// Render depth into texture
 			this.scene.overrideMaterial = this.materialDepth;
 			this.scene.overrideMaterial = this.materialDepth;
 			renderer.getClearColor( this._oldClearColor );
 			renderer.getClearColor( this._oldClearColor );
-			var oldClearAlpha = renderer.getClearAlpha();
-			var oldAutoClear = renderer.autoClear;
+			const oldClearAlpha = renderer.getClearAlpha();
+			const oldAutoClear = renderer.autoClear;
 			renderer.autoClear = false;
 			renderer.autoClear = false;
 			renderer.setClearColor( 0xffffff );
 			renderer.setClearColor( 0xffffff );
 			renderer.setClearAlpha( 1.0 );
 			renderer.setClearAlpha( 1.0 );
@@ -95,7 +95,8 @@
 			renderer.autoClear = oldAutoClear;
 			renderer.autoClear = oldAutoClear;
 
 
 		}
 		}
-	} );
+
+	}
 
 
 	THREE.BokehPass = BokehPass;
 	THREE.BokehPass = BokehPass;
 
 

+ 13 - 12
examples/js/postprocessing/ClearPass.js

@@ -1,22 +1,22 @@
 ( function () {
 ( function () {
 
 
-	var ClearPass = function ( clearColor, clearAlpha ) {
+	class ClearPass extends THREE.Pass {
 
 
-		THREE.Pass.call( this );
-		this.needsSwap = false;
-		this.clearColor = clearColor !== undefined ? clearColor : 0x000000;
-		this.clearAlpha = clearAlpha !== undefined ? clearAlpha : 0;
-		this._oldClearColor = new THREE.Color();
+		constructor( clearColor, clearAlpha ) {
 
 
-	};
+			super();
+			this.needsSwap = false;
+			this.clearColor = clearColor !== undefined ? clearColor : 0x000000;
+			this.clearAlpha = clearAlpha !== undefined ? clearAlpha : 0;
+			this._oldClearColor = new THREE.Color();
 
 
-	ClearPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
-		constructor: ClearPass,
-		render: function ( renderer, writeBuffer, readBuffer
+		}
+
+		render( renderer, writeBuffer, readBuffer
 			/*, deltaTime, maskActive */
 			/*, deltaTime, maskActive */
 		) {
 		) {
 
 
-			var oldClearAlpha;
+			let oldClearAlpha;
 
 
 			if ( this.clearColor ) {
 			if ( this.clearColor ) {
 
 
@@ -36,7 +36,8 @@
 			}
 			}
 
 
 		}
 		}
-	} );
+
+	}
 
 
 	THREE.ClearPass = ClearPass;
 	THREE.ClearPass = ClearPass;
 
 

+ 35 - 34
examples/js/postprocessing/CubeTexturePass.js

@@ -1,41 +1,41 @@
 ( function () {
 ( function () {
 
 
-	var CubeTexturePass = function ( camera, envMap, opacity ) {
-
-		THREE.Pass.call( this );
-		this.camera = camera;
-		this.needsSwap = false;
-		this.cubeShader = THREE.ShaderLib[ 'cube' ];
-		this.cubeMesh = new THREE.Mesh( new THREE.BoxGeometry( 10, 10, 10 ), new THREE.ShaderMaterial( {
-			uniforms: THREE.UniformsUtils.clone( this.cubeShader.uniforms ),
-			vertexShader: this.cubeShader.vertexShader,
-			fragmentShader: this.cubeShader.fragmentShader,
-			depthTest: false,
-			depthWrite: false,
-			side: THREE.BackSide
-		} ) );
-		Object.defineProperty( this.cubeMesh.material, 'envMap', {
-			get: function () {
-
-				return this.uniforms.envMap.value;
-
-			}
-		} );
-		this.envMap = envMap;
-		this.opacity = opacity !== undefined ? opacity : 1.0;
-		this.cubeScene = new THREE.Scene();
-		this.cubeCamera = new THREE.PerspectiveCamera();
-		this.cubeScene.add( this.cubeMesh );
-
-	};
-
-	CubeTexturePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
-		constructor: CubeTexturePass,
-		render: function ( renderer, writeBuffer, readBuffer
+	class CubeTexturePass extends THREE.Pass {
+
+		constructor( camera, envMap, opacity = 1 ) {
+
+			super();
+			this.camera = camera;
+			this.needsSwap = false;
+			this.cubeShader = THREE.ShaderLib[ 'cube' ];
+			this.cubeMesh = new THREE.Mesh( new THREE.BoxGeometry( 10, 10, 10 ), new THREE.ShaderMaterial( {
+				uniforms: THREE.UniformsUtils.clone( this.cubeShader.uniforms ),
+				vertexShader: this.cubeShader.vertexShader,
+				fragmentShader: this.cubeShader.fragmentShader,
+				depthTest: false,
+				depthWrite: false,
+				side: THREE.BackSide
+			} ) );
+			Object.defineProperty( this.cubeMesh.material, 'envMap', {
+				get: function () {
+
+					return this.uniforms.envMap.value;
+
+				}
+			} );
+			this.envMap = envMap;
+			this.opacity = opacity;
+			this.cubeScene = new THREE.Scene();
+			this.cubeCamera = new THREE.PerspectiveCamera();
+			this.cubeScene.add( this.cubeMesh );
+
+		}
+
+		render( renderer, writeBuffer, readBuffer
 			/*, deltaTime, maskActive*/
 			/*, deltaTime, maskActive*/
 		) {
 		) {
 
 
-			var oldAutoClear = renderer.autoClear;
+			const oldAutoClear = renderer.autoClear;
 			renderer.autoClear = false;
 			renderer.autoClear = false;
 			this.cubeCamera.projectionMatrix.copy( this.camera.projectionMatrix );
 			this.cubeCamera.projectionMatrix.copy( this.camera.projectionMatrix );
 			this.cubeCamera.quaternion.setFromRotationMatrix( this.camera.matrixWorld );
 			this.cubeCamera.quaternion.setFromRotationMatrix( this.camera.matrixWorld );
@@ -49,7 +49,8 @@
 			renderer.autoClear = oldAutoClear;
 			renderer.autoClear = oldAutoClear;
 
 
 		}
 		}
-	} );
+
+	}
 
 
 	THREE.CubeTexturePass = CubeTexturePass;
 	THREE.CubeTexturePass = CubeTexturePass;
 
 

+ 23 - 22
examples/js/postprocessing/DotScreenPass.js

@@ -1,26 +1,26 @@
 ( function () {
 ( function () {
 
 
-	var DotScreenPass = function ( center, angle, scale ) {
-
-		THREE.Pass.call( this );
-		if ( THREE.DotScreenShader === undefined ) console.error( 'THREE.DotScreenPass relies on THREE.DotScreenShader' );
-		var shader = THREE.DotScreenShader;
-		this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
-		if ( center !== undefined ) this.uniforms[ 'center' ].value.copy( center );
-		if ( angle !== undefined ) this.uniforms[ 'angle' ].value = angle;
-		if ( scale !== undefined ) this.uniforms[ 'scale' ].value = scale;
-		this.material = new THREE.ShaderMaterial( {
-			uniforms: this.uniforms,
-			vertexShader: shader.vertexShader,
-			fragmentShader: shader.fragmentShader
-		} );
-		this.fsQuad = new THREE.Pass.FullScreenQuad( this.material );
-
-	};
-
-	DotScreenPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
-		constructor: DotScreenPass,
-		render: function ( renderer, writeBuffer, readBuffer
+	class DotScreenPass extends THREE.Pass {
+
+		constructor( center, angle, scale ) {
+
+			super();
+			if ( THREE.DotScreenShader === undefined ) console.error( 'THREE.DotScreenPass relies on THREE.DotScreenShader' );
+			var shader = THREE.DotScreenShader;
+			this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
+			if ( center !== undefined ) this.uniforms[ 'center' ].value.copy( center );
+			if ( angle !== undefined ) this.uniforms[ 'angle' ].value = angle;
+			if ( scale !== undefined ) this.uniforms[ 'scale' ].value = scale;
+			this.material = new THREE.ShaderMaterial( {
+				uniforms: this.uniforms,
+				vertexShader: shader.vertexShader,
+				fragmentShader: shader.fragmentShader
+			} );
+			this.fsQuad = new THREE.FullScreenQuad( this.material );
+
+		}
+
+		render( renderer, writeBuffer, readBuffer
 			/*, deltaTime, maskActive */
 			/*, deltaTime, maskActive */
 		) {
 		) {
 
 
@@ -41,7 +41,8 @@
 			}
 			}
 
 
 		}
 		}
-	} );
+
+	}
 
 
 	THREE.DotScreenPass = DotScreenPass;
 	THREE.DotScreenPass = DotScreenPass;
 
 

+ 119 - 106
examples/js/postprocessing/EffectComposer.js

@@ -1,77 +1,81 @@
 ( function () {
 ( function () {
 
 
-	var EffectComposer = function ( renderer, renderTarget ) {
+	class EffectComposer {
 
 
-		this.renderer = renderer;
+		constructor( renderer, renderTarget ) {
 
 
-		if ( renderTarget === undefined ) {
+			this.renderer = renderer;
 
 
-			var parameters = {
-				minFilter: THREE.LinearFilter,
-				magFilter: THREE.LinearFilter,
-				format: THREE.RGBAFormat
-			};
-			var size = renderer.getSize( new THREE.Vector2() );
-			this._pixelRatio = renderer.getPixelRatio();
-			this._width = size.width;
-			this._height = size.height;
-			renderTarget = new THREE.WebGLRenderTarget( this._width * this._pixelRatio, this._height * this._pixelRatio, parameters );
-			renderTarget.texture.name = 'EffectComposer.rt1';
+			if ( renderTarget === undefined ) {
 
 
-		} else {
+				const parameters = {
+					minFilter: THREE.LinearFilter,
+					magFilter: THREE.LinearFilter,
+					format: THREE.RGBAFormat
+				};
+				const size = renderer.getSize( new THREE.Vector2() );
+				this._pixelRatio = renderer.getPixelRatio();
+				this._width = size.width;
+				this._height = size.height;
+				renderTarget = new THREE.WebGLRenderTarget( this._width * this._pixelRatio, this._height * this._pixelRatio, parameters );
+				renderTarget.texture.name = 'EffectComposer.rt1';
 
 
-			this._pixelRatio = 1;
-			this._width = renderTarget.width;
-			this._height = renderTarget.height;
+			} else {
 
 
-		}
+				this._pixelRatio = 1;
+				this._width = renderTarget.width;
+				this._height = renderTarget.height;
 
 
-		this.renderTarget1 = renderTarget;
-		this.renderTarget2 = renderTarget.clone();
-		this.renderTarget2.texture.name = 'EffectComposer.rt2';
-		this.writeBuffer = this.renderTarget1;
-		this.readBuffer = this.renderTarget2;
-		this.renderToScreen = true;
-		this.passes = []; // dependencies
+			}
 
 
-		if ( THREE.CopyShader === undefined ) {
+			this.renderTarget1 = renderTarget;
+			this.renderTarget2 = renderTarget.clone();
+			this.renderTarget2.texture.name = 'EffectComposer.rt2';
+			this.writeBuffer = this.renderTarget1;
+			this.readBuffer = this.renderTarget2;
+			this.renderToScreen = true;
+			this.passes = []; // dependencies
 
 
-			console.error( 'THREE.EffectComposer relies on THREE.CopyShader' );
+			if ( THREE.CopyShader === undefined ) {
 
 
-		}
+				console.error( 'THREE.EffectComposer relies on THREE.CopyShader' );
 
 
-		if ( THREE.ShaderPass === undefined ) {
+			}
 
 
-			console.error( 'THREE.EffectComposer relies on THREE.ShaderPass' );
+			if ( THREE.ShaderPass === undefined ) {
 
 
-		}
+				console.error( 'THREE.EffectComposer relies on THREE.ShaderPass' );
 
 
-		this.copyPass = new THREE.ShaderPass( THREE.CopyShader );
-		this.clock = new THREE.Clock();
+			}
 
 
-	};
+			this.copyPass = new THREE.ShaderPass( THREE.CopyShader );
+			this.clock = new THREE.Clock();
 
 
-	Object.assign( EffectComposer.prototype, {
-		swapBuffers: function () {
+		}
+
+		swapBuffers() {
 
 
-			var tmp = this.readBuffer;
+			const tmp = this.readBuffer;
 			this.readBuffer = this.writeBuffer;
 			this.readBuffer = this.writeBuffer;
 			this.writeBuffer = tmp;
 			this.writeBuffer = tmp;
 
 
-		},
-		addPass: function ( pass ) {
+		}
+
+		addPass( pass ) {
 
 
 			this.passes.push( pass );
 			this.passes.push( pass );
 			pass.setSize( this._width * this._pixelRatio, this._height * this._pixelRatio );
 			pass.setSize( this._width * this._pixelRatio, this._height * this._pixelRatio );
 
 
-		},
-		insertPass: function ( pass, index ) {
+		}
+
+		insertPass( pass, index ) {
 
 
 			this.passes.splice( index, 0, pass );
 			this.passes.splice( index, 0, pass );
 			pass.setSize( this._width * this._pixelRatio, this._height * this._pixelRatio );
 			pass.setSize( this._width * this._pixelRatio, this._height * this._pixelRatio );
 
 
-		},
-		removePass: function ( pass ) {
+		}
+
+		removePass( pass ) {
 
 
 			const index = this.passes.indexOf( pass );
 			const index = this.passes.indexOf( pass );
 
 
@@ -81,10 +85,11 @@
 
 
 			}
 			}
 
 
-		},
-		isLastEnabledPass: function ( passIndex ) {
+		}
+
+		isLastEnabledPass( passIndex ) {
 
 
-			for ( var i = passIndex + 1; i < this.passes.length; i ++ ) {
+			for ( let i = passIndex + 1; i < this.passes.length; i ++ ) {
 
 
 				if ( this.passes[ i ].enabled ) {
 				if ( this.passes[ i ].enabled ) {
 
 
@@ -96,8 +101,9 @@
 
 
 			return true;
 			return true;
 
 
-		},
-		render: function ( deltaTime ) {
+		}
+
+		render( deltaTime ) {
 
 
 			// deltaTime value is in seconds
 			// deltaTime value is in seconds
 			if ( deltaTime === undefined ) {
 			if ( deltaTime === undefined ) {
@@ -106,15 +112,12 @@
 
 
 			}
 			}
 
 
-			var currentRenderTarget = this.renderer.getRenderTarget();
-			var maskActive = false;
-			var pass,
-				i,
-				il = this.passes.length;
+			const currentRenderTarget = this.renderer.getRenderTarget();
+			let maskActive = false;
 
 
-			for ( i = 0; i < il; i ++ ) {
+			for ( let i = 0, il = this.passes.length; i < il; i ++ ) {
 
 
-				pass = this.passes[ i ];
+				const pass = this.passes[ i ];
 				if ( pass.enabled === false ) continue;
 				if ( pass.enabled === false ) continue;
 				pass.renderToScreen = this.renderToScreen && this.isLastEnabledPass( i );
 				pass.renderToScreen = this.renderToScreen && this.isLastEnabledPass( i );
 				pass.render( this.renderer, this.writeBuffer, this.readBuffer, deltaTime, maskActive );
 				pass.render( this.renderer, this.writeBuffer, this.readBuffer, deltaTime, maskActive );
@@ -123,8 +126,8 @@
 
 
 					if ( maskActive ) {
 					if ( maskActive ) {
 
 
-						var context = this.renderer.getContext();
-						var stencil = this.renderer.state.buffers.stencil; //context.stencilFunc( context.NOTEQUAL, 1, 0xffffffff );
+						const context = this.renderer.getContext();
+						const stencil = this.renderer.state.buffers.stencil; //context.stencilFunc( context.NOTEQUAL, 1, 0xffffffff );
 
 
 						stencil.setFunc( context.NOTEQUAL, 1, 0xffffffff );
 						stencil.setFunc( context.NOTEQUAL, 1, 0xffffffff );
 						this.copyPass.render( this.renderer, this.writeBuffer, this.readBuffer, deltaTime ); //context.stencilFunc( context.EQUAL, 1, 0xffffffff );
 						this.copyPass.render( this.renderer, this.writeBuffer, this.readBuffer, deltaTime ); //context.stencilFunc( context.EQUAL, 1, 0xffffffff );
@@ -155,12 +158,13 @@
 
 
 			this.renderer.setRenderTarget( currentRenderTarget );
 			this.renderer.setRenderTarget( currentRenderTarget );
 
 
-		},
-		reset: function ( renderTarget ) {
+		}
+
+		reset( renderTarget ) {
 
 
 			if ( renderTarget === undefined ) {
 			if ( renderTarget === undefined ) {
 
 
-				var size = this.renderer.getSize( new THREE.Vector2() );
+				const size = this.renderer.getSize( new THREE.Vector2() );
 				this._pixelRatio = this.renderer.getPixelRatio();
 				this._pixelRatio = this.renderer.getPixelRatio();
 				this._width = size.width;
 				this._width = size.width;
 				this._height = size.height;
 				this._height = size.height;
@@ -176,96 +180,105 @@
 			this.writeBuffer = this.renderTarget1;
 			this.writeBuffer = this.renderTarget1;
 			this.readBuffer = this.renderTarget2;
 			this.readBuffer = this.renderTarget2;
 
 
-		},
-		setSize: function ( width, height ) {
+		}
+
+		setSize( width, height ) {
 
 
 			this._width = width;
 			this._width = width;
 			this._height = height;
 			this._height = height;
-			var effectiveWidth = this._width * this._pixelRatio;
-			var effectiveHeight = this._height * this._pixelRatio;
+			const effectiveWidth = this._width * this._pixelRatio;
+			const effectiveHeight = this._height * this._pixelRatio;
 			this.renderTarget1.setSize( effectiveWidth, effectiveHeight );
 			this.renderTarget1.setSize( effectiveWidth, effectiveHeight );
 			this.renderTarget2.setSize( effectiveWidth, effectiveHeight );
 			this.renderTarget2.setSize( effectiveWidth, effectiveHeight );
 
 
-			for ( var i = 0; i < this.passes.length; i ++ ) {
+			for ( let i = 0; i < this.passes.length; i ++ ) {
 
 
 				this.passes[ i ].setSize( effectiveWidth, effectiveHeight );
 				this.passes[ i ].setSize( effectiveWidth, effectiveHeight );
 
 
 			}
 			}
 
 
-		},
-		setPixelRatio: function ( pixelRatio ) {
+		}
+
+		setPixelRatio( pixelRatio ) {
 
 
 			this._pixelRatio = pixelRatio;
 			this._pixelRatio = pixelRatio;
 			this.setSize( this._width, this._height );
 			this.setSize( this._width, this._height );
 
 
 		}
 		}
-	} );
 
 
-	var Pass = function () {
+	}
 
 
-		// if set to true, the pass is processed by the composer
-		this.enabled = true; // if set to true, the pass indicates to swap read and write buffer after rendering
+	class Pass {
 
 
-		this.needsSwap = true; // if set to true, the pass clears its buffer before rendering
+		constructor() {
 
 
-		this.clear = false; // if set to true, the result of the pass is rendered to screen. This is set automatically by EffectComposer.
+			// if set to true, the pass is processed by the composer
+			this.enabled = true; // if set to true, the pass indicates to swap read and write buffer after rendering
 
 
-		this.renderToScreen = false;
+			this.needsSwap = true; // if set to true, the pass clears its buffer before rendering
 
 
-	};
+			this.clear = false; // if set to true, the result of the pass is rendered to screen. This is set automatically by EffectComposer.
 
 
-	Object.assign( Pass.prototype, {
-		setSize: function ( ) {},
-		render: function ( ) {
+			this.renderToScreen = false;
+
+		}
+
+		setSize( ) {}
+
+		render( ) {
 
 
 			console.error( 'THREE.Pass: .render() must be implemented in derived pass.' );
 			console.error( 'THREE.Pass: .render() must be implemented in derived pass.' );
 
 
 		}
 		}
-	} ); // Helper for passes that need to fill the viewport with a single quad.
 
 
-	Pass.FullScreenQuad = function () {
+	} // Helper for passes that need to fill the viewport with a single quad.
 
 
-		var camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); // https://github.com/mrdoob/three.js/pull/21358
 
 
-		var geometry = new THREE.BufferGeometry();
-		geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );
-		geometry.setAttribute( 'uv', new THREE.Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );
+	const _camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); // https://github.com/mrdoob/three.js/pull/21358
 
 
-		var FullScreenQuad = function ( material ) {
 
 
-			this._mesh = new THREE.Mesh( geometry, material );
+	const _geometry = new THREE.BufferGeometry();
 
 
-		};
+	_geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );
 
 
-		Object.defineProperty( FullScreenQuad.prototype, 'material', {
-			get: function () {
+	_geometry.setAttribute( 'uv', new THREE.Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );
 
 
-				return this._mesh.material;
+	class FullScreenQuad {
 
 
-			},
-			set: function ( value ) {
+		constructor( material ) {
 
 
-				this._mesh.material = value;
+			this._mesh = new THREE.Mesh( _geometry, material );
 
 
-			}
-		} );
-		Object.assign( FullScreenQuad.prototype, {
-			dispose: function () {
+		}
 
 
-				this._mesh.geometry.dispose();
+		dispose() {
 
 
-			},
-			render: function ( renderer ) {
+			this._mesh.geometry.dispose();
 
 
-				renderer.render( this._mesh, camera );
+		}
 
 
-			}
-		} );
-		return FullScreenQuad;
+		render( renderer ) {
+
+			renderer.render( this._mesh, _camera );
+
+		}
+
+		get material() {
+
+			return this._mesh.material;
+
+		}
+
+		set material( value ) {
+
+			this._mesh.material = value;
+
+		}
 
 
-	}();
+	}
 
 
 	THREE.EffectComposer = EffectComposer;
 	THREE.EffectComposer = EffectComposer;
+	THREE.FullScreenQuad = FullScreenQuad;
 	THREE.Pass = Pass;
 	THREE.Pass = Pass;
 
 
 } )();
 } )();

+ 24 - 23
examples/js/postprocessing/FilmPass.js

@@ -1,27 +1,27 @@
 ( function () {
 ( function () {
 
 
-	var FilmPass = function ( noiseIntensity, scanlinesIntensity, scanlinesCount, grayscale ) {
-
-		THREE.Pass.call( this );
-		if ( THREE.FilmShader === undefined ) console.error( 'THREE.FilmPass relies on THREE.FilmShader' );
-		var shader = THREE.FilmShader;
-		this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
-		this.material = new THREE.ShaderMaterial( {
-			uniforms: this.uniforms,
-			vertexShader: shader.vertexShader,
-			fragmentShader: shader.fragmentShader
-		} );
-		if ( grayscale !== undefined ) this.uniforms.grayscale.value = grayscale;
-		if ( noiseIntensity !== undefined ) this.uniforms.nIntensity.value = noiseIntensity;
-		if ( scanlinesIntensity !== undefined ) this.uniforms.sIntensity.value = scanlinesIntensity;
-		if ( scanlinesCount !== undefined ) this.uniforms.sCount.value = scanlinesCount;
-		this.fsQuad = new THREE.Pass.FullScreenQuad( this.material );
-
-	};
-
-	FilmPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
-		constructor: FilmPass,
-		render: function ( renderer, writeBuffer, readBuffer, deltaTime
+	class FilmPass extends THREE.Pass {
+
+		constructor( noiseIntensity, scanlinesIntensity, scanlinesCount, grayscale ) {
+
+			super();
+			if ( THREE.FilmShader === undefined ) console.error( 'THREE.FilmPass relies on THREE.FilmShader' );
+			const shader = THREE.FilmShader;
+			this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
+			this.material = new THREE.ShaderMaterial( {
+				uniforms: this.uniforms,
+				vertexShader: shader.vertexShader,
+				fragmentShader: shader.fragmentShader
+			} );
+			if ( grayscale !== undefined ) this.uniforms.grayscale.value = grayscale;
+			if ( noiseIntensity !== undefined ) this.uniforms.nIntensity.value = noiseIntensity;
+			if ( scanlinesIntensity !== undefined ) this.uniforms.sIntensity.value = scanlinesIntensity;
+			if ( scanlinesCount !== undefined ) this.uniforms.sCount.value = scanlinesCount;
+			this.fsQuad = new THREE.FullScreenQuad( this.material );
+
+		}
+
+		render( renderer, writeBuffer, readBuffer, deltaTime
 			/*, maskActive */
 			/*, maskActive */
 		) {
 		) {
 
 
@@ -42,7 +42,8 @@
 			}
 			}
 
 
 		}
 		}
-	} );
+
+	}
 
 
 	THREE.FilmPass = FilmPass;
 	THREE.FilmPass = FilmPass;
 
 

+ 34 - 32
examples/js/postprocessing/GlitchPass.js

@@ -1,28 +1,27 @@
 ( function () {
 ( function () {
 
 
-	var GlitchPass = function ( dt_size ) {
-
-		THREE.Pass.call( this );
-		if ( THREE.DigitalGlitch === undefined ) console.error( 'THREE.GlitchPass relies on THREE.DigitalGlitch' );
-		var shader = THREE.DigitalGlitch;
-		this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
-		if ( dt_size == undefined ) dt_size = 64;
-		this.uniforms[ 'tDisp' ].value = this.generateHeightmap( dt_size );
-		this.material = new THREE.ShaderMaterial( {
-			uniforms: this.uniforms,
-			vertexShader: shader.vertexShader,
-			fragmentShader: shader.fragmentShader
-		} );
-		this.fsQuad = new THREE.Pass.FullScreenQuad( this.material );
-		this.goWild = false;
-		this.curF = 0;
-		this.generateTrigger();
-
-	};
-
-	GlitchPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
-		constructor: GlitchPass,
-		render: function ( renderer, writeBuffer, readBuffer
+	class GlitchPass extends THREE.Pass {
+
+		constructor( dt_size = 64 ) {
+
+			super();
+			if ( THREE.DigitalGlitch === undefined ) console.error( 'THREE.GlitchPass relies on THREE.DigitalGlitch' );
+			const shader = THREE.DigitalGlitch;
+			this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
+			this.uniforms[ 'tDisp' ].value = this.generateHeightmap( dt_size );
+			this.material = new THREE.ShaderMaterial( {
+				uniforms: this.uniforms,
+				vertexShader: shader.vertexShader,
+				fragmentShader: shader.fragmentShader
+			} );
+			this.fsQuad = new THREE.FullScreenQuad( this.material );
+			this.goWild = false;
+			this.curF = 0;
+			this.generateTrigger();
+
+		}
+
+		render( renderer, writeBuffer, readBuffer
 			/*, deltaTime, maskActive */
 			/*, deltaTime, maskActive */
 		) {
 		) {
 
 
@@ -72,20 +71,22 @@
 
 
 			}
 			}
 
 
-		},
-		generateTrigger: function () {
+		}
+
+		generateTrigger() {
 
 
 			this.randX = THREE.MathUtils.randInt( 120, 240 );
 			this.randX = THREE.MathUtils.randInt( 120, 240 );
 
 
-		},
-		generateHeightmap: function ( dt_size ) {
+		}
+
+		generateHeightmap( dt_size ) {
 
 
-			var data_arr = new Float32Array( dt_size * dt_size * 3 );
-			var length = dt_size * dt_size;
+			const data_arr = new Float32Array( dt_size * dt_size * 3 );
+			const length = dt_size * dt_size;
 
 
-			for ( var i = 0; i < length; i ++ ) {
+			for ( let i = 0; i < length; i ++ ) {
 
 
-				var val = THREE.MathUtils.randFloat( 0, 1 );
+				const val = THREE.MathUtils.randFloat( 0, 1 );
 				data_arr[ i * 3 + 0 ] = val;
 				data_arr[ i * 3 + 0 ] = val;
 				data_arr[ i * 3 + 1 ] = val;
 				data_arr[ i * 3 + 1 ] = val;
 				data_arr[ i * 3 + 2 ] = val;
 				data_arr[ i * 3 + 2 ] = val;
@@ -95,7 +96,8 @@
 			return new THREE.DataTexture( data_arr, dt_size, dt_size, THREE.RGBFormat, THREE.FloatType );
 			return new THREE.DataTexture( data_arr, dt_size, dt_size, THREE.RGBFormat, THREE.FloatType );
 
 
 		}
 		}
-	} );
+
+	}
 
 
 	THREE.GlitchPass = GlitchPass;
 	THREE.GlitchPass = GlitchPass;
 
 

+ 28 - 26
examples/js/postprocessing/HalftonePass.js

@@ -4,43 +4,43 @@
  * RGB Halftone pass for three.js effects composer. Requires THREE.HalftoneShader.
  * RGB Halftone pass for three.js effects composer. Requires THREE.HalftoneShader.
  */
  */
 
 
-	var HalftonePass = function ( width, height, params ) {
+	class HalftonePass extends THREE.Pass {
 
 
-		THREE.Pass.call( this );
+		constructor( width, height, params ) {
 
 
-		if ( THREE.HalftoneShader === undefined ) {
+			super();
 
 
-			console.error( 'THREE.HalftonePass requires THREE.HalftoneShader' );
+			if ( THREE.HalftoneShader === undefined ) {
 
 
-		}
+				console.error( 'THREE.HalftonePass requires THREE.HalftoneShader' );
 
 
-		this.uniforms = THREE.UniformsUtils.clone( THREE.HalftoneShader.uniforms );
-		this.material = new THREE.ShaderMaterial( {
-			uniforms: this.uniforms,
-			fragmentShader: THREE.HalftoneShader.fragmentShader,
-			vertexShader: THREE.HalftoneShader.vertexShader
-		} ); // set params
+			}
 
 
-		this.uniforms.width.value = width;
-		this.uniforms.height.value = height;
+			this.uniforms = THREE.UniformsUtils.clone( THREE.HalftoneShader.uniforms );
+			this.material = new THREE.ShaderMaterial( {
+				uniforms: this.uniforms,
+				fragmentShader: THREE.HalftoneShader.fragmentShader,
+				vertexShader: THREE.HalftoneShader.vertexShader
+			} ); // set params
 
 
-		for ( var key in params ) {
+			this.uniforms.width.value = width;
+			this.uniforms.height.value = height;
 
 
-			if ( params.hasOwnProperty( key ) && this.uniforms.hasOwnProperty( key ) ) {
+			for ( const key in params ) {
 
 
-				this.uniforms[ key ].value = params[ key ];
+				if ( params.hasOwnProperty( key ) && this.uniforms.hasOwnProperty( key ) ) {
 
 
-			}
+					this.uniforms[ key ].value = params[ key ];
 
 
-		}
+				}
 
 
-		this.fsQuad = new THREE.Pass.FullScreenQuad( this.material );
+			}
+
+			this.fsQuad = new THREE.FullScreenQuad( this.material );
 
 
-	};
+		}
 
 
-	HalftonePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
-		constructor: HalftonePass,
-		render: function ( renderer, writeBuffer, readBuffer
+		render( renderer, writeBuffer, readBuffer
 			/*, deltaTime, maskActive*/
 			/*, deltaTime, maskActive*/
 		) {
 		) {
 
 
@@ -59,14 +59,16 @@
 
 
 			}
 			}
 
 
-		},
-		setSize: function ( width, height ) {
+		}
+
+		setSize( width, height ) {
 
 
 			this.uniforms.width.value = width;
 			this.uniforms.width.value = width;
 			this.uniforms.height.value = height;
 			this.uniforms.height.value = height;
 
 
 		}
 		}
-	} );
+
+	}
 
 
 	THREE.HalftonePass = HalftonePass;
 	THREE.HalftonePass = HalftonePass;
 
 

+ 25 - 23
examples/js/postprocessing/MaskPass.js

@@ -1,24 +1,24 @@
 ( function () {
 ( function () {
 
 
-	var MaskPass = function ( scene, camera ) {
+	class MaskPass extends THREE.Pass {
 
 
-		THREE.Pass.call( this );
-		this.scene = scene;
-		this.camera = camera;
-		this.clear = true;
-		this.needsSwap = false;
-		this.inverse = false;
+		constructor( scene, camera ) {
 
 
-	};
+			super();
+			this.scene = scene;
+			this.camera = camera;
+			this.clear = true;
+			this.needsSwap = false;
+			this.inverse = false;
 
 
-	MaskPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
-		constructor: MaskPass,
-		render: function ( renderer, writeBuffer, readBuffer
+		}
+
+		render( renderer, writeBuffer, readBuffer
 			/*, deltaTime, maskActive */
 			/*, deltaTime, maskActive */
 		) {
 		) {
 
 
-			var context = renderer.getContext();
-			var state = renderer.state; // don't update color or depth
+			const context = renderer.getContext();
+			const state = renderer.state; // don't update color or depth
 
 
 			state.buffers.color.setMask( false );
 			state.buffers.color.setMask( false );
 			state.buffers.depth.setMask( false ); // lock buffers
 			state.buffers.depth.setMask( false ); // lock buffers
@@ -26,7 +26,7 @@
 			state.buffers.color.setLocked( true );
 			state.buffers.color.setLocked( true );
 			state.buffers.depth.setLocked( true ); // set up stencil
 			state.buffers.depth.setLocked( true ); // set up stencil
 
 
-			var writeValue, clearValue;
+			let writeValue, clearValue;
 
 
 			if ( this.inverse ) {
 			if ( this.inverse ) {
 
 
@@ -63,18 +63,19 @@
 			state.buffers.stencil.setLocked( true );
 			state.buffers.stencil.setLocked( true );
 
 
 		}
 		}
-	} );
 
 
-	var ClearMaskPass = function () {
+	}
+
+	class ClearMaskPass extends THREE.Pass {
 
 
-		THREE.Pass.call( this );
-		this.needsSwap = false;
+		constructor() {
 
 
-	};
+			super();
+			this.needsSwap = false;
 
 
-	ClearMaskPass.prototype = Object.create( THREE.Pass.prototype );
-	Object.assign( ClearMaskPass.prototype, {
-		render: function ( renderer
+		}
+
+		render( renderer
 			/*, writeBuffer, readBuffer, deltaTime, maskActive */
 			/*, writeBuffer, readBuffer, deltaTime, maskActive */
 		) {
 		) {
 
 
@@ -82,7 +83,8 @@
 			renderer.state.buffers.stencil.setTest( false );
 			renderer.state.buffers.stencil.setTest( false );
 
 
 		}
 		}
-	} );
+
+	}
 
 
 	THREE.ClearMaskPass = ClearMaskPass;
 	THREE.ClearMaskPass = ClearMaskPass;
 	THREE.MaskPass = MaskPass;
 	THREE.MaskPass = MaskPass;

+ 268 - 219
examples/js/postprocessing/OutlinePass.js

@@ -1,106 +1,106 @@
 ( function () {
 ( function () {
 
 
-	var OutlinePass = function ( resolution, scene, camera, selectedObjects ) {
-
-		this.renderScene = scene;
-		this.renderCamera = camera;
-		this.selectedObjects = selectedObjects !== undefined ? selectedObjects : [];
-		this.visibleEdgeColor = new THREE.Color( 1, 1, 1 );
-		this.hiddenEdgeColor = new THREE.Color( 0.1, 0.04, 0.02 );
-		this.edgeGlow = 0.0;
-		this.usePatternTexture = false;
-		this.edgeThickness = 1.0;
-		this.edgeStrength = 3.0;
-		this.downSampleRatio = 2;
-		this.pulsePeriod = 0;
-		this._visibilityCache = new Map();
-		THREE.Pass.call( this );
-		this.resolution = resolution !== undefined ? new THREE.Vector2( resolution.x, resolution.y ) : new THREE.Vector2( 256, 256 );
-		var pars = {
-			minFilter: THREE.LinearFilter,
-			magFilter: THREE.LinearFilter,
-			format: THREE.RGBAFormat
-		};
-		var resx = Math.round( this.resolution.x / this.downSampleRatio );
-		var resy = Math.round( this.resolution.y / this.downSampleRatio );
-		this.maskBufferMaterial = new THREE.MeshBasicMaterial( {
-			color: 0xffffff
-		} );
-		this.maskBufferMaterial.side = THREE.DoubleSide;
-		this.renderTargetMaskBuffer = new THREE.WebGLRenderTarget( this.resolution.x, this.resolution.y, pars );
-		this.renderTargetMaskBuffer.texture.name = 'OutlinePass.mask';
-		this.renderTargetMaskBuffer.texture.generateMipmaps = false;
-		this.depthMaterial = new THREE.MeshDepthMaterial();
-		this.depthMaterial.side = THREE.DoubleSide;
-		this.depthMaterial.depthPacking = THREE.RGBADepthPacking;
-		this.depthMaterial.blending = THREE.NoBlending;
-		this.prepareMaskMaterial = this.getPrepareMaskMaterial();
-		this.prepareMaskMaterial.side = THREE.DoubleSide;
-		this.prepareMaskMaterial.fragmentShader = replaceDepthToViewZ( this.prepareMaskMaterial.fragmentShader, this.renderCamera );
-		this.renderTargetDepthBuffer = new THREE.WebGLRenderTarget( this.resolution.x, this.resolution.y, pars );
-		this.renderTargetDepthBuffer.texture.name = 'OutlinePass.depth';
-		this.renderTargetDepthBuffer.texture.generateMipmaps = false;
-		this.renderTargetMaskDownSampleBuffer = new THREE.WebGLRenderTarget( resx, resy, pars );
-		this.renderTargetMaskDownSampleBuffer.texture.name = 'OutlinePass.depthDownSample';
-		this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps = false;
-		this.renderTargetBlurBuffer1 = new THREE.WebGLRenderTarget( resx, resy, pars );
-		this.renderTargetBlurBuffer1.texture.name = 'OutlinePass.blur1';
-		this.renderTargetBlurBuffer1.texture.generateMipmaps = false;
-		this.renderTargetBlurBuffer2 = new THREE.WebGLRenderTarget( Math.round( resx / 2 ), Math.round( resy / 2 ), pars );
-		this.renderTargetBlurBuffer2.texture.name = 'OutlinePass.blur2';
-		this.renderTargetBlurBuffer2.texture.generateMipmaps = false;
-		this.edgeDetectionMaterial = this.getEdgeDetectionMaterial();
-		this.renderTargetEdgeBuffer1 = new THREE.WebGLRenderTarget( resx, resy, pars );
-		this.renderTargetEdgeBuffer1.texture.name = 'OutlinePass.edge1';
-		this.renderTargetEdgeBuffer1.texture.generateMipmaps = false;
-		this.renderTargetEdgeBuffer2 = new THREE.WebGLRenderTarget( Math.round( resx / 2 ), Math.round( resy / 2 ), pars );
-		this.renderTargetEdgeBuffer2.texture.name = 'OutlinePass.edge2';
-		this.renderTargetEdgeBuffer2.texture.generateMipmaps = false;
-		var MAX_EDGE_THICKNESS = 4;
-		var MAX_EDGE_GLOW = 4;
-		this.separableBlurMaterial1 = this.getSeperableBlurMaterial( MAX_EDGE_THICKNESS );
-		this.separableBlurMaterial1.uniforms[ 'texSize' ].value.set( resx, resy );
-		this.separableBlurMaterial1.uniforms[ 'kernelRadius' ].value = 1;
-		this.separableBlurMaterial2 = this.getSeperableBlurMaterial( MAX_EDGE_GLOW );
-		this.separableBlurMaterial2.uniforms[ 'texSize' ].value.set( Math.round( resx / 2 ), Math.round( resy / 2 ) );
-		this.separableBlurMaterial2.uniforms[ 'kernelRadius' ].value = MAX_EDGE_GLOW; // Overlay material
-
-		this.overlayMaterial = this.getOverlayMaterial(); // copy material
-
-		if ( THREE.CopyShader === undefined ) console.error( 'THREE.OutlinePass relies on THREE.CopyShader' );
-		var copyShader = THREE.CopyShader;
-		this.copyUniforms = THREE.UniformsUtils.clone( copyShader.uniforms );
-		this.copyUniforms[ 'opacity' ].value = 1.0;
-		this.materialCopy = new THREE.ShaderMaterial( {
-			uniforms: this.copyUniforms,
-			vertexShader: copyShader.vertexShader,
-			fragmentShader: copyShader.fragmentShader,
-			blending: THREE.NoBlending,
-			depthTest: false,
-			depthWrite: false,
-			transparent: true
-		} );
-		this.enabled = true;
-		this.needsSwap = false;
-		this._oldClearColor = new THREE.Color();
-		this.oldClearAlpha = 1;
-		this.fsQuad = new THREE.Pass.FullScreenQuad( null );
-		this.tempPulseColor1 = new THREE.Color();
-		this.tempPulseColor2 = new THREE.Color();
-		this.textureMatrix = new THREE.Matrix4();
-
-		function replaceDepthToViewZ( string, camera ) {
-
-			var type = camera.isPerspectiveCamera ? 'perspective' : 'orthographic';
-			return string.replace( /DEPTH_TO_VIEW_Z/g, type + 'DepthToViewZ' );
+	class OutlinePass extends THREE.Pass {
+
+		constructor( resolution, scene, camera, selectedObjects ) {
+
+			super();
+			this.renderScene = scene;
+			this.renderCamera = camera;
+			this.selectedObjects = selectedObjects !== undefined ? selectedObjects : [];
+			this.visibleEdgeColor = new THREE.Color( 1, 1, 1 );
+			this.hiddenEdgeColor = new THREE.Color( 0.1, 0.04, 0.02 );
+			this.edgeGlow = 0.0;
+			this.usePatternTexture = false;
+			this.edgeThickness = 1.0;
+			this.edgeStrength = 3.0;
+			this.downSampleRatio = 2;
+			this.pulsePeriod = 0;
+			this._visibilityCache = new Map();
+			this.resolution = resolution !== undefined ? new THREE.Vector2( resolution.x, resolution.y ) : new THREE.Vector2( 256, 256 );
+			const pars = {
+				minFilter: THREE.LinearFilter,
+				magFilter: THREE.LinearFilter,
+				format: THREE.RGBAFormat
+			};
+			const resx = Math.round( this.resolution.x / this.downSampleRatio );
+			const resy = Math.round( this.resolution.y / this.downSampleRatio );
+			this.maskBufferMaterial = new THREE.MeshBasicMaterial( {
+				color: 0xffffff
+			} );
+			this.maskBufferMaterial.side = THREE.DoubleSide;
+			this.renderTargetMaskBuffer = new THREE.WebGLRenderTarget( this.resolution.x, this.resolution.y, pars );
+			this.renderTargetMaskBuffer.texture.name = 'OutlinePass.mask';
+			this.renderTargetMaskBuffer.texture.generateMipmaps = false;
+			this.depthMaterial = new THREE.MeshDepthMaterial();
+			this.depthMaterial.side = THREE.DoubleSide;
+			this.depthMaterial.depthPacking = THREE.RGBADepthPacking;
+			this.depthMaterial.blending = THREE.NoBlending;
+			this.prepareMaskMaterial = this.getPrepareMaskMaterial();
+			this.prepareMaskMaterial.side = THREE.DoubleSide;
+			this.prepareMaskMaterial.fragmentShader = replaceDepthToViewZ( this.prepareMaskMaterial.fragmentShader, this.renderCamera );
+			this.renderTargetDepthBuffer = new THREE.WebGLRenderTarget( this.resolution.x, this.resolution.y, pars );
+			this.renderTargetDepthBuffer.texture.name = 'OutlinePass.depth';
+			this.renderTargetDepthBuffer.texture.generateMipmaps = false;
+			this.renderTargetMaskDownSampleBuffer = new THREE.WebGLRenderTarget( resx, resy, pars );
+			this.renderTargetMaskDownSampleBuffer.texture.name = 'OutlinePass.depthDownSample';
+			this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps = false;
+			this.renderTargetBlurBuffer1 = new THREE.WebGLRenderTarget( resx, resy, pars );
+			this.renderTargetBlurBuffer1.texture.name = 'OutlinePass.blur1';
+			this.renderTargetBlurBuffer1.texture.generateMipmaps = false;
+			this.renderTargetBlurBuffer2 = new THREE.WebGLRenderTarget( Math.round( resx / 2 ), Math.round( resy / 2 ), pars );
+			this.renderTargetBlurBuffer2.texture.name = 'OutlinePass.blur2';
+			this.renderTargetBlurBuffer2.texture.generateMipmaps = false;
+			this.edgeDetectionMaterial = this.getEdgeDetectionMaterial();
+			this.renderTargetEdgeBuffer1 = new THREE.WebGLRenderTarget( resx, resy, pars );
+			this.renderTargetEdgeBuffer1.texture.name = 'OutlinePass.edge1';
+			this.renderTargetEdgeBuffer1.texture.generateMipmaps = false;
+			this.renderTargetEdgeBuffer2 = new THREE.WebGLRenderTarget( Math.round( resx / 2 ), Math.round( resy / 2 ), pars );
+			this.renderTargetEdgeBuffer2.texture.name = 'OutlinePass.edge2';
+			this.renderTargetEdgeBuffer2.texture.generateMipmaps = false;
+			const MAX_EDGE_THICKNESS = 4;
+			const MAX_EDGE_GLOW = 4;
+			this.separableBlurMaterial1 = this.getSeperableBlurMaterial( MAX_EDGE_THICKNESS );
+			this.separableBlurMaterial1.uniforms[ 'texSize' ].value.set( resx, resy );
+			this.separableBlurMaterial1.uniforms[ 'kernelRadius' ].value = 1;
+			this.separableBlurMaterial2 = this.getSeperableBlurMaterial( MAX_EDGE_GLOW );
+			this.separableBlurMaterial2.uniforms[ 'texSize' ].value.set( Math.round( resx / 2 ), Math.round( resy / 2 ) );
+			this.separableBlurMaterial2.uniforms[ 'kernelRadius' ].value = MAX_EDGE_GLOW; // Overlay material
+
+			this.overlayMaterial = this.getOverlayMaterial(); // copy material
+
+			if ( THREE.CopyShader === undefined ) console.error( 'THREE.OutlinePass relies on THREE.CopyShader' );
+			const copyShader = THREE.CopyShader;
+			this.copyUniforms = THREE.UniformsUtils.clone( copyShader.uniforms );
+			this.copyUniforms[ 'opacity' ].value = 1.0;
+			this.materialCopy = new THREE.ShaderMaterial( {
+				uniforms: this.copyUniforms,
+				vertexShader: copyShader.vertexShader,
+				fragmentShader: copyShader.fragmentShader,
+				blending: THREE.NoBlending,
+				depthTest: false,
+				depthWrite: false,
+				transparent: true
+			} );
+			this.enabled = true;
+			this.needsSwap = false;
+			this._oldClearColor = new THREE.Color();
+			this.oldClearAlpha = 1;
+			this.fsQuad = new THREE.FullScreenQuad( null );
+			this.tempPulseColor1 = new THREE.Color();
+			this.tempPulseColor2 = new THREE.Color();
+			this.textureMatrix = new THREE.Matrix4();
 
 
-		}
+			function replaceDepthToViewZ( string, camera ) {
+
+				var type = camera.isPerspectiveCamera ? 'perspective' : 'orthographic';
+				return string.replace( /DEPTH_TO_VIEW_Z/g, type + 'DepthToViewZ' );
 
 
-	};
+			}
+
+		}
 
 
-	OutlinePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
-		constructor: OutlinePass,
-		dispose: function () {
+		dispose() {
 
 
 			this.renderTargetMaskBuffer.dispose();
 			this.renderTargetMaskBuffer.dispose();
 			this.renderTargetDepthBuffer.dispose();
 			this.renderTargetDepthBuffer.dispose();
@@ -110,13 +110,14 @@
 			this.renderTargetEdgeBuffer1.dispose();
 			this.renderTargetEdgeBuffer1.dispose();
 			this.renderTargetEdgeBuffer2.dispose();
 			this.renderTargetEdgeBuffer2.dispose();
 
 
-		},
-		setSize: function ( width, height ) {
+		}
+
+		setSize( width, height ) {
 
 
 			this.renderTargetMaskBuffer.setSize( width, height );
 			this.renderTargetMaskBuffer.setSize( width, height );
 			this.renderTargetDepthBuffer.setSize( width, height );
 			this.renderTargetDepthBuffer.setSize( width, height );
-			var resx = Math.round( width / this.downSampleRatio );
-			var resy = Math.round( height / this.downSampleRatio );
+			let resx = Math.round( width / this.downSampleRatio );
+			let resy = Math.round( height / this.downSampleRatio );
 			this.renderTargetMaskDownSampleBuffer.setSize( resx, resy );
 			this.renderTargetMaskDownSampleBuffer.setSize( resx, resy );
 			this.renderTargetBlurBuffer1.setSize( resx, resy );
 			this.renderTargetBlurBuffer1.setSize( resx, resy );
 			this.renderTargetEdgeBuffer1.setSize( resx, resy );
 			this.renderTargetEdgeBuffer1.setSize( resx, resy );
@@ -127,10 +128,11 @@
 			this.renderTargetEdgeBuffer2.setSize( resx, resy );
 			this.renderTargetEdgeBuffer2.setSize( resx, resy );
 			this.separableBlurMaterial2.uniforms[ 'texSize' ].value.set( resx, resy );
 			this.separableBlurMaterial2.uniforms[ 'texSize' ].value.set( resx, resy );
 
 
-		},
-		changeVisibilityOfSelectedObjects: function ( bVisible ) {
+		}
 
 
-			var cache = this._visibilityCache;
+		changeVisibilityOfSelectedObjects( bVisible ) {
+
+			const cache = this._visibilityCache;
 
 
 			function gatherSelectedMeshesCallBack( object ) {
 			function gatherSelectedMeshesCallBack( object ) {
 
 
@@ -151,18 +153,19 @@
 
 
 			}
 			}
 
 
-			for ( var i = 0; i < this.selectedObjects.length; i ++ ) {
+			for ( let i = 0; i < this.selectedObjects.length; i ++ ) {
 
 
-				var selectedObject = this.selectedObjects[ i ];
+				const selectedObject = this.selectedObjects[ i ];
 				selectedObject.traverse( gatherSelectedMeshesCallBack );
 				selectedObject.traverse( gatherSelectedMeshesCallBack );
 
 
 			}
 			}
 
 
-		},
-		changeVisibilityOfNonSelectedObjects: function ( bVisible ) {
+		}
+
+		changeVisibilityOfNonSelectedObjects( bVisible ) {
 
 
-			var cache = this._visibilityCache;
-			var selectedMeshes = [];
+			const cache = this._visibilityCache;
+			const selectedMeshes = [];
 
 
 			function gatherSelectedMeshesCallBack( object ) {
 			function gatherSelectedMeshesCallBack( object ) {
 
 
@@ -170,9 +173,9 @@
 
 
 			}
 			}
 
 
-			for ( var i = 0; i < this.selectedObjects.length; i ++ ) {
+			for ( let i = 0; i < this.selectedObjects.length; i ++ ) {
 
 
-				var selectedObject = this.selectedObjects[ i ];
+				const selectedObject = this.selectedObjects[ i ];
 				selectedObject.traverse( gatherSelectedMeshesCallBack );
 				selectedObject.traverse( gatherSelectedMeshesCallBack );
 
 
 			}
 			}
@@ -182,11 +185,11 @@
 				if ( object.isMesh || object.isSprite ) {
 				if ( object.isMesh || object.isSprite ) {
 
 
 					// only meshes and sprites are supported by OutlinePass
 					// only meshes and sprites are supported by OutlinePass
-					var bFound = false;
+					let bFound = false;
 
 
-					for ( var i = 0; i < selectedMeshes.length; i ++ ) {
+					for ( let i = 0; i < selectedMeshes.length; i ++ ) {
 
 
-						var selectedObjectId = selectedMeshes[ i ].id;
+						const selectedObjectId = selectedMeshes[ i ].id;
 
 
 						if ( selectedObjectId === object.id ) {
 						if ( selectedObjectId === object.id ) {
 
 
@@ -199,7 +202,7 @@
 
 
 					if ( bFound === false ) {
 					if ( bFound === false ) {
 
 
-						var visibility = object.visible;
+						const visibility = object.visible;
 
 
 						if ( bVisible === false || cache.get( object ) === true ) {
 						if ( bVisible === false || cache.get( object ) === true ) {
 
 
@@ -232,27 +235,29 @@
 
 
 			this.renderScene.traverse( VisibilityChangeCallBack );
 			this.renderScene.traverse( VisibilityChangeCallBack );
 
 
-		},
-		updateTextureMatrix: function () {
+		}
+
+		updateTextureMatrix() {
 
 
 			this.textureMatrix.set( 0.5, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 1.0 );
 			this.textureMatrix.set( 0.5, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 1.0 );
 			this.textureMatrix.multiply( this.renderCamera.projectionMatrix );
 			this.textureMatrix.multiply( this.renderCamera.projectionMatrix );
 			this.textureMatrix.multiply( this.renderCamera.matrixWorldInverse );
 			this.textureMatrix.multiply( this.renderCamera.matrixWorldInverse );
 
 
-		},
-		render: function ( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {
+		}
+
+		render( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {
 
 
 			if ( this.selectedObjects.length > 0 ) {
 			if ( this.selectedObjects.length > 0 ) {
 
 
 				renderer.getClearColor( this._oldClearColor );
 				renderer.getClearColor( this._oldClearColor );
 				this.oldClearAlpha = renderer.getClearAlpha();
 				this.oldClearAlpha = renderer.getClearAlpha();
-				var oldAutoClear = renderer.autoClear;
+				const oldAutoClear = renderer.autoClear;
 				renderer.autoClear = false;
 				renderer.autoClear = false;
 				if ( maskActive ) renderer.state.buffers.stencil.setTest( false );
 				if ( maskActive ) renderer.state.buffers.stencil.setTest( false );
 				renderer.setClearColor( 0xffffff, 1 ); // Make selected objects invisible
 				renderer.setClearColor( 0xffffff, 1 ); // Make selected objects invisible
 
 
 				this.changeVisibilityOfSelectedObjects( false );
 				this.changeVisibilityOfSelectedObjects( false );
-				var currentBackground = this.renderScene.background;
+				const currentBackground = this.renderScene.background;
 				this.renderScene.background = null; // 1. Draw Non Selected objects in the depth buffer
 				this.renderScene.background = null; // 1. Draw Non Selected objects in the depth buffer
 
 
 				this.renderScene.overrideMaterial = this.depthMaterial;
 				this.renderScene.overrideMaterial = this.depthMaterial;
@@ -292,7 +297,7 @@
 
 
 				if ( this.pulsePeriod > 0 ) {
 				if ( this.pulsePeriod > 0 ) {
 
 
-					var scalar = ( 1 + 0.25 ) / 2 + Math.cos( performance.now() * 0.01 / this.pulsePeriod ) * ( 1.0 - 0.25 ) / 2;
+					const scalar = ( 1 + 0.25 ) / 2 + Math.cos( performance.now() * 0.01 / this.pulsePeriod ) * ( 1.0 - 0.25 ) / 2;
 					this.tempPulseColor1.multiplyScalar( scalar );
 					this.tempPulseColor1.multiplyScalar( scalar );
 					this.tempPulseColor2.multiplyScalar( scalar );
 					this.tempPulseColor2.multiplyScalar( scalar );
 
 
@@ -358,8 +363,9 @@
 
 
 			}
 			}
 
 
-		},
-		getPrepareMaskMaterial: function () {
+		}
+
+		getPrepareMaskMaterial() {
 
 
 			return new THREE.ShaderMaterial( {
 			return new THREE.ShaderMaterial( {
 				uniforms: {
 				uniforms: {
@@ -373,12 +379,45 @@
 						value: null
 						value: null
 					}
 					}
 				},
 				},
-				vertexShader: [ '#include <morphtarget_pars_vertex>', '#include <skinning_pars_vertex>', 'varying vec4 projTexCoord;', 'varying vec4 vPosition;', 'uniform mat4 textureMatrix;', 'void main() {', '	#include <skinbase_vertex>', '	#include <begin_vertex>', '	#include <morphtarget_vertex>', '	#include <skinning_vertex>', '	#include <project_vertex>', '	vPosition = mvPosition;', '	vec4 worldPosition = modelMatrix * vec4( position, 1.0 );', '	projTexCoord = textureMatrix * worldPosition;', '}' ].join( '\n' ),
-				fragmentShader: [ '#include <packing>', 'varying vec4 vPosition;', 'varying vec4 projTexCoord;', 'uniform sampler2D depthTexture;', 'uniform vec2 cameraNearFar;', 'void main() {', '	float depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));', '	float viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );', '	float depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;', '	gl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);', '}' ].join( '\n' )
+				vertexShader: `#include <morphtarget_pars_vertex>
+				#include <skinning_pars_vertex>
+
+				varying vec4 projTexCoord;
+				varying vec4 vPosition;
+				uniform mat4 textureMatrix;
+
+				void main() {
+
+					#include <skinbase_vertex>
+					#include <begin_vertex>
+					#include <morphtarget_vertex>
+					#include <skinning_vertex>
+					#include <project_vertex>
+
+					vPosition = mvPosition;
+					vec4 worldPosition = modelMatrix * vec4( position, 1.0 );
+					projTexCoord = textureMatrix * worldPosition;
+
+				}`,
+				fragmentShader: `#include <packing>
+				varying vec4 vPosition;
+				varying vec4 projTexCoord;
+				uniform sampler2D depthTexture;
+				uniform vec2 cameraNearFar;
+
+				void main() {
+
+					float depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));
+					float viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );
+					float depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;
+					gl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);
+
+				}`
 			} );
 			} );
 
 
-		},
-		getEdgeDetectionMaterial: function () {
+		}
+
+		getEdgeDetectionMaterial() {
 
 
 			return new THREE.ShaderMaterial( {
 			return new THREE.ShaderMaterial( {
 				uniforms: {
 				uniforms: {
@@ -395,37 +434,40 @@
 						value: new THREE.Vector3( 1.0, 1.0, 1.0 )
 						value: new THREE.Vector3( 1.0, 1.0, 1.0 )
 					}
 					}
 				},
 				},
-				vertexShader: 'varying vec2 vUv;\n\
-				void main() {\n\
-					vUv = uv;\n\
-					gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\
-				}',
-				fragmentShader: 'varying vec2 vUv;\
-				uniform sampler2D maskTexture;\
-				uniform vec2 texSize;\
-				uniform vec3 visibleEdgeColor;\
-				uniform vec3 hiddenEdgeColor;\
-				\
-				void main() {\n\
-					vec2 invSize = 1.0 / texSize;\
-					vec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\
-					vec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\
-					vec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\
-					vec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\
-					vec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\
-					float diff1 = (c1.r - c2.r)*0.5;\
-					float diff2 = (c3.r - c4.r)*0.5;\
-					float d = length( vec2(diff1, diff2) );\
-					float a1 = min(c1.g, c2.g);\
-					float a2 = min(c3.g, c4.g);\
-					float visibilityFactor = min(a1, a2);\
-					vec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\
-					gl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\
-				}'
+				vertexShader: `varying vec2 vUv;
+
+				void main() {
+					vUv = uv;
+					gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+				}`,
+				fragmentShader: `varying vec2 vUv;
+
+				uniform sampler2D maskTexture;
+				uniform vec2 texSize;
+				uniform vec3 visibleEdgeColor;
+				uniform vec3 hiddenEdgeColor;
+
+				void main() {
+					vec2 invSize = 1.0 / texSize;
+					vec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);
+					vec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);
+					vec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);
+					vec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);
+					vec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);
+					float diff1 = (c1.r - c2.r)*0.5;
+					float diff2 = (c3.r - c4.r)*0.5;
+					float d = length( vec2(diff1, diff2) );
+					float a1 = min(c1.g, c2.g);
+					float a2 = min(c3.g, c4.g);
+					float visibilityFactor = min(a1, a2);
+					vec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;
+					gl_FragColor = vec4(edgeColor, 1.0) * vec4(d);
+				}`
 			} );
 			} );
 
 
-		},
-		getSeperableBlurMaterial: function ( maxRadius ) {
+		}
+
+		getSeperableBlurMaterial( maxRadius ) {
 
 
 			return new THREE.ShaderMaterial( {
 			return new THREE.ShaderMaterial( {
 				defines: {
 				defines: {
@@ -445,41 +487,44 @@
 						value: 1.0
 						value: 1.0
 					}
 					}
 				},
 				},
-				vertexShader: 'varying vec2 vUv;\n\
-				void main() {\n\
-					vUv = uv;\n\
-					gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\
-				}',
-				fragmentShader: '#include <common>\
-				varying vec2 vUv;\
-				uniform sampler2D colorTexture;\
-				uniform vec2 texSize;\
-				uniform vec2 direction;\
-				uniform float kernelRadius;\
-				\
-				float gaussianPdf(in float x, in float sigma) {\
-					return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\
-				}\
-				void main() {\
-					vec2 invSize = 1.0 / texSize;\
-					float weightSum = gaussianPdf(0.0, kernelRadius);\
-					vec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;\
-					vec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\
-					vec2 uvOffset = delta;\
-					for( int i = 1; i <= MAX_RADIUS; i ++ ) {\
-						float w = gaussianPdf(uvOffset.x, kernelRadius);\
-						vec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\
-						vec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\
-						diffuseSum += ((sample1 + sample2) * w);\
-						weightSum += (2.0 * w);\
-						uvOffset += delta;\
-					}\
-					gl_FragColor = diffuseSum/weightSum;\
-				}'
+				vertexShader: `varying vec2 vUv;
+
+				void main() {
+					vUv = uv;
+					gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+				}`,
+				fragmentShader: `#include <common>
+				varying vec2 vUv;
+				uniform sampler2D colorTexture;
+				uniform vec2 texSize;
+				uniform vec2 direction;
+				uniform float kernelRadius;
+
+				float gaussianPdf(in float x, in float sigma) {
+					return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;
+				}
+
+				void main() {
+					vec2 invSize = 1.0 / texSize;
+					float weightSum = gaussianPdf(0.0, kernelRadius);
+					vec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;
+					vec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);
+					vec2 uvOffset = delta;
+					for( int i = 1; i <= MAX_RADIUS; i ++ ) {
+						float w = gaussianPdf(uvOffset.x, kernelRadius);
+						vec4 sample1 = texture2D( colorTexture, vUv + uvOffset);
+						vec4 sample2 = texture2D( colorTexture, vUv - uvOffset);
+						diffuseSum += ((sample1 + sample2) * w);
+						weightSum += (2.0 * w);
+						uvOffset += delta;
+					}
+					gl_FragColor = diffuseSum/weightSum;
+				}`
 			} );
 			} );
 
 
-		},
-		getOverlayMaterial: function () {
+		}
+
+		getOverlayMaterial() {
 
 
 			return new THREE.ShaderMaterial( {
 			return new THREE.ShaderMaterial( {
 				uniforms: {
 				uniforms: {
@@ -505,32 +550,34 @@
 						value: 0.0
 						value: 0.0
 					}
 					}
 				},
 				},
-				vertexShader: 'varying vec2 vUv;\n\
-				void main() {\n\
-					vUv = uv;\n\
-					gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\
-				}',
-				fragmentShader: 'varying vec2 vUv;\
-				uniform sampler2D maskTexture;\
-				uniform sampler2D edgeTexture1;\
-				uniform sampler2D edgeTexture2;\
-				uniform sampler2D patternTexture;\
-				uniform float edgeStrength;\
-				uniform float edgeGlow;\
-				uniform bool usePatternTexture;\
-				\
-				void main() {\
-					vec4 edgeValue1 = texture2D(edgeTexture1, vUv);\
-					vec4 edgeValue2 = texture2D(edgeTexture2, vUv);\
-					vec4 maskColor = texture2D(maskTexture, vUv);\
-					vec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\
-					float visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\
-					vec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\
-					vec4 finalColor = edgeStrength * maskColor.r * edgeValue;\
-					if(usePatternTexture)\
-						finalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\
-					gl_FragColor = finalColor;\
-				}',
+				vertexShader: `varying vec2 vUv;
+
+				void main() {
+					vUv = uv;
+					gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+				}`,
+				fragmentShader: `varying vec2 vUv;
+
+				uniform sampler2D maskTexture;
+				uniform sampler2D edgeTexture1;
+				uniform sampler2D edgeTexture2;
+				uniform sampler2D patternTexture;
+				uniform float edgeStrength;
+				uniform float edgeGlow;
+				uniform bool usePatternTexture;
+
+				void main() {
+					vec4 edgeValue1 = texture2D(edgeTexture1, vUv);
+					vec4 edgeValue2 = texture2D(edgeTexture2, vUv);
+					vec4 maskColor = texture2D(maskTexture, vUv);
+					vec4 patternColor = texture2D(patternTexture, 6.0 * vUv);
+					float visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;
+					vec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;
+					vec4 finalColor = edgeStrength * maskColor.r * edgeValue;
+					if(usePatternTexture)
+						finalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);
+					gl_FragColor = finalColor;
+				}`,
 				blending: THREE.AdditiveBlending,
 				blending: THREE.AdditiveBlending,
 				depthTest: false,
 				depthTest: false,
 				depthWrite: false,
 				depthWrite: false,
@@ -538,7 +585,9 @@
 			} );
 			} );
 
 
 		}
 		}
-	} );
+
+	}
+
 	OutlinePass.BlurDirectionX = new THREE.Vector2( 1.0, 0.0 );
 	OutlinePass.BlurDirectionX = new THREE.Vector2( 1.0, 0.0 );
 	OutlinePass.BlurDirectionY = new THREE.Vector2( 0.0, 1.0 );
 	OutlinePass.BlurDirectionY = new THREE.Vector2( 0.0, 1.0 );
 
 

+ 43 - 40
examples/js/postprocessing/Pass.js

@@ -1,72 +1,75 @@
 ( function () {
 ( function () {
 
 
-	function Pass() {
+	class Pass {
 
 
-		// if set to true, the pass is processed by the composer
-		this.enabled = true; // if set to true, the pass indicates to swap read and write buffer after rendering
+		constructor() {
 
 
-		this.needsSwap = true; // if set to true, the pass clears its buffer before rendering
+			// if set to true, the pass is processed by the composer
+			this.enabled = true; // if set to true, the pass indicates to swap read and write buffer after rendering
 
 
-		this.clear = false; // if set to true, the result of the pass is rendered to screen. This is set automatically by EffectComposer.
+			this.needsSwap = true; // if set to true, the pass clears its buffer before rendering
 
 
-		this.renderToScreen = false;
+			this.clear = false; // if set to true, the result of the pass is rendered to screen. This is set automatically by EffectComposer.
 
 
-	}
+			this.renderToScreen = false;
+
+		}
 
 
-	Object.assign( Pass.prototype, {
-		setSize: function ( ) {},
-		render: function ( ) {
+		setSize( ) {}
+
+		render( ) {
 
 
 			console.error( 'THREE.Pass: .render() must be implemented in derived pass.' );
 			console.error( 'THREE.Pass: .render() must be implemented in derived pass.' );
 
 
 		}
 		}
-	} ); // Helper for passes that need to fill the viewport with a single quad.
-	// Important: It's actually a hack to put FullScreenQuad into the Pass namespace. This is only
-	// done to make examples/js code work. Normally, FullScreenQuad should be exported
-	// from this module like Pass.
 
 
-	Pass.FullScreenQuad = function () {
+	} // Helper for passes that need to fill the viewport with a single quad.
+
+
+	const _camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); // https://github.com/mrdoob/three.js/pull/21358
+
+
+	const _geometry = new THREE.BufferGeometry();
+
+	_geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );
 
 
-		var camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); // https://github.com/mrdoob/three.js/pull/21358
+	_geometry.setAttribute( 'uv', new THREE.Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );
 
 
-		var geometry = new THREE.BufferGeometry();
-		geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );
-		geometry.setAttribute( 'uv', new THREE.Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );
+	class FullScreenQuad {
 
 
-		var FullScreenQuad = function ( material ) {
+		constructor( material ) {
 
 
-			this._mesh = new THREE.Mesh( geometry, material );
+			this._mesh = new THREE.Mesh( _geometry, material );
 
 
-		};
+		}
 
 
-		Object.defineProperty( FullScreenQuad.prototype, 'material', {
-			get: function () {
+		dispose() {
 
 
-				return this._mesh.material;
+			this._mesh.geometry.dispose();
 
 
-			},
-			set: function ( value ) {
+		}
 
 
-				this._mesh.material = value;
+		render( renderer ) {
 
 
-			}
-		} );
-		Object.assign( FullScreenQuad.prototype, {
-			dispose: function () {
+			renderer.render( this._mesh, _camera );
 
 
-				this._mesh.geometry.dispose();
+		}
 
 
-			},
-			render: function ( renderer ) {
+		get material() {
 
 
-				renderer.render( this._mesh, camera );
+			return this._mesh.material;
+
+		}
 
 
-			}
-		} );
-		return FullScreenQuad;
+		set material( value ) {
 
 
-	}();
+			this._mesh.material = value;
+
+		}
+
+	}
 
 
+	THREE.FullScreenQuad = FullScreenQuad;
 	THREE.Pass = Pass;
 	THREE.Pass = Pass;
 
 
 } )();
 } )();

+ 22 - 21
examples/js/postprocessing/RenderPass.js

@@ -1,29 +1,29 @@
 ( function () {
 ( function () {
 
 
-	var RenderPass = function ( scene, camera, overrideMaterial, clearColor, clearAlpha ) {
-
-		THREE.Pass.call( this );
-		this.scene = scene;
-		this.camera = camera;
-		this.overrideMaterial = overrideMaterial;
-		this.clearColor = clearColor;
-		this.clearAlpha = clearAlpha !== undefined ? clearAlpha : 0;
-		this.clear = true;
-		this.clearDepth = false;
-		this.needsSwap = false;
-		this._oldClearColor = new THREE.Color();
-
-	};
-
-	RenderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
-		constructor: RenderPass,
-		render: function ( renderer, writeBuffer, readBuffer
+	class RenderPass extends THREE.Pass {
+
+		constructor( scene, camera, overrideMaterial, clearColor, clearAlpha ) {
+
+			super();
+			this.scene = scene;
+			this.camera = camera;
+			this.overrideMaterial = overrideMaterial;
+			this.clearColor = clearColor;
+			this.clearAlpha = clearAlpha !== undefined ? clearAlpha : 0;
+			this.clear = true;
+			this.clearDepth = false;
+			this.needsSwap = false;
+			this._oldClearColor = new THREE.Color();
+
+		}
+
+		render( renderer, writeBuffer, readBuffer
 			/*, deltaTime, maskActive */
 			/*, deltaTime, maskActive */
 		) {
 		) {
 
 
-			var oldAutoClear = renderer.autoClear;
+			const oldAutoClear = renderer.autoClear;
 			renderer.autoClear = false;
 			renderer.autoClear = false;
-			var oldClearAlpha, oldOverrideMaterial;
+			let oldClearAlpha, oldOverrideMaterial;
 
 
 			if ( this.overrideMaterial !== undefined ) {
 			if ( this.overrideMaterial !== undefined ) {
 
 
@@ -66,7 +66,8 @@
 			renderer.autoClear = oldAutoClear;
 			renderer.autoClear = oldAutoClear;
 
 
 		}
 		}
-	} );
+
+	}
 
 
 	THREE.RenderPass = RenderPass;
 	THREE.RenderPass = RenderPass;
 
 

+ 162 - 157
examples/js/postprocessing/SAOPass.js

@@ -4,163 +4,156 @@
  * SAO implementation inspired from bhouston previous SAO work
  * SAO implementation inspired from bhouston previous SAO work
  */
  */
 
 
-	var SAOPass = function ( scene, camera, depthTexture, useNormals, resolution ) {
-
-		THREE.Pass.call( this );
-		this.scene = scene;
-		this.camera = camera;
-		this.clear = true;
-		this.needsSwap = false;
-		this.supportsDepthTextureExtension = depthTexture !== undefined ? depthTexture : false;
-		this.supportsNormalTexture = useNormals !== undefined ? useNormals : false;
-		this.originalClearColor = new THREE.Color();
-		this._oldClearColor = new THREE.Color();
-		this.oldClearAlpha = 1;
-		this.params = {
-			output: 0,
-			saoBias: 0.5,
-			saoIntensity: 0.18,
-			saoScale: 1,
-			saoKernelRadius: 100,
-			saoMinResolution: 0,
-			saoBlur: true,
-			saoBlurRadius: 8,
-			saoBlurStdDev: 4,
-			saoBlurDepthCutoff: 0.01
-		};
-		this.resolution = resolution !== undefined ? new THREE.Vector2( resolution.x, resolution.y ) : new THREE.Vector2( 256, 256 );
-		this.saoRenderTarget = new THREE.WebGLRenderTarget( this.resolution.x, this.resolution.y, {
-			minFilter: THREE.LinearFilter,
-			magFilter: THREE.LinearFilter,
-			format: THREE.RGBAFormat
-		} );
-		this.blurIntermediateRenderTarget = this.saoRenderTarget.clone();
-		this.beautyRenderTarget = this.saoRenderTarget.clone();
-		this.normalRenderTarget = new THREE.WebGLRenderTarget( this.resolution.x, this.resolution.y, {
-			minFilter: THREE.NearestFilter,
-			magFilter: THREE.NearestFilter,
-			format: THREE.RGBAFormat
-		} );
-		this.depthRenderTarget = this.normalRenderTarget.clone();
-
-		if ( this.supportsDepthTextureExtension ) {
-
-			var depthTexture = new THREE.DepthTexture();
-			depthTexture.type = THREE.UnsignedShortType;
-			this.beautyRenderTarget.depthTexture = depthTexture;
-			this.beautyRenderTarget.depthBuffer = true;
+	class SAOPass extends THREE.Pass {
+
+		constructor( scene, camera, depthTexture, useNormals, resolution ) {
+
+			super();
+			this.scene = scene;
+			this.camera = camera;
+			this.clear = true;
+			this.needsSwap = false;
+			this.supportsDepthTextureExtension = depthTexture !== undefined ? depthTexture : false;
+			this.supportsNormalTexture = useNormals !== undefined ? useNormals : false;
+			this.originalClearColor = new THREE.Color();
+			this._oldClearColor = new THREE.Color();
+			this.oldClearAlpha = 1;
+			this.params = {
+				output: 0,
+				saoBias: 0.5,
+				saoIntensity: 0.18,
+				saoScale: 1,
+				saoKernelRadius: 100,
+				saoMinResolution: 0,
+				saoBlur: true,
+				saoBlurRadius: 8,
+				saoBlurStdDev: 4,
+				saoBlurDepthCutoff: 0.01
+			};
+			this.resolution = resolution !== undefined ? new THREE.Vector2( resolution.x, resolution.y ) : new THREE.Vector2( 256, 256 );
+			this.saoRenderTarget = new THREE.WebGLRenderTarget( this.resolution.x, this.resolution.y, {
+				minFilter: THREE.LinearFilter,
+				magFilter: THREE.LinearFilter,
+				format: THREE.RGBAFormat
+			} );
+			this.blurIntermediateRenderTarget = this.saoRenderTarget.clone();
+			this.beautyRenderTarget = this.saoRenderTarget.clone();
+			this.normalRenderTarget = new THREE.WebGLRenderTarget( this.resolution.x, this.resolution.y, {
+				minFilter: THREE.NearestFilter,
+				magFilter: THREE.NearestFilter,
+				format: THREE.RGBAFormat
+			} );
+			this.depthRenderTarget = this.normalRenderTarget.clone();
+
+			if ( this.supportsDepthTextureExtension ) {
+
+				const depthTexture = new THREE.DepthTexture();
+				depthTexture.type = THREE.UnsignedShortType;
+				this.beautyRenderTarget.depthTexture = depthTexture;
+				this.beautyRenderTarget.depthBuffer = true;
 
 
-		}
+			}
 
 
-		this.depthMaterial = new THREE.MeshDepthMaterial();
-		this.depthMaterial.depthPacking = THREE.RGBADepthPacking;
-		this.depthMaterial.blending = THREE.NoBlending;
-		this.normalMaterial = new THREE.MeshNormalMaterial();
-		this.normalMaterial.blending = THREE.NoBlending;
+			this.depthMaterial = new THREE.MeshDepthMaterial();
+			this.depthMaterial.depthPacking = THREE.RGBADepthPacking;
+			this.depthMaterial.blending = THREE.NoBlending;
+			this.normalMaterial = new THREE.MeshNormalMaterial();
+			this.normalMaterial.blending = THREE.NoBlending;
 
 
-		if ( THREE.SAOShader === undefined ) {
+			if ( THREE.SAOShader === undefined ) {
 
 
-			console.error( 'THREE.SAOPass relies on THREE.SAOShader' );
+				console.error( 'THREE.SAOPass relies on THREE.SAOShader' );
 
 
-		}
+			}
 
 
-		this.saoMaterial = new THREE.ShaderMaterial( {
-			defines: Object.assign( {}, THREE.SAOShader.defines ),
-			fragmentShader: THREE.SAOShader.fragmentShader,
-			vertexShader: THREE.SAOShader.vertexShader,
-			uniforms: THREE.UniformsUtils.clone( THREE.SAOShader.uniforms )
-		} );
-		this.saoMaterial.extensions.derivatives = true;
-		this.saoMaterial.defines[ 'DEPTH_PACKING' ] = this.supportsDepthTextureExtension ? 0 : 1;
-		this.saoMaterial.defines[ 'NORMAL_TEXTURE' ] = this.supportsNormalTexture ? 1 : 0;
-		this.saoMaterial.defines[ 'PERSPECTIVE_CAMERA' ] = this.camera.isPerspectiveCamera ? 1 : 0;
-		this.saoMaterial.uniforms[ 'tDepth' ].value = this.supportsDepthTextureExtension ? depthTexture : this.depthRenderTarget.texture;
-		this.saoMaterial.uniforms[ 'tNormal' ].value = this.normalRenderTarget.texture;
-		this.saoMaterial.uniforms[ 'size' ].value.set( this.resolution.x, this.resolution.y );
-		this.saoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
-		this.saoMaterial.uniforms[ 'cameraProjectionMatrix' ].value = this.camera.projectionMatrix;
-		this.saoMaterial.blending = THREE.NoBlending;
-
-		if ( THREE.DepthLimitedBlurShader === undefined ) {
-
-			console.error( 'THREE.SAOPass relies on THREE.DepthLimitedBlurShader' );
+			this.saoMaterial = new THREE.ShaderMaterial( {
+				defines: Object.assign( {}, THREE.SAOShader.defines ),
+				fragmentShader: THREE.SAOShader.fragmentShader,
+				vertexShader: THREE.SAOShader.vertexShader,
+				uniforms: THREE.UniformsUtils.clone( THREE.SAOShader.uniforms )
+			} );
+			this.saoMaterial.extensions.derivatives = true;
+			this.saoMaterial.defines[ 'DEPTH_PACKING' ] = this.supportsDepthTextureExtension ? 0 : 1;
+			this.saoMaterial.defines[ 'NORMAL_TEXTURE' ] = this.supportsNormalTexture ? 1 : 0;
+			this.saoMaterial.defines[ 'PERSPECTIVE_CAMERA' ] = this.camera.isPerspectiveCamera ? 1 : 0;
+			this.saoMaterial.uniforms[ 'tDepth' ].value = this.supportsDepthTextureExtension ? depthTexture : this.depthRenderTarget.texture;
+			this.saoMaterial.uniforms[ 'tNormal' ].value = this.normalRenderTarget.texture;
+			this.saoMaterial.uniforms[ 'size' ].value.set( this.resolution.x, this.resolution.y );
+			this.saoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
+			this.saoMaterial.uniforms[ 'cameraProjectionMatrix' ].value = this.camera.projectionMatrix;
+			this.saoMaterial.blending = THREE.NoBlending;
 
 
-		}
+			if ( THREE.DepthLimitedBlurShader === undefined ) {
 
 
-		this.vBlurMaterial = new THREE.ShaderMaterial( {
-			uniforms: THREE.UniformsUtils.clone( THREE.DepthLimitedBlurShader.uniforms ),
-			defines: Object.assign( {}, THREE.DepthLimitedBlurShader.defines ),
-			vertexShader: THREE.DepthLimitedBlurShader.vertexShader,
-			fragmentShader: THREE.DepthLimitedBlurShader.fragmentShader
-		} );
-		this.vBlurMaterial.defines[ 'DEPTH_PACKING' ] = this.supportsDepthTextureExtension ? 0 : 1;
-		this.vBlurMaterial.defines[ 'PERSPECTIVE_CAMERA' ] = this.camera.isPerspectiveCamera ? 1 : 0;
-		this.vBlurMaterial.uniforms[ 'tDiffuse' ].value = this.saoRenderTarget.texture;
-		this.vBlurMaterial.uniforms[ 'tDepth' ].value = this.supportsDepthTextureExtension ? depthTexture : this.depthRenderTarget.texture;
-		this.vBlurMaterial.uniforms[ 'size' ].value.set( this.resolution.x, this.resolution.y );
-		this.vBlurMaterial.blending = THREE.NoBlending;
-		this.hBlurMaterial = new THREE.ShaderMaterial( {
-			uniforms: THREE.UniformsUtils.clone( THREE.DepthLimitedBlurShader.uniforms ),
-			defines: Object.assign( {}, THREE.DepthLimitedBlurShader.defines ),
-			vertexShader: THREE.DepthLimitedBlurShader.vertexShader,
-			fragmentShader: THREE.DepthLimitedBlurShader.fragmentShader
-		} );
-		this.hBlurMaterial.defines[ 'DEPTH_PACKING' ] = this.supportsDepthTextureExtension ? 0 : 1;
-		this.hBlurMaterial.defines[ 'PERSPECTIVE_CAMERA' ] = this.camera.isPerspectiveCamera ? 1 : 0;
-		this.hBlurMaterial.uniforms[ 'tDiffuse' ].value = this.blurIntermediateRenderTarget.texture;
-		this.hBlurMaterial.uniforms[ 'tDepth' ].value = this.supportsDepthTextureExtension ? depthTexture : this.depthRenderTarget.texture;
-		this.hBlurMaterial.uniforms[ 'size' ].value.set( this.resolution.x, this.resolution.y );
-		this.hBlurMaterial.blending = THREE.NoBlending;
-
-		if ( THREE.CopyShader === undefined ) {
-
-			console.error( 'THREE.SAOPass relies on THREE.CopyShader' );
+				console.error( 'THREE.SAOPass relies on THREE.DepthLimitedBlurShader' );
 
 
-		}
+			}
 
 
-		this.materialCopy = new THREE.ShaderMaterial( {
-			uniforms: THREE.UniformsUtils.clone( THREE.CopyShader.uniforms ),
-			vertexShader: THREE.CopyShader.vertexShader,
-			fragmentShader: THREE.CopyShader.fragmentShader,
-			blending: THREE.NoBlending
-		} );
-		this.materialCopy.transparent = true;
-		this.materialCopy.depthTest = false;
-		this.materialCopy.depthWrite = false;
-		this.materialCopy.blending = THREE.CustomBlending;
-		this.materialCopy.blendSrc = THREE.DstColorFactor;
-		this.materialCopy.blendDst = THREE.ZeroFactor;
-		this.materialCopy.blendEquation = THREE.AddEquation;
-		this.materialCopy.blendSrcAlpha = THREE.DstAlphaFactor;
-		this.materialCopy.blendDstAlpha = THREE.ZeroFactor;
-		this.materialCopy.blendEquationAlpha = THREE.AddEquation;
-
-		if ( THREE.UnpackDepthRGBAShader === undefined ) {
-
-			console.error( 'THREE.SAOPass relies on THREE.UnpackDepthRGBAShader' );
+			this.vBlurMaterial = new THREE.ShaderMaterial( {
+				uniforms: THREE.UniformsUtils.clone( THREE.DepthLimitedBlurShader.uniforms ),
+				defines: Object.assign( {}, THREE.DepthLimitedBlurShader.defines ),
+				vertexShader: THREE.DepthLimitedBlurShader.vertexShader,
+				fragmentShader: THREE.DepthLimitedBlurShader.fragmentShader
+			} );
+			this.vBlurMaterial.defines[ 'DEPTH_PACKING' ] = this.supportsDepthTextureExtension ? 0 : 1;
+			this.vBlurMaterial.defines[ 'PERSPECTIVE_CAMERA' ] = this.camera.isPerspectiveCamera ? 1 : 0;
+			this.vBlurMaterial.uniforms[ 'tDiffuse' ].value = this.saoRenderTarget.texture;
+			this.vBlurMaterial.uniforms[ 'tDepth' ].value = this.supportsDepthTextureExtension ? depthTexture : this.depthRenderTarget.texture;
+			this.vBlurMaterial.uniforms[ 'size' ].value.set( this.resolution.x, this.resolution.y );
+			this.vBlurMaterial.blending = THREE.NoBlending;
+			this.hBlurMaterial = new THREE.ShaderMaterial( {
+				uniforms: THREE.UniformsUtils.clone( THREE.DepthLimitedBlurShader.uniforms ),
+				defines: Object.assign( {}, THREE.DepthLimitedBlurShader.defines ),
+				vertexShader: THREE.DepthLimitedBlurShader.vertexShader,
+				fragmentShader: THREE.DepthLimitedBlurShader.fragmentShader
+			} );
+			this.hBlurMaterial.defines[ 'DEPTH_PACKING' ] = this.supportsDepthTextureExtension ? 0 : 1;
+			this.hBlurMaterial.defines[ 'PERSPECTIVE_CAMERA' ] = this.camera.isPerspectiveCamera ? 1 : 0;
+			this.hBlurMaterial.uniforms[ 'tDiffuse' ].value = this.blurIntermediateRenderTarget.texture;
+			this.hBlurMaterial.uniforms[ 'tDepth' ].value = this.supportsDepthTextureExtension ? depthTexture : this.depthRenderTarget.texture;
+			this.hBlurMaterial.uniforms[ 'size' ].value.set( this.resolution.x, this.resolution.y );
+			this.hBlurMaterial.blending = THREE.NoBlending;
+
+			if ( THREE.CopyShader === undefined ) {
+
+				console.error( 'THREE.SAOPass relies on THREE.CopyShader' );
 
 
-		}
+			}
 
 
-		this.depthCopy = new THREE.ShaderMaterial( {
-			uniforms: THREE.UniformsUtils.clone( THREE.UnpackDepthRGBAShader.uniforms ),
-			vertexShader: THREE.UnpackDepthRGBAShader.vertexShader,
-			fragmentShader: THREE.UnpackDepthRGBAShader.fragmentShader,
-			blending: THREE.NoBlending
-		} );
-		this.fsQuad = new THREE.Pass.FullScreenQuad( null );
+			this.materialCopy = new THREE.ShaderMaterial( {
+				uniforms: THREE.UniformsUtils.clone( THREE.CopyShader.uniforms ),
+				vertexShader: THREE.CopyShader.vertexShader,
+				fragmentShader: THREE.CopyShader.fragmentShader,
+				blending: THREE.NoBlending
+			} );
+			this.materialCopy.transparent = true;
+			this.materialCopy.depthTest = false;
+			this.materialCopy.depthWrite = false;
+			this.materialCopy.blending = THREE.CustomBlending;
+			this.materialCopy.blendSrc = THREE.DstColorFactor;
+			this.materialCopy.blendDst = THREE.ZeroFactor;
+			this.materialCopy.blendEquation = THREE.AddEquation;
+			this.materialCopy.blendSrcAlpha = THREE.DstAlphaFactor;
+			this.materialCopy.blendDstAlpha = THREE.ZeroFactor;
+			this.materialCopy.blendEquationAlpha = THREE.AddEquation;
+
+			if ( THREE.UnpackDepthRGBAShader === undefined ) {
+
+				console.error( 'THREE.SAOPass relies on THREE.UnpackDepthRGBAShader' );
 
 
-	};
+			}
 
 
-	SAOPass.OUTPUT = {
-		'Beauty': 1,
-		'Default': 0,
-		'SAO': 2,
-		'Depth': 3,
-		'Normal': 4
-	};
-	SAOPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
-		constructor: SAOPass,
-		render: function ( renderer, writeBuffer, readBuffer
+			this.depthCopy = new THREE.ShaderMaterial( {
+				uniforms: THREE.UniformsUtils.clone( THREE.UnpackDepthRGBAShader.uniforms ),
+				vertexShader: THREE.UnpackDepthRGBAShader.vertexShader,
+				fragmentShader: THREE.UnpackDepthRGBAShader.fragmentShader,
+				blending: THREE.NoBlending
+			} );
+			this.fsQuad = new THREE.FullScreenQuad( null );
+
+		}
+
+		render( renderer, writeBuffer, readBuffer
 			/*, deltaTime, maskActive*/
 			/*, deltaTime, maskActive*/
 		) {
 		) {
 
 
@@ -182,7 +175,7 @@
 
 
 			renderer.getClearColor( this._oldClearColor );
 			renderer.getClearColor( this._oldClearColor );
 			this.oldClearAlpha = renderer.getClearAlpha();
 			this.oldClearAlpha = renderer.getClearAlpha();
-			var oldAutoClear = renderer.autoClear;
+			const oldAutoClear = renderer.autoClear;
 			renderer.autoClear = false;
 			renderer.autoClear = false;
 			renderer.setRenderTarget( this.depthRenderTarget );
 			renderer.setRenderTarget( this.depthRenderTarget );
 			renderer.clear();
 			renderer.clear();
@@ -194,7 +187,7 @@
 			this.saoMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
 			this.saoMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
 			this.saoMaterial.uniforms[ 'cameraFar' ].value = this.camera.far; // this.saoMaterial.uniforms['randomSeed'].value = Math.random();
 			this.saoMaterial.uniforms[ 'cameraFar' ].value = this.camera.far; // this.saoMaterial.uniforms['randomSeed'].value = Math.random();
 
 
-			var depthCutoff = this.params.saoBlurDepthCutoff * ( this.camera.far - this.camera.near );
+			const depthCutoff = this.params.saoBlurDepthCutoff * ( this.camera.far - this.camera.near );
 			this.vBlurMaterial.uniforms[ 'depthCutoff' ].value = depthCutoff;
 			this.vBlurMaterial.uniforms[ 'depthCutoff' ].value = depthCutoff;
 			this.hBlurMaterial.uniforms[ 'depthCutoff' ].value = depthCutoff;
 			this.hBlurMaterial.uniforms[ 'depthCutoff' ].value = depthCutoff;
 			this.vBlurMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
 			this.vBlurMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
@@ -242,7 +235,7 @@
 
 
 			}
 			}
 
 
-			var outputMaterial = this.materialCopy; // Setting up SAO rendering
+			let outputMaterial = this.materialCopy; // Setting up SAO rendering
 
 
 			if ( this.params.output === 3 ) {
 			if ( this.params.output === 3 ) {
 
 
@@ -287,13 +280,14 @@
 			renderer.setClearColor( this._oldClearColor, this.oldClearAlpha );
 			renderer.setClearColor( this._oldClearColor, this.oldClearAlpha );
 			renderer.autoClear = oldAutoClear;
 			renderer.autoClear = oldAutoClear;
 
 
-		},
-		renderPass: function ( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
+		}
+
+		renderPass( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
 			// save original state
 			// save original state
 			renderer.getClearColor( this.originalClearColor );
 			renderer.getClearColor( this.originalClearColor );
-			var originalClearAlpha = renderer.getClearAlpha();
-			var originalAutoClear = renderer.autoClear;
+			const originalClearAlpha = renderer.getClearAlpha();
+			const originalAutoClear = renderer.autoClear;
 			renderer.setRenderTarget( renderTarget ); // setup pass state
 			renderer.setRenderTarget( renderTarget ); // setup pass state
 
 
 			renderer.autoClear = false;
 			renderer.autoClear = false;
@@ -313,12 +307,13 @@
 			renderer.setClearColor( this.originalClearColor );
 			renderer.setClearColor( this.originalClearColor );
 			renderer.setClearAlpha( originalClearAlpha );
 			renderer.setClearAlpha( originalClearAlpha );
 
 
-		},
-		renderOverride: function ( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
+		}
+
+		renderOverride( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
 			renderer.getClearColor( this.originalClearColor );
 			renderer.getClearColor( this.originalClearColor );
-			var originalClearAlpha = renderer.getClearAlpha();
-			var originalAutoClear = renderer.autoClear;
+			const originalClearAlpha = renderer.getClearAlpha();
+			const originalAutoClear = renderer.autoClear;
 			renderer.setRenderTarget( renderTarget );
 			renderer.setRenderTarget( renderTarget );
 			renderer.autoClear = false;
 			renderer.autoClear = false;
 			clearColor = overrideMaterial.clearColor || clearColor;
 			clearColor = overrideMaterial.clearColor || clearColor;
@@ -340,8 +335,9 @@
 			renderer.setClearColor( this.originalClearColor );
 			renderer.setClearColor( this.originalClearColor );
 			renderer.setClearAlpha( originalClearAlpha );
 			renderer.setClearAlpha( originalClearAlpha );
 
 
-		},
-		setSize: function ( width, height ) {
+		}
+
+		setSize( width, height ) {
 
 
 			this.beautyRenderTarget.setSize( width, height );
 			this.beautyRenderTarget.setSize( width, height );
 			this.saoRenderTarget.setSize( width, height );
 			this.saoRenderTarget.setSize( width, height );
@@ -358,7 +354,16 @@
 			this.hBlurMaterial.needsUpdate = true;
 			this.hBlurMaterial.needsUpdate = true;
 
 
 		}
 		}
-	} );
+
+	}
+
+	SAOPass.OUTPUT = {
+		'Beauty': 1,
+		'Default': 0,
+		'SAO': 2,
+		'Depth': 3,
+		'Normal': 4
+	};
 
 
 	THREE.SAOPass = SAOPass;
 	THREE.SAOPass = SAOPass;
 
 

File diff suppressed because it is too large
+ 88 - 86
examples/js/postprocessing/SMAAPass.js


+ 53 - 48
examples/js/postprocessing/SSAARenderPass.js

@@ -10,38 +10,38 @@
 *
 *
 */
 */
 
 
-	var SSAARenderPass = function ( scene, camera, clearColor, clearAlpha ) {
-
-		THREE.Pass.call( this );
-		this.scene = scene;
-		this.camera = camera;
-		this.sampleLevel = 4; // specified as n, where the number of samples is 2^n, so sampleLevel = 4, is 2^4 samples, 16.
-
-		this.unbiased = true; // as we need to clear the buffer in this pass, clearColor must be set to something, defaults to black.
-
-		this.clearColor = clearColor !== undefined ? clearColor : 0x000000;
-		this.clearAlpha = clearAlpha !== undefined ? clearAlpha : 0;
-		this._oldClearColor = new THREE.Color();
-		if ( THREE.CopyShader === undefined ) console.error( 'THREE.SSAARenderPass relies on THREE.CopyShader' );
-		var copyShader = THREE.CopyShader;
-		this.copyUniforms = THREE.UniformsUtils.clone( copyShader.uniforms );
-		this.copyMaterial = new THREE.ShaderMaterial( {
-			uniforms: this.copyUniforms,
-			vertexShader: copyShader.vertexShader,
-			fragmentShader: copyShader.fragmentShader,
-			premultipliedAlpha: true,
-			transparent: true,
-			blending: THREE.AdditiveBlending,
-			depthTest: false,
-			depthWrite: false
-		} );
-		this.fsQuad = new THREE.Pass.FullScreenQuad( this.copyMaterial );
-
-	};
-
-	SSAARenderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
-		constructor: SSAARenderPass,
-		dispose: function () {
+	class SSAARenderPass extends THREE.Pass {
+
+		constructor( scene, camera, clearColor, clearAlpha ) {
+
+			super();
+			this.scene = scene;
+			this.camera = camera;
+			this.sampleLevel = 4; // specified as n, where the number of samples is 2^n, so sampleLevel = 4, is 2^4 samples, 16.
+
+			this.unbiased = true; // as we need to clear the buffer in this pass, clearColor must be set to something, defaults to black.
+
+			this.clearColor = clearColor !== undefined ? clearColor : 0x000000;
+			this.clearAlpha = clearAlpha !== undefined ? clearAlpha : 0;
+			this._oldClearColor = new THREE.Color();
+			if ( THREE.CopyShader === undefined ) console.error( 'THREE.SSAARenderPass relies on THREE.CopyShader' );
+			const copyShader = THREE.CopyShader;
+			this.copyUniforms = THREE.UniformsUtils.clone( copyShader.uniforms );
+			this.copyMaterial = new THREE.ShaderMaterial( {
+				uniforms: this.copyUniforms,
+				vertexShader: copyShader.vertexShader,
+				fragmentShader: copyShader.fragmentShader,
+				premultipliedAlpha: true,
+				transparent: true,
+				blending: THREE.AdditiveBlending,
+				depthTest: false,
+				depthWrite: false
+			} );
+			this.fsQuad = new THREE.FullScreenQuad( this.copyMaterial );
+
+		}
+
+		dispose() {
 
 
 			if ( this.sampleRenderTarget ) {
 			if ( this.sampleRenderTarget ) {
 
 
@@ -50,13 +50,15 @@
 
 
 			}
 			}
 
 
-		},
-		setSize: function ( width, height ) {
+		}
+
+		setSize( width, height ) {
 
 
 			if ( this.sampleRenderTarget ) this.sampleRenderTarget.setSize( width, height );
 			if ( this.sampleRenderTarget ) this.sampleRenderTarget.setSize( width, height );
 
 
-		},
-		render: function ( renderer, writeBuffer, readBuffer ) {
+		}
+
+		render( renderer, writeBuffer, readBuffer ) {
 
 
 			if ( ! this.sampleRenderTarget ) {
 			if ( ! this.sampleRenderTarget ) {
 
 
@@ -69,20 +71,21 @@
 
 
 			}
 			}
 
 
-			var jitterOffsets = SSAARenderPass.JitterVectors[ Math.max( 0, Math.min( this.sampleLevel, 5 ) ) ];
-			var autoClear = renderer.autoClear;
+			const jitterOffsets = _JitterVectors[ Math.max( 0, Math.min( this.sampleLevel, 5 ) ) ];
+
+			const autoClear = renderer.autoClear;
 			renderer.autoClear = false;
 			renderer.autoClear = false;
 			renderer.getClearColor( this._oldClearColor );
 			renderer.getClearColor( this._oldClearColor );
-			var oldClearAlpha = renderer.getClearAlpha();
-			var baseSampleWeight = 1.0 / jitterOffsets.length;
-			var roundingRange = 1 / 32;
+			const oldClearAlpha = renderer.getClearAlpha();
+			const baseSampleWeight = 1.0 / jitterOffsets.length;
+			const roundingRange = 1 / 32;
 			this.copyUniforms[ 'tDiffuse' ].value = this.sampleRenderTarget.texture;
 			this.copyUniforms[ 'tDiffuse' ].value = this.sampleRenderTarget.texture;
-			var width = readBuffer.width,
+			const width = readBuffer.width,
 				height = readBuffer.height; // render the scene multiple times, each slightly jitter offset from the last and accumulate the results.
 				height = readBuffer.height; // render the scene multiple times, each slightly jitter offset from the last and accumulate the results.
 
 
-			for ( var i = 0; i < jitterOffsets.length; i ++ ) {
+			for ( let i = 0; i < jitterOffsets.length; i ++ ) {
 
 
-				var jitterOffset = jitterOffsets[ i ];
+				const jitterOffset = jitterOffsets[ i ];
 
 
 				if ( this.camera.setViewOffset ) {
 				if ( this.camera.setViewOffset ) {
 
 
@@ -91,14 +94,14 @@
 
 
 				}
 				}
 
 
-				var sampleWeight = baseSampleWeight;
+				let sampleWeight = baseSampleWeight;
 
 
 				if ( this.unbiased ) {
 				if ( this.unbiased ) {
 
 
 					// the theory is that equal weights for each sample lead to an accumulation of rounding errors.
 					// the theory is that equal weights for each sample lead to an accumulation of rounding errors.
 					// The following equation varies the sampleWeight per sample so that it is uniformly distributed
 					// The following equation varies the sampleWeight per sample so that it is uniformly distributed
 					// across a range of values whose rounding errors cancel each other out.
 					// across a range of values whose rounding errors cancel each other out.
-					var uniformCenteredDistribution = - 0.5 + ( i + 0.5 ) / jitterOffsets.length;
+					const uniformCenteredDistribution = - 0.5 + ( i + 0.5 ) / jitterOffsets.length;
 					sampleWeight += roundingRange * uniformCenteredDistribution;
 					sampleWeight += roundingRange * uniformCenteredDistribution;
 
 
 				}
 				}
@@ -126,13 +129,15 @@
 			renderer.setClearColor( this._oldClearColor, oldClearAlpha );
 			renderer.setClearColor( this._oldClearColor, oldClearAlpha );
 
 
 		}
 		}
-	} ); // These jitter vectors are specified in integers because it is easier.
+
+	} // These jitter vectors are specified in integers because it is easier.
 	// I am assuming a [-8,8) integer grid, but it needs to be mapped onto [-0.5,0.5)
 	// I am assuming a [-8,8) integer grid, but it needs to be mapped onto [-0.5,0.5)
 	// before being used, thus these integers need to be scaled by 1/16.
 	// before being used, thus these integers need to be scaled by 1/16.
 	//
 	//
 	// Sample patterns reference: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476218%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
 	// Sample patterns reference: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476218%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
 
 
-	SSAARenderPass.JitterVectors = [[[ 0, 0 ]], [[ 4, 4 ], [ - 4, - 4 ]], [[ - 2, - 6 ], [ 6, - 2 ], [ - 6, 2 ], [ 2, 6 ]], [[ 1, - 3 ], [ - 1, 3 ], [ 5, 1 ], [ - 3, - 5 ], [ - 5, 5 ], [ - 7, - 1 ], [ 3, 7 ], [ 7, - 7 ]], [[ 1, 1 ], [ - 1, - 3 ], [ - 3, 2 ], [ 4, - 1 ], [ - 5, - 2 ], [ 2, 5 ], [ 5, 3 ], [ 3, - 5 ], [ - 2, 6 ], [ 0, - 7 ], [ - 4, - 6 ], [ - 6, 4 ], [ - 8, 0 ], [ 7, - 4 ], [ 6, 7 ], [ - 7, - 8 ]], [[ - 4, - 7 ], [ - 7, - 5 ], [ - 3, - 5 ], [ - 5, - 4 ], [ - 1, - 4 ], [ - 2, - 2 ], [ - 6, - 1 ], [ - 4, 0 ], [ - 7, 1 ], [ - 1, 2 ], [ - 6, 3 ], [ - 3, 3 ], [ - 7, 6 ], [ - 3, 6 ], [ - 5, 7 ], [ - 1, 7 ], [ 5, - 7 ], [ 1, - 6 ], [ 6, - 5 ], [ 4, - 4 ], [ 2, - 3 ], [ 7, - 2 ], [ 1, - 1 ], [ 4, - 1 ], [ 2, 1 ], [ 6, 2 ], [ 0, 4 ], [ 4, 4 ], [ 2, 5 ], [ 7, 5 ], [ 5, 6 ], [ 3, 7 ]]];
+
+	const _JitterVectors = [[[ 0, 0 ]], [[ 4, 4 ], [ - 4, - 4 ]], [[ - 2, - 6 ], [ 6, - 2 ], [ - 6, 2 ], [ 2, 6 ]], [[ 1, - 3 ], [ - 1, 3 ], [ 5, 1 ], [ - 3, - 5 ], [ - 5, 5 ], [ - 7, - 1 ], [ 3, 7 ], [ 7, - 7 ]], [[ 1, 1 ], [ - 1, - 3 ], [ - 3, 2 ], [ 4, - 1 ], [ - 5, - 2 ], [ 2, 5 ], [ 5, 3 ], [ 3, - 5 ], [ - 2, 6 ], [ 0, - 7 ], [ - 4, - 6 ], [ - 6, 4 ], [ - 8, 0 ], [ 7, - 4 ], [ 6, 7 ], [ - 7, - 8 ]], [[ - 4, - 7 ], [ - 7, - 5 ], [ - 3, - 5 ], [ - 5, - 4 ], [ - 1, - 4 ], [ - 2, - 2 ], [ - 6, - 1 ], [ - 4, 0 ], [ - 7, 1 ], [ - 1, 2 ], [ - 6, 3 ], [ - 3, 3 ], [ - 7, 6 ], [ - 3, 6 ], [ - 5, 7 ], [ - 1, 7 ], [ 5, - 7 ], [ 1, - 6 ], [ 6, - 5 ], [ 4, - 4 ], [ 2, - 3 ], [ 7, - 2 ], [ 1, - 1 ], [ 4, - 1 ], [ 2, 1 ], [ 6, 2 ], [ 0, 4 ], [ 4, 4 ], [ 2, 5 ], [ 7, 5 ], [ 5, 6 ], [ 3, 7 ]]];
 
 
 	THREE.SSAARenderPass = SSAARenderPass;
 	THREE.SSAARenderPass = SSAARenderPass;
 
 

+ 158 - 148
examples/js/postprocessing/SSAOPass.js

@@ -1,116 +1,116 @@
 ( function () {
 ( function () {
 
 
-	var SSAOPass = function ( scene, camera, width, height ) {
-
-		THREE.Pass.call( this );
-		this.width = width !== undefined ? width : 512;
-		this.height = height !== undefined ? height : 512;
-		this.clear = true;
-		this.camera = camera;
-		this.scene = scene;
-		this.kernelRadius = 8;
-		this.kernelSize = 32;
-		this.kernel = [];
-		this.noiseTexture = null;
-		this.output = 0;
-		this.minDistance = 0.005;
-		this.maxDistance = 0.1;
-		this._visibilityCache = new Map(); //
-
-		this.generateSampleKernel();
-		this.generateRandomKernelRotations(); // beauty render target
-
-		var depthTexture = new THREE.DepthTexture();
-		depthTexture.type = THREE.UnsignedShortType;
-		this.beautyRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
-			minFilter: THREE.LinearFilter,
-			magFilter: THREE.LinearFilter,
-			format: THREE.RGBAFormat
-		} ); // normal render target with depth buffer
-
-		this.normalRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
-			minFilter: THREE.NearestFilter,
-			magFilter: THREE.NearestFilter,
-			format: THREE.RGBAFormat,
-			depthTexture: depthTexture
-		} ); // ssao render target
-
-		this.ssaoRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
-			minFilter: THREE.LinearFilter,
-			magFilter: THREE.LinearFilter,
-			format: THREE.RGBAFormat
-		} );
-		this.blurRenderTarget = this.ssaoRenderTarget.clone(); // ssao material
-
-		if ( THREE.SSAOShader === undefined ) {
-
-			console.error( 'THREE.SSAOPass: The pass relies on THREE.SSAOShader.' );
+	class SSAOPass extends THREE.Pass {
+
+		constructor( scene, camera, width, height ) {
+
+			super();
+			this.width = width !== undefined ? width : 512;
+			this.height = height !== undefined ? height : 512;
+			this.clear = true;
+			this.camera = camera;
+			this.scene = scene;
+			this.kernelRadius = 8;
+			this.kernelSize = 32;
+			this.kernel = [];
+			this.noiseTexture = null;
+			this.output = 0;
+			this.minDistance = 0.005;
+			this.maxDistance = 0.1;
+			this._visibilityCache = new Map(); //
+
+			this.generateSampleKernel();
+			this.generateRandomKernelRotations(); // beauty render target
+
+			const depthTexture = new THREE.DepthTexture();
+			depthTexture.type = THREE.UnsignedShortType;
+			this.beautyRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
+				minFilter: THREE.LinearFilter,
+				magFilter: THREE.LinearFilter,
+				format: THREE.RGBAFormat
+			} ); // normal render target with depth buffer
+
+			this.normalRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
+				minFilter: THREE.NearestFilter,
+				magFilter: THREE.NearestFilter,
+				format: THREE.RGBAFormat,
+				depthTexture: depthTexture
+			} ); // ssao render target
+
+			this.ssaoRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
+				minFilter: THREE.LinearFilter,
+				magFilter: THREE.LinearFilter,
+				format: THREE.RGBAFormat
+			} );
+			this.blurRenderTarget = this.ssaoRenderTarget.clone(); // ssao material
 
 
-		}
+			if ( THREE.SSAOShader === undefined ) {
 
 
-		this.ssaoMaterial = new THREE.ShaderMaterial( {
-			defines: Object.assign( {}, THREE.SSAOShader.defines ),
-			uniforms: THREE.UniformsUtils.clone( THREE.SSAOShader.uniforms ),
-			vertexShader: THREE.SSAOShader.vertexShader,
-			fragmentShader: THREE.SSAOShader.fragmentShader,
-			blending: THREE.NoBlending
-		} );
-		this.ssaoMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
-		this.ssaoMaterial.uniforms[ 'tNormal' ].value = this.normalRenderTarget.texture;
-		this.ssaoMaterial.uniforms[ 'tDepth' ].value = this.normalRenderTarget.depthTexture;
-		this.ssaoMaterial.uniforms[ 'tNoise' ].value = this.noiseTexture;
-		this.ssaoMaterial.uniforms[ 'kernel' ].value = this.kernel;
-		this.ssaoMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
-		this.ssaoMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
-		this.ssaoMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height );
-		this.ssaoMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
-		this.ssaoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse ); // normal material
-
-		this.normalMaterial = new THREE.MeshNormalMaterial();
-		this.normalMaterial.blending = THREE.NoBlending; // blur material
-
-		this.blurMaterial = new THREE.ShaderMaterial( {
-			defines: Object.assign( {}, THREE.SSAOBlurShader.defines ),
-			uniforms: THREE.UniformsUtils.clone( THREE.SSAOBlurShader.uniforms ),
-			vertexShader: THREE.SSAOBlurShader.vertexShader,
-			fragmentShader: THREE.SSAOBlurShader.fragmentShader
-		} );
-		this.blurMaterial.uniforms[ 'tDiffuse' ].value = this.ssaoRenderTarget.texture;
-		this.blurMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height ); // material for rendering the depth
-
-		this.depthRenderMaterial = new THREE.ShaderMaterial( {
-			defines: Object.assign( {}, THREE.SSAODepthShader.defines ),
-			uniforms: THREE.UniformsUtils.clone( THREE.SSAODepthShader.uniforms ),
-			vertexShader: THREE.SSAODepthShader.vertexShader,
-			fragmentShader: THREE.SSAODepthShader.fragmentShader,
-			blending: THREE.NoBlending
-		} );
-		this.depthRenderMaterial.uniforms[ 'tDepth' ].value = this.normalRenderTarget.depthTexture;
-		this.depthRenderMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
-		this.depthRenderMaterial.uniforms[ 'cameraFar' ].value = this.camera.far; // material for rendering the content of a render target
-
-		this.copyMaterial = new THREE.ShaderMaterial( {
-			uniforms: THREE.UniformsUtils.clone( THREE.CopyShader.uniforms ),
-			vertexShader: THREE.CopyShader.vertexShader,
-			fragmentShader: THREE.CopyShader.fragmentShader,
-			transparent: true,
-			depthTest: false,
-			depthWrite: false,
-			blendSrc: THREE.DstColorFactor,
-			blendDst: THREE.ZeroFactor,
-			blendEquation: THREE.AddEquation,
-			blendSrcAlpha: THREE.DstAlphaFactor,
-			blendDstAlpha: THREE.ZeroFactor,
-			blendEquationAlpha: THREE.AddEquation
-		} );
-		this.fsQuad = new THREE.Pass.FullScreenQuad( null );
-		this.originalClearColor = new THREE.Color();
+				console.error( 'THREE.SSAOPass: The pass relies on THREE.SSAOShader.' );
 
 
-	};
+			}
+
+			this.ssaoMaterial = new THREE.ShaderMaterial( {
+				defines: Object.assign( {}, THREE.SSAOShader.defines ),
+				uniforms: THREE.UniformsUtils.clone( THREE.SSAOShader.uniforms ),
+				vertexShader: THREE.SSAOShader.vertexShader,
+				fragmentShader: THREE.SSAOShader.fragmentShader,
+				blending: THREE.NoBlending
+			} );
+			this.ssaoMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
+			this.ssaoMaterial.uniforms[ 'tNormal' ].value = this.normalRenderTarget.texture;
+			this.ssaoMaterial.uniforms[ 'tDepth' ].value = this.normalRenderTarget.depthTexture;
+			this.ssaoMaterial.uniforms[ 'tNoise' ].value = this.noiseTexture;
+			this.ssaoMaterial.uniforms[ 'kernel' ].value = this.kernel;
+			this.ssaoMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
+			this.ssaoMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
+			this.ssaoMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height );
+			this.ssaoMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
+			this.ssaoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse ); // normal material
+
+			this.normalMaterial = new THREE.MeshNormalMaterial();
+			this.normalMaterial.blending = THREE.NoBlending; // blur material
 
 
-	SSAOPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
-		constructor: SSAOPass,
-		dispose: function () {
+			this.blurMaterial = new THREE.ShaderMaterial( {
+				defines: Object.assign( {}, THREE.SSAOBlurShader.defines ),
+				uniforms: THREE.UniformsUtils.clone( THREE.SSAOBlurShader.uniforms ),
+				vertexShader: THREE.SSAOBlurShader.vertexShader,
+				fragmentShader: THREE.SSAOBlurShader.fragmentShader
+			} );
+			this.blurMaterial.uniforms[ 'tDiffuse' ].value = this.ssaoRenderTarget.texture;
+			this.blurMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height ); // material for rendering the depth
+
+			this.depthRenderMaterial = new THREE.ShaderMaterial( {
+				defines: Object.assign( {}, THREE.SSAODepthShader.defines ),
+				uniforms: THREE.UniformsUtils.clone( THREE.SSAODepthShader.uniforms ),
+				vertexShader: THREE.SSAODepthShader.vertexShader,
+				fragmentShader: THREE.SSAODepthShader.fragmentShader,
+				blending: THREE.NoBlending
+			} );
+			this.depthRenderMaterial.uniforms[ 'tDepth' ].value = this.normalRenderTarget.depthTexture;
+			this.depthRenderMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
+			this.depthRenderMaterial.uniforms[ 'cameraFar' ].value = this.camera.far; // material for rendering the content of a render target
+
+			this.copyMaterial = new THREE.ShaderMaterial( {
+				uniforms: THREE.UniformsUtils.clone( THREE.CopyShader.uniforms ),
+				vertexShader: THREE.CopyShader.vertexShader,
+				fragmentShader: THREE.CopyShader.fragmentShader,
+				transparent: true,
+				depthTest: false,
+				depthWrite: false,
+				blendSrc: THREE.DstColorFactor,
+				blendDst: THREE.ZeroFactor,
+				blendEquation: THREE.AddEquation,
+				blendSrcAlpha: THREE.DstAlphaFactor,
+				blendDstAlpha: THREE.ZeroFactor,
+				blendEquationAlpha: THREE.AddEquation
+			} );
+			this.fsQuad = new THREE.FullScreenQuad( null );
+			this.originalClearColor = new THREE.Color();
+
+		}
+
+		dispose() {
 
 
 			// dispose render targets
 			// dispose render targets
 			this.beautyRenderTarget.dispose();
 			this.beautyRenderTarget.dispose();
@@ -125,8 +125,9 @@
 
 
 			this.fsQuad.dispose();
 			this.fsQuad.dispose();
 
 
-		},
-		render: function ( renderer, writeBuffer
+		}
+
+		render( renderer, writeBuffer
 			/*, readBuffer, deltaTime, maskActive */
 			/*, readBuffer, deltaTime, maskActive */
 		) {
 		) {
 
 
@@ -190,13 +191,14 @@
 
 
 			}
 			}
 
 
-		},
-		renderPass: function ( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
+		}
+
+		renderPass( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
 			// save original state
 			// save original state
 			renderer.getClearColor( this.originalClearColor );
 			renderer.getClearColor( this.originalClearColor );
-			var originalClearAlpha = renderer.getClearAlpha();
-			var originalAutoClear = renderer.autoClear;
+			const originalClearAlpha = renderer.getClearAlpha();
+			const originalAutoClear = renderer.autoClear;
 			renderer.setRenderTarget( renderTarget ); // setup pass state
 			renderer.setRenderTarget( renderTarget ); // setup pass state
 
 
 			renderer.autoClear = false;
 			renderer.autoClear = false;
@@ -216,12 +218,13 @@
 			renderer.setClearColor( this.originalClearColor );
 			renderer.setClearColor( this.originalClearColor );
 			renderer.setClearAlpha( originalClearAlpha );
 			renderer.setClearAlpha( originalClearAlpha );
 
 
-		},
-		renderOverride: function ( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
+		}
+
+		renderOverride( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
 			renderer.getClearColor( this.originalClearColor );
 			renderer.getClearColor( this.originalClearColor );
-			var originalClearAlpha = renderer.getClearAlpha();
-			var originalAutoClear = renderer.autoClear;
+			const originalClearAlpha = renderer.getClearAlpha();
+			const originalAutoClear = renderer.autoClear;
 			renderer.setRenderTarget( renderTarget );
 			renderer.setRenderTarget( renderTarget );
 			renderer.autoClear = false;
 			renderer.autoClear = false;
 			clearColor = overrideMaterial.clearColor || clearColor;
 			clearColor = overrideMaterial.clearColor || clearColor;
@@ -243,8 +246,9 @@
 			renderer.setClearColor( this.originalClearColor );
 			renderer.setClearColor( this.originalClearColor );
 			renderer.setClearAlpha( originalClearAlpha );
 			renderer.setClearAlpha( originalClearAlpha );
 
 
-		},
-		setSize: function ( width, height ) {
+		}
+
+		setSize( width, height ) {
 
 
 			this.width = width;
 			this.width = width;
 			this.height = height;
 			this.height = height;
@@ -257,30 +261,32 @@
 			this.ssaoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
 			this.ssaoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
 			this.blurMaterial.uniforms[ 'resolution' ].value.set( width, height );
 			this.blurMaterial.uniforms[ 'resolution' ].value.set( width, height );
 
 
-		},
-		generateSampleKernel: function () {
+		}
+
+		generateSampleKernel() {
 
 
-			var kernelSize = this.kernelSize;
-			var kernel = this.kernel;
+			const kernelSize = this.kernelSize;
+			const kernel = this.kernel;
 
 
-			for ( var i = 0; i < kernelSize; i ++ ) {
+			for ( let i = 0; i < kernelSize; i ++ ) {
 
 
-				var sample = new THREE.Vector3();
+				const sample = new THREE.Vector3();
 				sample.x = Math.random() * 2 - 1;
 				sample.x = Math.random() * 2 - 1;
 				sample.y = Math.random() * 2 - 1;
 				sample.y = Math.random() * 2 - 1;
 				sample.z = Math.random();
 				sample.z = Math.random();
 				sample.normalize();
 				sample.normalize();
-				var scale = i / kernelSize;
+				let scale = i / kernelSize;
 				scale = THREE.MathUtils.lerp( 0.1, 1, scale * scale );
 				scale = THREE.MathUtils.lerp( 0.1, 1, scale * scale );
 				sample.multiplyScalar( scale );
 				sample.multiplyScalar( scale );
 				kernel.push( sample );
 				kernel.push( sample );
 
 
 			}
 			}
 
 
-		},
-		generateRandomKernelRotations: function () {
+		}
+
+		generateRandomKernelRotations() {
 
 
-			var width = 4,
+			const width = 4,
 				height = 4;
 				height = 4;
 
 
 			if ( THREE.SimplexNoise === undefined ) {
 			if ( THREE.SimplexNoise === undefined ) {
@@ -289,17 +295,17 @@
 
 
 			}
 			}
 
 
-			var simplex = new THREE.SimplexNoise();
-			var size = width * height;
-			var data = new Float32Array( size * 4 );
+			const simplex = new THREE.SimplexNoise();
+			const size = width * height;
+			const data = new Float32Array( size * 4 );
 
 
-			for ( var i = 0; i < size; i ++ ) {
+			for ( let i = 0; i < size; i ++ ) {
 
 
-				var stride = i * 4;
-				var x = Math.random() * 2 - 1;
-				var y = Math.random() * 2 - 1;
-				var z = 0;
-				var noise = simplex.noise3d( x, y, z );
+				const stride = i * 4;
+				const x = Math.random() * 2 - 1;
+				const y = Math.random() * 2 - 1;
+				const z = 0;
+				const noise = simplex.noise3d( x, y, z );
 				data[ stride ] = noise;
 				data[ stride ] = noise;
 				data[ stride + 1 ] = noise;
 				data[ stride + 1 ] = noise;
 				data[ stride + 2 ] = noise;
 				data[ stride + 2 ] = noise;
@@ -311,11 +317,12 @@
 			this.noiseTexture.wrapS = THREE.RepeatWrapping;
 			this.noiseTexture.wrapS = THREE.RepeatWrapping;
 			this.noiseTexture.wrapT = THREE.RepeatWrapping;
 			this.noiseTexture.wrapT = THREE.RepeatWrapping;
 
 
-		},
-		overrideVisibility: function () {
+		}
+
+		overrideVisibility() {
 
 
-			var scene = this.scene;
-			var cache = this._visibilityCache;
+			const scene = this.scene;
+			const cache = this._visibilityCache;
 			scene.traverse( function ( object ) {
 			scene.traverse( function ( object ) {
 
 
 				cache.set( object, object.visible );
 				cache.set( object, object.visible );
@@ -323,21 +330,24 @@
 
 
 			} );
 			} );
 
 
-		},
-		restoreVisibility: function () {
+		}
+
+		restoreVisibility() {
 
 
-			var scene = this.scene;
-			var cache = this._visibilityCache;
+			const scene = this.scene;
+			const cache = this._visibilityCache;
 			scene.traverse( function ( object ) {
 			scene.traverse( function ( object ) {
 
 
-				var visible = cache.get( object );
+				const visible = cache.get( object );
 				object.visible = visible;
 				object.visible = visible;
 
 
 			} );
 			} );
 			cache.clear();
 			cache.clear();
 
 
 		}
 		}
-	} );
+
+	}
+
 	SSAOPass.OUTPUT = {
 	SSAOPass.OUTPUT = {
 		'Default': 0,
 		'Default': 0,
 		'SSAO': 1,
 		'SSAO': 1,

+ 266 - 259
examples/js/postprocessing/SSRPass.js

@@ -1,288 +1,288 @@
 ( function () {
 ( function () {
 
 
-	var SSRPass = function ( {
-		renderer,
-		scene,
-		camera,
-		width,
-		height,
-		selects,
-		encoding,
-		bouncing = false,
-		morphTargets = false,
-		groundReflector
-	} ) {
-
-		THREE.Pass.call( this );
-		this.width = width !== undefined ? width : 512;
-		this.height = height !== undefined ? height : 512;
-		this.clear = true;
-		this.renderer = renderer;
-		this.scene = scene;
-		this.camera = camera;
-		this.groundReflector = groundReflector;
-		this.opacity = THREE.SSRShader.uniforms.opacity.value;
-		this.output = 0;
-		this.maxDistance = THREE.SSRShader.uniforms.maxDistance.value;
-		this.surfDist = THREE.SSRShader.uniforms.surfDist.value;
-		this.encoding = encoding;
-		this.tempColor = new THREE.Color();
-		this._selects = selects;
-		this.selective = Array.isArray( this._selects );
-		Object.defineProperty( this, 'selects', {
-			get() {
-
-				return this._selects;
-
-			},
-
-			set( val ) {
-
-				if ( this._selects === val ) return;
-				this._selects = val;
-
-				if ( Array.isArray( val ) ) {
-
-					this.selective = true;
-					this.ssrMaterial.defines.SELECTIVE = true;
-					this.ssrMaterial.needsUpdate = true;
+	class SSRPass extends THREE.Pass {
+
+		constructor( {
+			renderer,
+			scene,
+			camera,
+			width,
+			height,
+			selects,
+			encoding,
+			bouncing = false,
+			morphTargets = false,
+			groundReflector
+		} ) {
+
+			super();
+			this.width = width !== undefined ? width : 512;
+			this.height = height !== undefined ? height : 512;
+			this.clear = true;
+			this.renderer = renderer;
+			this.scene = scene;
+			this.camera = camera;
+			this.groundReflector = groundReflector;
+			this.opacity = THREE.SSRShader.uniforms.opacity.value;
+			this.output = 0;
+			this.maxDistance = THREE.SSRShader.uniforms.maxDistance.value;
+			this.surfDist = THREE.SSRShader.uniforms.surfDist.value;
+			this.encoding = encoding;
+			this.tempColor = new THREE.Color();
+			this._selects = selects;
+			this.selective = Array.isArray( this._selects );
+			Object.defineProperty( this, 'selects', {
+				get() {
+
+					return this._selects;
+
+				},
+
+				set( val ) {
+
+					if ( this._selects === val ) return;
+					this._selects = val;
+
+					if ( Array.isArray( val ) ) {
+
+						this.selective = true;
+						this.ssrMaterial.defines.SELECTIVE = true;
+						this.ssrMaterial.needsUpdate = true;
 
 
-				} else {
+					} else {
 
 
-					this.selective = false;
-					this.ssrMaterial.defines.SELECTIVE = false;
-					this.ssrMaterial.needsUpdate = true;
+						this.selective = false;
+						this.ssrMaterial.defines.SELECTIVE = false;
+						this.ssrMaterial.needsUpdate = true;
+
+					}
 
 
 				}
 				}
 
 
-			}
+			} );
+			this._bouncing = bouncing;
+			Object.defineProperty( this, 'bouncing', {
+				get() {
 
 
-		} );
-		this._bouncing = bouncing;
-		Object.defineProperty( this, 'bouncing', {
-			get() {
+					return this._bouncing;
 
 
-				return this._bouncing;
+				},
 
 
-			},
+				set( val ) {
 
 
-			set( val ) {
+					if ( this._bouncing === val ) return;
+					this._bouncing = val;
 
 
-				if ( this._bouncing === val ) return;
-				this._bouncing = val;
+					if ( val ) {
 
 
-				if ( val ) {
+						this.ssrMaterial.uniforms[ 'tDiffuse' ].value = this.prevRenderTarget.texture;
 
 
-					this.ssrMaterial.uniforms[ 'tDiffuse' ].value = this.prevRenderTarget.texture;
+					} else {
 
 
-				} else {
+						this.ssrMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
 
 
-					this.ssrMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
+					}
 
 
 				}
 				}
 
 
-			}
+			} );
+			this.blur = true;
+			this._distanceAttenuation = THREE.SSRShader.defines.DISTANCE_ATTENUATION;
+			Object.defineProperty( this, 'distanceAttenuation', {
+				get() {
+
+					return this._distanceAttenuation;
 
 
-		} );
-		this.blur = true;
-		this._distanceAttenuation = THREE.SSRShader.defines.DISTANCE_ATTENUATION;
-		Object.defineProperty( this, 'distanceAttenuation', {
-			get() {
+				},
 
 
-				return this._distanceAttenuation;
+				set( val ) {
 
 
-			},
+					if ( this._distanceAttenuation === val ) return;
+					this._distanceAttenuation = val;
+					this.ssrMaterial.defines.DISTANCE_ATTENUATION = val;
+					this.ssrMaterial.needsUpdate = true;
 
 
-			set( val ) {
+				}
 
 
-				if ( this._distanceAttenuation === val ) return;
-				this._distanceAttenuation = val;
-				this.ssrMaterial.defines.DISTANCE_ATTENUATION = val;
-				this.ssrMaterial.needsUpdate = true;
+			} );
+			this._fresnel = THREE.SSRShader.defines.FRESNEL;
+			Object.defineProperty( this, 'fresnel', {
+				get() {
 
 
-			}
+					return this._fresnel;
 
 
-		} );
-		this._fresnel = THREE.SSRShader.defines.FRESNEL;
-		Object.defineProperty( this, 'fresnel', {
-			get() {
+				},
+
+				set( val ) {
+
+					if ( this._fresnel === val ) return;
+					this._fresnel = val;
+					this.ssrMaterial.defines.FRESNEL = val;
+					this.ssrMaterial.needsUpdate = true;
 
 
-				return this._fresnel;
+				}
 
 
-			},
+			} );
+			this._infiniteThick = THREE.SSRShader.defines.INFINITE_THICK;
+			Object.defineProperty( this, 'infiniteThick', {
+				get() {
 
 
-			set( val ) {
+					return this._infiniteThick;
 
 
-				if ( this._fresnel === val ) return;
-				this._fresnel = val;
-				this.ssrMaterial.defines.FRESNEL = val;
-				this.ssrMaterial.needsUpdate = true;
+				},
 
 
-			}
+				set( val ) {
 
 
-		} );
-		this._infiniteThick = THREE.SSRShader.defines.INFINITE_THICK;
-		Object.defineProperty( this, 'infiniteThick', {
-			get() {
+					if ( this._infiniteThick === val ) return;
+					this._infiniteThick = val;
+					this.ssrMaterial.defines.INFINITE_THICK = val;
+					this.ssrMaterial.needsUpdate = true;
 
 
-				return this._infiniteThick;
+				}
 
 
-			},
+			} );
+			this.thickTolerance = THREE.SSRShader.uniforms.thickTolerance.value; // beauty render target with depth buffer
+
+			const depthTexture = new THREE.DepthTexture();
+			depthTexture.type = THREE.UnsignedShortType;
+			depthTexture.minFilter = THREE.NearestFilter;
+			depthTexture.magFilter = THREE.NearestFilter;
+			this.beautyRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
+				minFilter: THREE.LinearFilter,
+				magFilter: THREE.LinearFilter,
+				format: THREE.RGBAFormat,
+				depthTexture: depthTexture,
+				depthBuffer: true
+			} ); //for bouncing
+
+			this.prevRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
+				minFilter: THREE.LinearFilter,
+				magFilter: THREE.LinearFilter,
+				format: THREE.RGBAFormat
+			} ); // normal render target
+
+			this.normalRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
+				minFilter: THREE.NearestFilter,
+				magFilter: THREE.NearestFilter,
+				format: THREE.RGBAFormat,
+				type: THREE.HalfFloatType
+			} ); // metalness render target
+
+			this.metalnessRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
+				minFilter: THREE.NearestFilter,
+				magFilter: THREE.NearestFilter,
+				format: THREE.RGBAFormat
+			} ); // ssr render target
+
+			this.ssrRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
+				minFilter: THREE.LinearFilter,
+				magFilter: THREE.LinearFilter,
+				format: THREE.RGBAFormat
+			} );
+			this.blurRenderTarget = this.ssrRenderTarget.clone();
+			this.blurRenderTarget2 = this.ssrRenderTarget.clone(); // this.blurRenderTarget3 = this.ssrRenderTarget.clone();
+			// ssr material
 
 
-			set( val ) {
+			if ( THREE.SSRShader === undefined ) {
 
 
-				if ( this._infiniteThick === val ) return;
-				this._infiniteThick = val;
-				this.ssrMaterial.defines.INFINITE_THICK = val;
-				this.ssrMaterial.needsUpdate = true;
+				console.error( 'THREE.SSRPass: The pass relies on THREE.SSRShader.' );
 
 
 			}
 			}
 
 
-		} );
-		this.thickTolerance = THREE.SSRShader.uniforms.thickTolerance.value; // beauty render target with depth buffer
-
-		var depthTexture = new THREE.DepthTexture();
-		depthTexture.type = THREE.UnsignedShortType;
-		depthTexture.minFilter = THREE.NearestFilter;
-		depthTexture.magFilter = THREE.NearestFilter;
-		this.beautyRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
-			minFilter: THREE.LinearFilter,
-			magFilter: THREE.LinearFilter,
-			format: THREE.RGBAFormat,
-			depthTexture: depthTexture,
-			depthBuffer: true
-		} ); //for bouncing
-
-		this.prevRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
-			minFilter: THREE.LinearFilter,
-			magFilter: THREE.LinearFilter,
-			format: THREE.RGBAFormat
-		} ); // normal render target
-
-		this.normalRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
-			minFilter: THREE.NearestFilter,
-			magFilter: THREE.NearestFilter,
-			format: THREE.RGBAFormat,
-			type: THREE.HalfFloatType
-		} ); // metalness render target
-
-		this.metalnessRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
-			minFilter: THREE.NearestFilter,
-			magFilter: THREE.NearestFilter,
-			format: THREE.RGBAFormat
-		} ); // ssr render target
-
-		this.ssrRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
-			minFilter: THREE.LinearFilter,
-			magFilter: THREE.LinearFilter,
-			format: THREE.RGBAFormat
-		} );
-		this.blurRenderTarget = this.ssrRenderTarget.clone();
-		this.blurRenderTarget2 = this.ssrRenderTarget.clone(); // this.blurRenderTarget3 = this.ssrRenderTarget.clone();
-		// ssr material
-
-		if ( THREE.SSRShader === undefined ) {
-
-			console.error( 'THREE.SSRPass: The pass relies on THREE.SSRShader.' );
+			this.ssrMaterial = new THREE.ShaderMaterial( {
+				defines: Object.assign( {}, THREE.SSRShader.defines, {
+					MAX_STEP: Math.sqrt( this.width * this.width + this.height * this.height )
+				} ),
+				uniforms: THREE.UniformsUtils.clone( THREE.SSRShader.uniforms ),
+				vertexShader: THREE.SSRShader.vertexShader,
+				fragmentShader: THREE.SSRShader.fragmentShader,
+				blending: THREE.NoBlending
+			} );
+			this.ssrMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
+			this.ssrMaterial.uniforms[ 'tNormal' ].value = this.normalRenderTarget.texture;
+			this.ssrMaterial.defines.SELECTIVE = this.selective;
+			this.ssrMaterial.needsUpdate = true;
+			this.ssrMaterial.uniforms[ 'tMetalness' ].value = this.metalnessRenderTarget.texture;
+			this.ssrMaterial.uniforms[ 'tDepth' ].value = this.beautyRenderTarget.depthTexture;
+			this.ssrMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
+			this.ssrMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
+			this.ssrMaterial.uniforms[ 'surfDist' ].value = this.surfDist;
+			this.ssrMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height );
+			this.ssrMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
+			this.ssrMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse ); // normal material
 
 
-		}
+			this.normalMaterial = new THREE.MeshNormalMaterial( {
+				morphTargets
+			} );
+			this.normalMaterial.blending = THREE.NoBlending; // metalnessOn material
 
 
-		this.ssrMaterial = new THREE.ShaderMaterial( {
-			defines: Object.assign( {}, THREE.SSRShader.defines, {
-				MAX_STEP: Math.sqrt( this.width * this.width + this.height * this.height )
-			} ),
-			uniforms: THREE.UniformsUtils.clone( THREE.SSRShader.uniforms ),
-			vertexShader: THREE.SSRShader.vertexShader,
-			fragmentShader: THREE.SSRShader.fragmentShader,
-			blending: THREE.NoBlending
-		} );
-		this.ssrMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
-		this.ssrMaterial.uniforms[ 'tNormal' ].value = this.normalRenderTarget.texture;
-		this.ssrMaterial.defines.SELECTIVE = this.selective;
-		this.ssrMaterial.needsUpdate = true;
-		this.ssrMaterial.uniforms[ 'tMetalness' ].value = this.metalnessRenderTarget.texture;
-		this.ssrMaterial.uniforms[ 'tDepth' ].value = this.beautyRenderTarget.depthTexture;
-		this.ssrMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
-		this.ssrMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
-		this.ssrMaterial.uniforms[ 'surfDist' ].value = this.surfDist;
-		this.ssrMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height );
-		this.ssrMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
-		this.ssrMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse ); // normal material
-
-		this.normalMaterial = new THREE.MeshNormalMaterial( {
-			morphTargets
-		} );
-		this.normalMaterial.blending = THREE.NoBlending; // metalnessOn material
-
-		this.metalnessOnMaterial = new THREE.MeshBasicMaterial( {
-			color: 'white'
-		} ); // metalnessOff material
-
-		this.metalnessOffMaterial = new THREE.MeshBasicMaterial( {
-			color: 'black'
-		} ); // blur material
-
-		this.blurMaterial = new THREE.ShaderMaterial( {
-			defines: Object.assign( {}, THREE.SSRBlurShader.defines ),
-			uniforms: THREE.UniformsUtils.clone( THREE.SSRBlurShader.uniforms ),
-			vertexShader: THREE.SSRBlurShader.vertexShader,
-			fragmentShader: THREE.SSRBlurShader.fragmentShader
-		} );
-		this.blurMaterial.uniforms[ 'tDiffuse' ].value = this.ssrRenderTarget.texture;
-		this.blurMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height ); // blur material 2
-
-		this.blurMaterial2 = new THREE.ShaderMaterial( {
-			defines: Object.assign( {}, THREE.SSRBlurShader.defines ),
-			uniforms: THREE.UniformsUtils.clone( THREE.SSRBlurShader.uniforms ),
-			vertexShader: THREE.SSRBlurShader.vertexShader,
-			fragmentShader: THREE.SSRBlurShader.fragmentShader
-		} );
-		this.blurMaterial2.uniforms[ 'tDiffuse' ].value = this.blurRenderTarget.texture;
-		this.blurMaterial2.uniforms[ 'resolution' ].value.set( this.width, this.height ); // // blur material 3
-		// this.blurMaterial3 = new THREE.ShaderMaterial({
-		//	 defines: Object.assign({}, THREE.SSRBlurShader.defines),
-		//	 uniforms: THREE.UniformsUtils.clone(THREE.SSRBlurShader.uniforms),
-		//	 vertexShader: THREE.SSRBlurShader.vertexShader,
-		//	 fragmentShader: THREE.SSRBlurShader.fragmentShader
-		// });
-		// this.blurMaterial3.uniforms['tDiffuse'].value = this.blurRenderTarget2.texture;
-		// this.blurMaterial3.uniforms['resolution'].value.set(this.width, this.height);
-		// material for rendering the depth
-
-		this.depthRenderMaterial = new THREE.ShaderMaterial( {
-			defines: Object.assign( {}, THREE.SSRDepthShader.defines ),
-			uniforms: THREE.UniformsUtils.clone( THREE.SSRDepthShader.uniforms ),
-			vertexShader: THREE.SSRDepthShader.vertexShader,
-			fragmentShader: THREE.SSRDepthShader.fragmentShader,
-			blending: THREE.NoBlending
-		} );
-		this.depthRenderMaterial.uniforms[ 'tDepth' ].value = this.beautyRenderTarget.depthTexture;
-		this.depthRenderMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
-		this.depthRenderMaterial.uniforms[ 'cameraFar' ].value = this.camera.far; // material for rendering the content of a render target
-
-		this.copyMaterial = new THREE.ShaderMaterial( {
-			uniforms: THREE.UniformsUtils.clone( THREE.CopyShader.uniforms ),
-			vertexShader: THREE.CopyShader.vertexShader,
-			fragmentShader: THREE.CopyShader.fragmentShader,
-			transparent: true,
-			depthTest: false,
-			depthWrite: false,
-			blendSrc: THREE.SrcAlphaFactor,
-			blendDst: THREE.OneMinusSrcAlphaFactor,
-			blendEquation: THREE.AddEquation,
-			blendSrcAlpha: THREE.SrcAlphaFactor,
-			blendDstAlpha: THREE.OneMinusSrcAlphaFactor,
-			blendEquationAlpha: THREE.AddEquation // premultipliedAlpha:true,
-
-		} );
-		this.fsQuad = new THREE.Pass.FullScreenQuad( null );
-		this.originalClearColor = new THREE.Color();
+			this.metalnessOnMaterial = new THREE.MeshBasicMaterial( {
+				color: 'white'
+			} ); // metalnessOff material
 
 
-	};
+			this.metalnessOffMaterial = new THREE.MeshBasicMaterial( {
+				color: 'black'
+			} ); // blur material
 
 
-	SSRPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
-		constructor: SSRPass,
-		dispose: function () {
+			this.blurMaterial = new THREE.ShaderMaterial( {
+				defines: Object.assign( {}, THREE.SSRBlurShader.defines ),
+				uniforms: THREE.UniformsUtils.clone( THREE.SSRBlurShader.uniforms ),
+				vertexShader: THREE.SSRBlurShader.vertexShader,
+				fragmentShader: THREE.SSRBlurShader.fragmentShader
+			} );
+			this.blurMaterial.uniforms[ 'tDiffuse' ].value = this.ssrRenderTarget.texture;
+			this.blurMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height ); // blur material 2
+
+			this.blurMaterial2 = new THREE.ShaderMaterial( {
+				defines: Object.assign( {}, THREE.SSRBlurShader.defines ),
+				uniforms: THREE.UniformsUtils.clone( THREE.SSRBlurShader.uniforms ),
+				vertexShader: THREE.SSRBlurShader.vertexShader,
+				fragmentShader: THREE.SSRBlurShader.fragmentShader
+			} );
+			this.blurMaterial2.uniforms[ 'tDiffuse' ].value = this.blurRenderTarget.texture;
+			this.blurMaterial2.uniforms[ 'resolution' ].value.set( this.width, this.height ); // // blur material 3
+			// this.blurMaterial3 = new THREE.ShaderMaterial({
+			//	 defines: Object.assign({}, THREE.SSRBlurShader.defines),
+			//	 uniforms: THREE.UniformsUtils.clone(THREE.SSRBlurShader.uniforms),
+			//	 vertexShader: THREE.SSRBlurShader.vertexShader,
+			//	 fragmentShader: THREE.SSRBlurShader.fragmentShader
+			// });
+			// this.blurMaterial3.uniforms['tDiffuse'].value = this.blurRenderTarget2.texture;
+			// this.blurMaterial3.uniforms['resolution'].value.set(this.width, this.height);
+			// material for rendering the depth
+
+			this.depthRenderMaterial = new THREE.ShaderMaterial( {
+				defines: Object.assign( {}, THREE.SSRDepthShader.defines ),
+				uniforms: THREE.UniformsUtils.clone( THREE.SSRDepthShader.uniforms ),
+				vertexShader: THREE.SSRDepthShader.vertexShader,
+				fragmentShader: THREE.SSRDepthShader.fragmentShader,
+				blending: THREE.NoBlending
+			} );
+			this.depthRenderMaterial.uniforms[ 'tDepth' ].value = this.beautyRenderTarget.depthTexture;
+			this.depthRenderMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
+			this.depthRenderMaterial.uniforms[ 'cameraFar' ].value = this.camera.far; // material for rendering the content of a render target
+
+			this.copyMaterial = new THREE.ShaderMaterial( {
+				uniforms: THREE.UniformsUtils.clone( THREE.CopyShader.uniforms ),
+				vertexShader: THREE.CopyShader.vertexShader,
+				fragmentShader: THREE.CopyShader.fragmentShader,
+				transparent: true,
+				depthTest: false,
+				depthWrite: false,
+				blendSrc: THREE.SrcAlphaFactor,
+				blendDst: THREE.OneMinusSrcAlphaFactor,
+				blendEquation: THREE.AddEquation,
+				blendSrcAlpha: THREE.SrcAlphaFactor,
+				blendDstAlpha: THREE.OneMinusSrcAlphaFactor,
+				blendEquationAlpha: THREE.AddEquation // premultipliedAlpha:true,
+
+			} );
+			this.fsQuad = new THREE.FullScreenQuad( null );
+			this.originalClearColor = new THREE.Color();
+
+		}
+
+		dispose() {
 
 
 			// dispose render targets
 			// dispose render targets
 			this.beautyRenderTarget.dispose();
 			this.beautyRenderTarget.dispose();
@@ -304,8 +304,9 @@
 
 
 			this.fsQuad.dispose();
 			this.fsQuad.dispose();
 
 
-		},
-		render: function ( renderer, writeBuffer
+		}
+
+		render( renderer, writeBuffer
 			/*, readBuffer, deltaTime, maskActive */
 			/*, readBuffer, deltaTime, maskActive */
 		) {
 		) {
 
 
@@ -421,13 +422,14 @@
 
 
 			}
 			}
 
 
-		},
-		renderPass: function ( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
+		}
+
+		renderPass( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
 			// save original state
 			// save original state
 			this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
 			this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
-			var originalClearAlpha = renderer.getClearAlpha( this.tempColor );
-			var originalAutoClear = renderer.autoClear;
+			const originalClearAlpha = renderer.getClearAlpha( this.tempColor );
+			const originalAutoClear = renderer.autoClear;
 			renderer.setRenderTarget( renderTarget ); // setup pass state
 			renderer.setRenderTarget( renderTarget ); // setup pass state
 
 
 			renderer.autoClear = false;
 			renderer.autoClear = false;
@@ -447,12 +449,13 @@
 			renderer.setClearColor( this.originalClearColor );
 			renderer.setClearColor( this.originalClearColor );
 			renderer.setClearAlpha( originalClearAlpha );
 			renderer.setClearAlpha( originalClearAlpha );
 
 
-		},
-		renderOverride: function ( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
+		}
+
+		renderOverride( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
 			this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
 			this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
-			var originalClearAlpha = renderer.getClearAlpha( this.tempColor );
-			var originalAutoClear = renderer.autoClear;
+			const originalClearAlpha = renderer.getClearAlpha( this.tempColor );
+			const originalAutoClear = renderer.autoClear;
 			renderer.setRenderTarget( renderTarget );
 			renderer.setRenderTarget( renderTarget );
 			renderer.autoClear = false;
 			renderer.autoClear = false;
 			clearColor = overrideMaterial.clearColor || clearColor;
 			clearColor = overrideMaterial.clearColor || clearColor;
@@ -474,12 +477,13 @@
 			renderer.setClearColor( this.originalClearColor );
 			renderer.setClearColor( this.originalClearColor );
 			renderer.setClearAlpha( originalClearAlpha );
 			renderer.setClearAlpha( originalClearAlpha );
 
 
-		},
-		renderMetalness: function ( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
+		}
+
+		renderMetalness( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
 			this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
 			this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
-			var originalClearAlpha = renderer.getClearAlpha( this.tempColor );
-			var originalAutoClear = renderer.autoClear;
+			const originalClearAlpha = renderer.getClearAlpha( this.tempColor );
+			const originalAutoClear = renderer.autoClear;
 			renderer.setRenderTarget( renderTarget );
 			renderer.setRenderTarget( renderTarget );
 			renderer.autoClear = false;
 			renderer.autoClear = false;
 			clearColor = overrideMaterial.clearColor || clearColor;
 			clearColor = overrideMaterial.clearColor || clearColor;
@@ -519,8 +523,9 @@
 			renderer.setClearColor( this.originalClearColor );
 			renderer.setClearColor( this.originalClearColor );
 			renderer.setClearAlpha( originalClearAlpha );
 			renderer.setClearAlpha( originalClearAlpha );
 
 
-		},
-		setSize: function ( width, height ) {
+		}
+
+		setSize( width, height ) {
 
 
 			this.width = width;
 			this.width = width;
 			this.height = height;
 			this.height = height;
@@ -541,7 +546,9 @@
 			this.blurMaterial2.uniforms[ 'resolution' ].value.set( width, height );
 			this.blurMaterial2.uniforms[ 'resolution' ].value.set( width, height );
 
 
 		}
 		}
-	} );
+
+	}
+
 	SSRPass.OUTPUT = {
 	SSRPass.OUTPUT = {
 		'Default': 0,
 		'Default': 0,
 		'SSR': 1,
 		'SSR': 1,

+ 210 - 203
examples/js/postprocessing/SSRrPass.js

@@ -1,210 +1,210 @@
 ( function () {
 ( function () {
 
 
-	var SSRrPass = function ( {
-		renderer,
-		scene,
-		camera,
-		width,
-		height,
-		selects,
-		encoding,
-		morphTargets = false
-	} ) {
-
-		THREE.Pass.call( this );
-		this.width = width !== undefined ? width : 512;
-		this.height = height !== undefined ? height : 512;
-		this.clear = true;
-		this.renderer = renderer;
-		this.scene = scene;
-		this.camera = camera;
-		this.output = 0; // this.output = 1;
-
-		this.ior = THREE.SSRrShader.uniforms.ior.value;
-		this.maxDistance = THREE.SSRrShader.uniforms.maxDistance.value;
-		this.surfDist = THREE.SSRrShader.uniforms.surfDist.value;
-		this.encoding = encoding;
-		this.tempColor = new THREE.Color();
-		this.selects = selects;
-		this._specular = THREE.SSRrShader.defines.SPECULAR;
-		Object.defineProperty( this, 'specular', {
-			get() {
-
-				return this._specular;
-
-			},
-
-			set( val ) {
-
-				if ( this._specular === val ) return;
-				this._specular = val;
-				this.ssrrMaterial.defines.SPECULAR = val;
-				this.ssrrMaterial.needsUpdate = true;
+	class SSRrPass extends THREE.Pass {
+
+		constructor( {
+			renderer,
+			scene,
+			camera,
+			width,
+			height,
+			selects,
+			encoding,
+			morphTargets = false
+		} ) {
+
+			super();
+			this.width = width !== undefined ? width : 512;
+			this.height = height !== undefined ? height : 512;
+			this.clear = true;
+			this.renderer = renderer;
+			this.scene = scene;
+			this.camera = camera;
+			this.output = 0; // this.output = 1;
+
+			this.ior = THREE.SSRrShader.uniforms.ior.value;
+			this.maxDistance = THREE.SSRrShader.uniforms.maxDistance.value;
+			this.surfDist = THREE.SSRrShader.uniforms.surfDist.value;
+			this.encoding = encoding;
+			this.tempColor = new THREE.Color();
+			this.selects = selects;
+			this._specular = THREE.SSRrShader.defines.SPECULAR;
+			Object.defineProperty( this, 'specular', {
+				get() {
+
+					return this._specular;
+
+				},
+
+				set( val ) {
+
+					if ( this._specular === val ) return;
+					this._specular = val;
+					this.ssrrMaterial.defines.SPECULAR = val;
+					this.ssrrMaterial.needsUpdate = true;
 
 
-			}
+				}
 
 
-		} );
-		this._fillHole = THREE.SSRrShader.defines.FILL_HOLE;
-		Object.defineProperty( this, 'fillHole', {
-			get() {
+			} );
+			this._fillHole = THREE.SSRrShader.defines.FILL_HOLE;
+			Object.defineProperty( this, 'fillHole', {
+				get() {
 
 
-				return this._fillHole;
+					return this._fillHole;
 
 
-			},
+				},
 
 
-			set( val ) {
+				set( val ) {
 
 
-				if ( this._fillHole === val ) return;
-				this._fillHole = val;
-				this.ssrrMaterial.defines.FILL_HOLE = val;
-				this.ssrrMaterial.needsUpdate = true;
+					if ( this._fillHole === val ) return;
+					this._fillHole = val;
+					this.ssrrMaterial.defines.FILL_HOLE = val;
+					this.ssrrMaterial.needsUpdate = true;
 
 
-			}
+				}
+
+			} );
+			this._infiniteThick = THREE.SSRrShader.defines.INFINITE_THICK;
+			Object.defineProperty( this, 'infiniteThick', {
+				get() {
+
+					return this._infiniteThick;
 
 
-		} );
-		this._infiniteThick = THREE.SSRrShader.defines.INFINITE_THICK;
-		Object.defineProperty( this, 'infiniteThick', {
-			get() {
+				},
 
 
-				return this._infiniteThick;
+				set( val ) {
 
 
-			},
+					if ( this._infiniteThick === val ) return;
+					this._infiniteThick = val;
+					this.ssrrMaterial.defines.INFINITE_THICK = val;
+					this.ssrrMaterial.needsUpdate = true;
 
 
-			set( val ) {
+				}
 
 
-				if ( this._infiniteThick === val ) return;
-				this._infiniteThick = val;
-				this.ssrrMaterial.defines.INFINITE_THICK = val;
-				this.ssrrMaterial.needsUpdate = true;
+			} ); // beauty render target with depth buffer
+
+			const depthTexture = new THREE.DepthTexture();
+			depthTexture.type = THREE.UnsignedShortType;
+			depthTexture.minFilter = THREE.NearestFilter;
+			depthTexture.magFilter = THREE.NearestFilter;
+			this.beautyRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
+				minFilter: THREE.NearestFilter,
+				magFilter: THREE.NearestFilter,
+				format: THREE.RGBAFormat,
+				depthTexture: depthTexture,
+				depthBuffer: true
+			} );
+			this.specularRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
+			// TODO: Can merge with refractiveRenderTarget?
+				minFilter: THREE.NearestFilter,
+				magFilter: THREE.NearestFilter,
+				format: THREE.RGBAFormat
+			} ); // normalSelects render target
+
+			const depthTextureSelects = new THREE.DepthTexture();
+			depthTextureSelects.type = THREE.UnsignedShortType;
+			depthTextureSelects.minFilter = THREE.NearestFilter;
+			depthTextureSelects.magFilter = THREE.NearestFilter;
+			this.normalSelectsRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
+				minFilter: THREE.NearestFilter,
+				magFilter: THREE.NearestFilter,
+				format: THREE.RGBAFormat,
+				type: THREE.HalfFloatType,
+				depthTexture: depthTextureSelects,
+				depthBuffer: true
+			} ); // refractive render target
+
+			this.refractiveRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
+				minFilter: THREE.NearestFilter,
+				magFilter: THREE.NearestFilter,
+				format: THREE.RGBAFormat
+			} ); // ssrr render target
+
+			this.ssrrRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
+				minFilter: THREE.NearestFilter,
+				magFilter: THREE.NearestFilter,
+				format: THREE.RGBAFormat
+			} ); // ssrr material
+
+			if ( THREE.SSRrShader === undefined ) {
+
+				console.error( 'THREE.SSRrPass: The pass relies on THREE.SSRrShader.' );
 
 
 			}
 			}
 
 
-		} ); // beauty render target with depth buffer
-
-		var depthTexture = new THREE.DepthTexture();
-		depthTexture.type = THREE.UnsignedShortType;
-		depthTexture.minFilter = THREE.NearestFilter;
-		depthTexture.magFilter = THREE.NearestFilter;
-		this.beautyRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
-			minFilter: THREE.NearestFilter,
-			magFilter: THREE.NearestFilter,
-			format: THREE.RGBAFormat,
-			depthTexture: depthTexture,
-			depthBuffer: true
-		} );
-		this.specularRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
-		// TODO: Can merge with refractiveRenderTarget?
-			minFilter: THREE.NearestFilter,
-			magFilter: THREE.NearestFilter,
-			format: THREE.RGBAFormat
-		} ); // normalSelects render target
-
-		var depthTextureSelects = new THREE.DepthTexture();
-		depthTextureSelects.type = THREE.UnsignedShortType;
-		depthTextureSelects.minFilter = THREE.NearestFilter;
-		depthTextureSelects.magFilter = THREE.NearestFilter;
-		this.normalSelectsRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
-			minFilter: THREE.NearestFilter,
-			magFilter: THREE.NearestFilter,
-			format: THREE.RGBAFormat,
-			type: THREE.HalfFloatType,
-			depthTexture: depthTextureSelects,
-			depthBuffer: true
-		} ); // refractive render target
-
-		this.refractiveRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
-			minFilter: THREE.NearestFilter,
-			magFilter: THREE.NearestFilter,
-			format: THREE.RGBAFormat
-		} ); // ssrr render target
-
-		this.ssrrRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
-			minFilter: THREE.NearestFilter,
-			magFilter: THREE.NearestFilter,
-			format: THREE.RGBAFormat
-		} ); // ssrr material
-
-		if ( THREE.SSRrShader === undefined ) {
-
-			console.error( 'THREE.SSRrPass: The pass relies on THREE.SSRrShader.' );
+			this.ssrrMaterial = new THREE.ShaderMaterial( {
+				defines: Object.assign( {}, THREE.SSRrShader.defines, {
+					MAX_STEP: Math.sqrt( this.width * this.width + this.height * this.height )
+				} ),
+				uniforms: THREE.UniformsUtils.clone( THREE.SSRrShader.uniforms ),
+				vertexShader: THREE.SSRrShader.vertexShader,
+				fragmentShader: THREE.SSRrShader.fragmentShader,
+				blending: THREE.NoBlending
+			} );
+			this.ssrrMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
+			this.ssrrMaterial.uniforms[ 'tSpecular' ].value = this.specularRenderTarget.texture;
+			this.ssrrMaterial.uniforms[ 'tNormalSelects' ].value = this.normalSelectsRenderTarget.texture;
+			this.ssrrMaterial.needsUpdate = true;
+			this.ssrrMaterial.uniforms[ 'tRefractive' ].value = this.refractiveRenderTarget.texture;
+			this.ssrrMaterial.uniforms[ 'tDepth' ].value = this.beautyRenderTarget.depthTexture;
+			this.ssrrMaterial.uniforms[ 'tDepthSelects' ].value = this.normalSelectsRenderTarget.depthTexture;
+			this.ssrrMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
+			this.ssrrMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
+			this.ssrrMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height );
+			this.ssrrMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
+			this.ssrrMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse ); // normal material
 
 
-		}
+			this.normalMaterial = new THREE.MeshNormalMaterial( {
+				morphTargets
+			} );
+			this.normalMaterial.blending = THREE.NoBlending; // refractiveOn material
+
+			this.refractiveOnMaterial = new THREE.MeshBasicMaterial( {
+				color: 'white'
+			} ); // refractiveOff material
+
+			this.refractiveOffMaterial = new THREE.MeshBasicMaterial( {
+				color: 'black'
+			} ); // specular material
+
+			this.specularMaterial = new THREE.MeshStandardMaterial( {
+				color: 'black',
+				metalness: 0,
+				roughness: .2
+			} ); // material for rendering the depth
+
+			this.depthRenderMaterial = new THREE.ShaderMaterial( {
+				defines: Object.assign( {}, THREE.SSRrDepthShader.defines ),
+				uniforms: THREE.UniformsUtils.clone( THREE.SSRrDepthShader.uniforms ),
+				vertexShader: THREE.SSRrDepthShader.vertexShader,
+				fragmentShader: THREE.SSRrDepthShader.fragmentShader,
+				blending: THREE.NoBlending
+			} );
+			this.depthRenderMaterial.uniforms[ 'tDepth' ].value = this.beautyRenderTarget.depthTexture;
+			this.depthRenderMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
+			this.depthRenderMaterial.uniforms[ 'cameraFar' ].value = this.camera.far; // material for rendering the content of a render target
+
+			this.copyMaterial = new THREE.ShaderMaterial( {
+				uniforms: THREE.UniformsUtils.clone( THREE.CopyShader.uniforms ),
+				vertexShader: THREE.CopyShader.vertexShader,
+				fragmentShader: THREE.CopyShader.fragmentShader,
+				transparent: true,
+				depthTest: false,
+				depthWrite: false,
+				blendSrc: THREE.SrcAlphaFactor,
+				blendDst: THREE.OneMinusSrcAlphaFactor,
+				blendEquation: THREE.AddEquation,
+				blendSrcAlpha: THREE.SrcAlphaFactor,
+				blendDstAlpha: THREE.OneMinusSrcAlphaFactor,
+				blendEquationAlpha: THREE.AddEquation // premultipliedAlpha:true,
 
 
-		this.ssrrMaterial = new THREE.ShaderMaterial( {
-			defines: Object.assign( {}, THREE.SSRrShader.defines, {
-				MAX_STEP: Math.sqrt( this.width * this.width + this.height * this.height )
-			} ),
-			uniforms: THREE.UniformsUtils.clone( THREE.SSRrShader.uniforms ),
-			vertexShader: THREE.SSRrShader.vertexShader,
-			fragmentShader: THREE.SSRrShader.fragmentShader,
-			blending: THREE.NoBlending
-		} );
-		this.ssrrMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
-		this.ssrrMaterial.uniforms[ 'tSpecular' ].value = this.specularRenderTarget.texture;
-		this.ssrrMaterial.uniforms[ 'tNormalSelects' ].value = this.normalSelectsRenderTarget.texture;
-		this.ssrrMaterial.needsUpdate = true;
-		this.ssrrMaterial.uniforms[ 'tRefractive' ].value = this.refractiveRenderTarget.texture;
-		this.ssrrMaterial.uniforms[ 'tDepth' ].value = this.beautyRenderTarget.depthTexture;
-		this.ssrrMaterial.uniforms[ 'tDepthSelects' ].value = this.normalSelectsRenderTarget.depthTexture;
-		this.ssrrMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
-		this.ssrrMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
-		this.ssrrMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height );
-		this.ssrrMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
-		this.ssrrMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse ); // normal material
-
-		this.normalMaterial = new THREE.MeshNormalMaterial( {
-			morphTargets
-		} );
-		this.normalMaterial.blending = THREE.NoBlending; // refractiveOn material
-
-		this.refractiveOnMaterial = new THREE.MeshBasicMaterial( {
-			color: 'white'
-		} ); // refractiveOff material
-
-		this.refractiveOffMaterial = new THREE.MeshBasicMaterial( {
-			color: 'black'
-		} ); // specular material
-
-		this.specularMaterial = new THREE.MeshStandardMaterial( {
-			color: 'black',
-			metalness: 0,
-			roughness: .2
-		} ); // material for rendering the depth
-
-		this.depthRenderMaterial = new THREE.ShaderMaterial( {
-			defines: Object.assign( {}, THREE.SSRrDepthShader.defines ),
-			uniforms: THREE.UniformsUtils.clone( THREE.SSRrDepthShader.uniforms ),
-			vertexShader: THREE.SSRrDepthShader.vertexShader,
-			fragmentShader: THREE.SSRrDepthShader.fragmentShader,
-			blending: THREE.NoBlending
-		} );
-		this.depthRenderMaterial.uniforms[ 'tDepth' ].value = this.beautyRenderTarget.depthTexture;
-		this.depthRenderMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
-		this.depthRenderMaterial.uniforms[ 'cameraFar' ].value = this.camera.far; // material for rendering the content of a render target
-
-		this.copyMaterial = new THREE.ShaderMaterial( {
-			uniforms: THREE.UniformsUtils.clone( THREE.CopyShader.uniforms ),
-			vertexShader: THREE.CopyShader.vertexShader,
-			fragmentShader: THREE.CopyShader.fragmentShader,
-			transparent: true,
-			depthTest: false,
-			depthWrite: false,
-			blendSrc: THREE.SrcAlphaFactor,
-			blendDst: THREE.OneMinusSrcAlphaFactor,
-			blendEquation: THREE.AddEquation,
-			blendSrcAlpha: THREE.SrcAlphaFactor,
-			blendDstAlpha: THREE.OneMinusSrcAlphaFactor,
-			blendEquationAlpha: THREE.AddEquation // premultipliedAlpha:true,
-
-		} );
-		this.fsQuad = new THREE.Pass.FullScreenQuad( null );
-		this.originalClearColor = new THREE.Color();
+			} );
+			this.fsQuad = new THREE.FullScreenQuad( null );
+			this.originalClearColor = new THREE.Color();
 
 
-	};
+		}
 
 
-	SSRrPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
-		constructor: SSRrPass,
-		dispose: function () {
+		dispose() {
 
 
 			// dispose render targets
 			// dispose render targets
 			this.beautyRenderTarget.dispose();
 			this.beautyRenderTarget.dispose();
@@ -221,8 +221,9 @@
 
 
 			this.fsQuad.dispose();
 			this.fsQuad.dispose();
 
 
-		},
-		render: function ( renderer, writeBuffer
+		}
+
+		render( renderer, writeBuffer
 			/*, readBuffer, deltaTime, maskActive */
 			/*, readBuffer, deltaTime, maskActive */
 		) {
 		) {
 
 
@@ -350,13 +351,14 @@
 
 
 			}
 			}
 
 
-		},
-		renderPass: function ( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
+		}
+
+		renderPass( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
 			// save original state
 			// save original state
 			this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
 			this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
-			var originalClearAlpha = renderer.getClearAlpha( this.tempColor );
-			var originalAutoClear = renderer.autoClear;
+			const originalClearAlpha = renderer.getClearAlpha( this.tempColor );
+			const originalAutoClear = renderer.autoClear;
 			renderer.setRenderTarget( renderTarget ); // setup pass state
 			renderer.setRenderTarget( renderTarget ); // setup pass state
 
 
 			renderer.autoClear = false;
 			renderer.autoClear = false;
@@ -376,12 +378,13 @@
 			renderer.setClearColor( this.originalClearColor );
 			renderer.setClearColor( this.originalClearColor );
 			renderer.setClearAlpha( originalClearAlpha );
 			renderer.setClearAlpha( originalClearAlpha );
 
 
-		},
-		renderOverride: function ( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
+		}
+
+		renderOverride( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
 			this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
 			this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
-			var originalClearAlpha = renderer.getClearAlpha( this.tempColor );
-			var originalAutoClear = renderer.autoClear;
+			const originalClearAlpha = renderer.getClearAlpha( this.tempColor );
+			const originalAutoClear = renderer.autoClear;
 			renderer.setRenderTarget( renderTarget );
 			renderer.setRenderTarget( renderTarget );
 			renderer.autoClear = false;
 			renderer.autoClear = false;
 			clearColor = overrideMaterial.clearColor || clearColor;
 			clearColor = overrideMaterial.clearColor || clearColor;
@@ -403,12 +406,13 @@
 			renderer.setClearColor( this.originalClearColor );
 			renderer.setClearColor( this.originalClearColor );
 			renderer.setClearAlpha( originalClearAlpha );
 			renderer.setClearAlpha( originalClearAlpha );
 
 
-		},
-		renderRefractive: function ( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
+		}
+
+		renderRefractive( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
 			this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
 			this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
-			var originalClearAlpha = renderer.getClearAlpha( this.tempColor );
-			var originalAutoClear = renderer.autoClear;
+			const originalClearAlpha = renderer.getClearAlpha( this.tempColor );
+			const originalAutoClear = renderer.autoClear;
 			renderer.setRenderTarget( renderTarget );
 			renderer.setRenderTarget( renderTarget );
 			renderer.autoClear = false;
 			renderer.autoClear = false;
 			clearColor = overrideMaterial.clearColor || clearColor;
 			clearColor = overrideMaterial.clearColor || clearColor;
@@ -459,8 +463,9 @@
 			renderer.setClearColor( this.originalClearColor );
 			renderer.setClearColor( this.originalClearColor );
 			renderer.setClearAlpha( originalClearAlpha );
 			renderer.setClearAlpha( originalClearAlpha );
 
 
-		},
-		setSize: function ( width, height ) {
+		}
+
+		setSize( width, height ) {
 
 
 			this.width = width;
 			this.width = width;
 			this.height = height;
 			this.height = height;
@@ -476,7 +481,9 @@
 			this.ssrrMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
 			this.ssrrMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
 
 
 		}
 		}
-	} );
+
+	}
+
 	SSRrPass.OUTPUT = {
 	SSRrPass.OUTPUT = {
 		'Default': 0,
 		'Default': 0,
 		'SSRr': 1,
 		'SSRr': 1,

+ 32 - 29
examples/js/postprocessing/SavePass.js

@@ -1,38 +1,40 @@
 ( function () {
 ( function () {
 
 
-	var SavePass = function ( renderTarget ) {
-
-		THREE.Pass.call( this );
-		if ( THREE.CopyShader === undefined ) console.error( 'THREE.SavePass relies on THREE.CopyShader' );
-		var shader = THREE.CopyShader;
-		this.textureID = 'tDiffuse';
-		this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
-		this.material = new THREE.ShaderMaterial( {
-			uniforms: this.uniforms,
-			vertexShader: shader.vertexShader,
-			fragmentShader: shader.fragmentShader
-		} );
-		this.renderTarget = renderTarget;
-
-		if ( this.renderTarget === undefined ) {
-
-			this.renderTarget = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, {
-				minFilter: THREE.LinearFilter,
-				magFilter: THREE.LinearFilter,
-				format: THREE.RGBFormat
+	class SavePass extends THREE.Pass {
+
+		constructor( renderTarget ) {
+
+			super();
+			if ( THREE.CopyShader === undefined ) console.error( 'THREE.SavePass relies on THREE.CopyShader' );
+			const shader = THREE.CopyShader;
+			this.textureID = 'tDiffuse';
+			this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
+			this.material = new THREE.ShaderMaterial( {
+				uniforms: this.uniforms,
+				vertexShader: shader.vertexShader,
+				fragmentShader: shader.fragmentShader
 			} );
 			} );
-			this.renderTarget.texture.name = 'SavePass.rt';
+			this.renderTarget = renderTarget;
 
 
-		}
+			if ( this.renderTarget === undefined ) {
+
+				this.renderTarget = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, {
+					minFilter: THREE.LinearFilter,
+					magFilter: THREE.LinearFilter,
+					format: THREE.RGBFormat
+				} );
+				this.renderTarget.texture.name = 'SavePass.rt';
+
+			}
 
 
-		this.needsSwap = false;
-		this.fsQuad = new THREE.Pass.FullScreenQuad( this.material );
+			this.needsSwap = false;
+			this.fsQuad = new THREE.FullScreenQuad( this.material );
 
 
-	};
+		}
 
 
-	SavePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
-		constructor: SavePass,
-		render: function ( renderer, writeBuffer, readBuffer ) {
+		render( renderer, writeBuffer, readBuffer
+			/*, deltaTime, maskActive */
+		) {
 
 
 			if ( this.uniforms[ this.textureID ] ) {
 			if ( this.uniforms[ this.textureID ] ) {
 
 
@@ -45,7 +47,8 @@
 			this.fsQuad.render( renderer );
 			this.fsQuad.render( renderer );
 
 
 		}
 		}
-	} );
+
+	}
 
 
 	THREE.SavePass = SavePass;
 	THREE.SavePass = SavePass;
 
 

+ 22 - 21
examples/js/postprocessing/ShaderPass.js

@@ -1,34 +1,34 @@
 ( function () {
 ( function () {
 
 
-	var ShaderPass = function ( shader, textureID ) {
+	class ShaderPass extends THREE.Pass {
 
 
-		THREE.Pass.call( this );
-		this.textureID = textureID !== undefined ? textureID : 'tDiffuse';
+		constructor( shader, textureID ) {
 
 
-		if ( shader instanceof THREE.ShaderMaterial ) {
+			super();
+			this.textureID = textureID !== undefined ? textureID : 'tDiffuse';
 
 
-			this.uniforms = shader.uniforms;
-			this.material = shader;
+			if ( shader instanceof THREE.ShaderMaterial ) {
 
 
-		} else if ( shader ) {
+				this.uniforms = shader.uniforms;
+				this.material = shader;
 
 
-			this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
-			this.material = new THREE.ShaderMaterial( {
-				defines: Object.assign( {}, shader.defines ),
-				uniforms: this.uniforms,
-				vertexShader: shader.vertexShader,
-				fragmentShader: shader.fragmentShader
-			} );
+			} else if ( shader ) {
 
 
-		}
+				this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
+				this.material = new THREE.ShaderMaterial( {
+					defines: Object.assign( {}, shader.defines ),
+					uniforms: this.uniforms,
+					vertexShader: shader.vertexShader,
+					fragmentShader: shader.fragmentShader
+				} );
 
 
-		this.fsQuad = new THREE.Pass.FullScreenQuad( this.material );
+			}
 
 
-	};
+			this.fsQuad = new THREE.FullScreenQuad( this.material );
 
 
-	ShaderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
-		constructor: ShaderPass,
-		render: function ( renderer, writeBuffer, readBuffer
+		}
+
+		render( renderer, writeBuffer, readBuffer
 			/*, deltaTime, maskActive */
 			/*, deltaTime, maskActive */
 		) {
 		) {
 
 
@@ -55,7 +55,8 @@
 			}
 			}
 
 
 		}
 		}
-	} );
+
+	}
 
 
 	THREE.ShaderPass = ShaderPass;
 	THREE.ShaderPass = ShaderPass;
 
 

+ 20 - 24
examples/js/postprocessing/TAARenderPass.js

@@ -12,34 +12,27 @@
  *
  *
  */
  */
 
 
-	var TAARenderPass = function ( scene, camera, clearColor, clearAlpha ) {
+	class TAARenderPass extends THREE.SSAARenderPass {
 
 
-		if ( THREE.SSAARenderPass === undefined ) {
+		constructor( scene, camera, clearColor, clearAlpha ) {
 
 
-			console.error( 'THREE.TAARenderPass relies on THREE.SSAARenderPass' );
+			super( scene, camera, clearColor, clearAlpha );
+			this.sampleLevel = 0;
+			this.accumulate = false;
 
 
 		}
 		}
 
 
-		THREE.SSAARenderPass.call( this, scene, camera, clearColor, clearAlpha );
-		this.sampleLevel = 0;
-		this.accumulate = false;
-
-	};
-
-	TAARenderPass.JitterVectors = THREE.SSAARenderPass.JitterVectors;
-	TAARenderPass.prototype = Object.assign( Object.create( THREE.SSAARenderPass.prototype ), {
-		constructor: TAARenderPass,
-		render: function ( renderer, writeBuffer, readBuffer, deltaTime ) {
+		render( renderer, writeBuffer, readBuffer, deltaTime ) {
 
 
 			if ( ! this.accumulate ) {
 			if ( ! this.accumulate ) {
 
 
-				THREE.SSAARenderPass.prototype.render.call( this, renderer, writeBuffer, readBuffer, deltaTime );
+				super.render( renderer, writeBuffer, readBuffer, deltaTime );
 				this.accumulateIndex = - 1;
 				this.accumulateIndex = - 1;
 				return;
 				return;
 
 
 			}
 			}
 
 
-			var jitterOffsets = TAARenderPass.JitterVectors[ 5 ];
+			const jitterOffsets = _JitterVectors[ 5 ];
 
 
 			if ( ! this.sampleRenderTarget ) {
 			if ( ! this.sampleRenderTarget ) {
 
 
@@ -57,26 +50,26 @@
 
 
 			if ( this.accumulate && this.accumulateIndex === - 1 ) {
 			if ( this.accumulate && this.accumulateIndex === - 1 ) {
 
 
-				THREE.SSAARenderPass.prototype.render.call( this, renderer, this.holdRenderTarget, readBuffer, deltaTime );
+				super.render( renderer, this.holdRenderTarget, readBuffer, deltaTime );
 				this.accumulateIndex = 0;
 				this.accumulateIndex = 0;
 
 
 			}
 			}
 
 
-			var autoClear = renderer.autoClear;
+			const autoClear = renderer.autoClear;
 			renderer.autoClear = false;
 			renderer.autoClear = false;
-			var sampleWeight = 1.0 / jitterOffsets.length;
+			const sampleWeight = 1.0 / jitterOffsets.length;
 
 
 			if ( this.accumulateIndex >= 0 && this.accumulateIndex < jitterOffsets.length ) {
 			if ( this.accumulateIndex >= 0 && this.accumulateIndex < jitterOffsets.length ) {
 
 
 				this.copyUniforms[ 'opacity' ].value = sampleWeight;
 				this.copyUniforms[ 'opacity' ].value = sampleWeight;
 				this.copyUniforms[ 'tDiffuse' ].value = writeBuffer.texture; // render the scene multiple times, each slightly jitter offset from the last and accumulate the results.
 				this.copyUniforms[ 'tDiffuse' ].value = writeBuffer.texture; // render the scene multiple times, each slightly jitter offset from the last and accumulate the results.
 
 
-				var numSamplesPerFrame = Math.pow( 2, this.sampleLevel );
+				const numSamplesPerFrame = Math.pow( 2, this.sampleLevel );
 
 
-				for ( var i = 0; i < numSamplesPerFrame; i ++ ) {
+				for ( let i = 0; i < numSamplesPerFrame; i ++ ) {
 
 
-					var j = this.accumulateIndex;
-					var jitterOffset = jitterOffsets[ j ];
+					const j = this.accumulateIndex;
+					const jitterOffset = jitterOffsets[ j ];
 
 
 					if ( this.camera.setViewOffset ) {
 					if ( this.camera.setViewOffset ) {
 
 
@@ -100,7 +93,7 @@
 
 
 			}
 			}
 
 
-			var accumulationWeight = this.accumulateIndex * sampleWeight;
+			const accumulationWeight = this.accumulateIndex * sampleWeight;
 
 
 			if ( accumulationWeight > 0 ) {
 			if ( accumulationWeight > 0 ) {
 
 
@@ -125,7 +118,10 @@
 			renderer.autoClear = autoClear;
 			renderer.autoClear = autoClear;
 
 
 		}
 		}
-	} );
+
+	}
+
+	const _JitterVectors = [[[ 0, 0 ]], [[ 4, 4 ], [ - 4, - 4 ]], [[ - 2, - 6 ], [ 6, - 2 ], [ - 6, 2 ], [ 2, 6 ]], [[ 1, - 3 ], [ - 1, 3 ], [ 5, 1 ], [ - 3, - 5 ], [ - 5, 5 ], [ - 7, - 1 ], [ 3, 7 ], [ 7, - 7 ]], [[ 1, 1 ], [ - 1, - 3 ], [ - 3, 2 ], [ 4, - 1 ], [ - 5, - 2 ], [ 2, 5 ], [ 5, 3 ], [ 3, - 5 ], [ - 2, 6 ], [ 0, - 7 ], [ - 4, - 6 ], [ - 6, 4 ], [ - 8, 0 ], [ 7, - 4 ], [ 6, 7 ], [ - 7, - 8 ]], [[ - 4, - 7 ], [ - 7, - 5 ], [ - 3, - 5 ], [ - 5, - 4 ], [ - 1, - 4 ], [ - 2, - 2 ], [ - 6, - 1 ], [ - 4, 0 ], [ - 7, 1 ], [ - 1, 2 ], [ - 6, 3 ], [ - 3, 3 ], [ - 7, 6 ], [ - 3, 6 ], [ - 5, 7 ], [ - 1, 7 ], [ 5, - 7 ], [ 1, - 6 ], [ 6, - 5 ], [ 4, - 4 ], [ 2, - 3 ], [ 7, - 2 ], [ 1, - 1 ], [ 4, - 1 ], [ 2, 1 ], [ 6, 2 ], [ 0, 4 ], [ 4, 4 ], [ 2, 5 ], [ 7, 5 ], [ 5, 6 ], [ 3, 7 ]]];
 
 
 	THREE.TAARenderPass = TAARenderPass;
 	THREE.TAARenderPass = TAARenderPass;
 
 

+ 26 - 25
examples/js/postprocessing/TexturePass.js

@@ -1,32 +1,32 @@
 ( function () {
 ( function () {
 
 
-	var TexturePass = function ( map, opacity ) {
-
-		THREE.Pass.call( this );
-		if ( THREE.CopyShader === undefined ) console.error( 'THREE.TexturePass relies on THREE.CopyShader' );
-		var shader = THREE.CopyShader;
-		this.map = map;
-		this.opacity = opacity !== undefined ? opacity : 1.0;
-		this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
-		this.material = new THREE.ShaderMaterial( {
-			uniforms: this.uniforms,
-			vertexShader: shader.vertexShader,
-			fragmentShader: shader.fragmentShader,
-			depthTest: false,
-			depthWrite: false
-		} );
-		this.needsSwap = false;
-		this.fsQuad = new THREE.Pass.FullScreenQuad( null );
-
-	};
-
-	TexturePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
-		constructor: TexturePass,
-		render: function ( renderer, writeBuffer, readBuffer
+	class TexturePass extends THREE.Pass {
+
+		constructor( map, opacity ) {
+
+			super();
+			if ( THREE.CopyShader === undefined ) console.error( 'THREE.TexturePass relies on THREE.CopyShader' );
+			const shader = THREE.CopyShader;
+			this.map = map;
+			this.opacity = opacity !== undefined ? opacity : 1.0;
+			this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
+			this.material = new THREE.ShaderMaterial( {
+				uniforms: this.uniforms,
+				vertexShader: shader.vertexShader,
+				fragmentShader: shader.fragmentShader,
+				depthTest: false,
+				depthWrite: false
+			} );
+			this.needsSwap = false;
+			this.fsQuad = new THREE.FullScreenQuad( null );
+
+		}
+
+		render( renderer, writeBuffer, readBuffer
 			/*, deltaTime, maskActive */
 			/*, deltaTime, maskActive */
 		) {
 		) {
 
 
-			var oldAutoClear = renderer.autoClear;
+			const oldAutoClear = renderer.autoClear;
 			renderer.autoClear = false;
 			renderer.autoClear = false;
 			this.fsQuad.material = this.material;
 			this.fsQuad.material = this.material;
 			this.uniforms[ 'opacity' ].value = this.opacity;
 			this.uniforms[ 'opacity' ].value = this.opacity;
@@ -38,7 +38,8 @@
 			renderer.autoClear = oldAutoClear;
 			renderer.autoClear = oldAutoClear;
 
 
 		}
 		}
-	} );
+
+	}
 
 
 	THREE.TexturePass = TexturePass;
 	THREE.TexturePass = TexturePass;
 
 

+ 191 - 185
examples/js/postprocessing/UnrealBloomPass.js

@@ -10,125 +10,125 @@
  * - https://docs.unrealengine.com/latest/INT/Engine/Rendering/PostProcessEffects/Bloom/
  * - https://docs.unrealengine.com/latest/INT/Engine/Rendering/PostProcessEffects/Bloom/
  */
  */
 
 
-	var UnrealBloomPass = function ( resolution, strength, radius, threshold ) {
-
-		THREE.Pass.call( this );
-		this.strength = strength !== undefined ? strength : 1;
-		this.radius = radius;
-		this.threshold = threshold;
-		this.resolution = resolution !== undefined ? new THREE.Vector2( resolution.x, resolution.y ) : new THREE.Vector2( 256, 256 ); // create color only once here, reuse it later inside the render function
-
-		this.clearColor = new THREE.Color( 0, 0, 0 ); // render targets
-
-		var pars = {
-			minFilter: THREE.LinearFilter,
-			magFilter: THREE.LinearFilter,
-			format: THREE.RGBAFormat
-		};
-		this.renderTargetsHorizontal = [];
-		this.renderTargetsVertical = [];
-		this.nMips = 5;
-		var resx = Math.round( this.resolution.x / 2 );
-		var resy = Math.round( this.resolution.y / 2 );
-		this.renderTargetBright = new THREE.WebGLRenderTarget( resx, resy, pars );
-		this.renderTargetBright.texture.name = 'UnrealBloomPass.bright';
-		this.renderTargetBright.texture.generateMipmaps = false;
-
-		for ( var i = 0; i < this.nMips; i ++ ) {
-
-			var renderTargetHorizonal = new THREE.WebGLRenderTarget( resx, resy, pars );
-			renderTargetHorizonal.texture.name = 'UnrealBloomPass.h' + i;
-			renderTargetHorizonal.texture.generateMipmaps = false;
-			this.renderTargetsHorizontal.push( renderTargetHorizonal );
-			var renderTargetVertical = new THREE.WebGLRenderTarget( resx, resy, pars );
-			renderTargetVertical.texture.name = 'UnrealBloomPass.v' + i;
-			renderTargetVertical.texture.generateMipmaps = false;
-			this.renderTargetsVertical.push( renderTargetVertical );
-			resx = Math.round( resx / 2 );
-			resy = Math.round( resy / 2 );
-
-		} // luminosity high pass material
-
-
-		if ( THREE.LuminosityHighPassShader === undefined ) console.error( 'THREE.UnrealBloomPass relies on THREE.LuminosityHighPassShader' );
-		var highPassShader = THREE.LuminosityHighPassShader;
-		this.highPassUniforms = THREE.UniformsUtils.clone( highPassShader.uniforms );
-		this.highPassUniforms[ 'luminosityThreshold' ].value = threshold;
-		this.highPassUniforms[ 'smoothWidth' ].value = 0.01;
-		this.materialHighPassFilter = new THREE.ShaderMaterial( {
-			uniforms: this.highPassUniforms,
-			vertexShader: highPassShader.vertexShader,
-			fragmentShader: highPassShader.fragmentShader,
-			defines: {}
-		} ); // Gaussian Blur Materials
-
-		this.separableBlurMaterials = [];
-		var kernelSizeArray = [ 3, 5, 7, 9, 11 ];
-		var resx = Math.round( this.resolution.x / 2 );
-		var resy = Math.round( this.resolution.y / 2 );
-
-		for ( var i = 0; i < this.nMips; i ++ ) {
-
-			this.separableBlurMaterials.push( this.getSeperableBlurMaterial( kernelSizeArray[ i ] ) );
-			this.separableBlurMaterials[ i ].uniforms[ 'texSize' ].value = new THREE.Vector2( resx, resy );
-			resx = Math.round( resx / 2 );
-			resy = Math.round( resy / 2 );
-
-		} // Composite material
-
-
-		this.compositeMaterial = this.getCompositeMaterial( this.nMips );
-		this.compositeMaterial.uniforms[ 'blurTexture1' ].value = this.renderTargetsVertical[ 0 ].texture;
-		this.compositeMaterial.uniforms[ 'blurTexture2' ].value = this.renderTargetsVertical[ 1 ].texture;
-		this.compositeMaterial.uniforms[ 'blurTexture3' ].value = this.renderTargetsVertical[ 2 ].texture;
-		this.compositeMaterial.uniforms[ 'blurTexture4' ].value = this.renderTargetsVertical[ 3 ].texture;
-		this.compositeMaterial.uniforms[ 'blurTexture5' ].value = this.renderTargetsVertical[ 4 ].texture;
-		this.compositeMaterial.uniforms[ 'bloomStrength' ].value = strength;
-		this.compositeMaterial.uniforms[ 'bloomRadius' ].value = 0.1;
-		this.compositeMaterial.needsUpdate = true;
-		var bloomFactors = [ 1.0, 0.8, 0.6, 0.4, 0.2 ];
-		this.compositeMaterial.uniforms[ 'bloomFactors' ].value = bloomFactors;
-		this.bloomTintColors = [ new THREE.Vector3( 1, 1, 1 ), new THREE.Vector3( 1, 1, 1 ), new THREE.Vector3( 1, 1, 1 ), new THREE.Vector3( 1, 1, 1 ), new THREE.Vector3( 1, 1, 1 ) ];
-		this.compositeMaterial.uniforms[ 'bloomTintColors' ].value = this.bloomTintColors; // copy material
-
-		if ( THREE.CopyShader === undefined ) {
-
-			console.error( 'THREE.UnrealBloomPass relies on THREE.CopyShader' );
+	class UnrealBloomPass extends THREE.Pass {
+
+		constructor( resolution, strength, radius, threshold ) {
+
+			super();
+			this.strength = strength !== undefined ? strength : 1;
+			this.radius = radius;
+			this.threshold = threshold;
+			this.resolution = resolution !== undefined ? new THREE.Vector2( resolution.x, resolution.y ) : new THREE.Vector2( 256, 256 ); // create color only once here, reuse it later inside the render function
+
+			this.clearColor = new THREE.Color( 0, 0, 0 ); // render targets
+
+			const pars = {
+				minFilter: THREE.LinearFilter,
+				magFilter: THREE.LinearFilter,
+				format: THREE.RGBAFormat
+			};
+			this.renderTargetsHorizontal = [];
+			this.renderTargetsVertical = [];
+			this.nMips = 5;
+			let resx = Math.round( this.resolution.x / 2 );
+			let resy = Math.round( this.resolution.y / 2 );
+			this.renderTargetBright = new THREE.WebGLRenderTarget( resx, resy, pars );
+			this.renderTargetBright.texture.name = 'UnrealBloomPass.bright';
+			this.renderTargetBright.texture.generateMipmaps = false;
+
+			for ( let i = 0; i < this.nMips; i ++ ) {
+
+				const renderTargetHorizonal = new THREE.WebGLRenderTarget( resx, resy, pars );
+				renderTargetHorizonal.texture.name = 'UnrealBloomPass.h' + i;
+				renderTargetHorizonal.texture.generateMipmaps = false;
+				this.renderTargetsHorizontal.push( renderTargetHorizonal );
+				const renderTargetVertical = new THREE.WebGLRenderTarget( resx, resy, pars );
+				renderTargetVertical.texture.name = 'UnrealBloomPass.v' + i;
+				renderTargetVertical.texture.generateMipmaps = false;
+				this.renderTargetsVertical.push( renderTargetVertical );
+				resx = Math.round( resx / 2 );
+				resy = Math.round( resy / 2 );
+
+			} // luminosity high pass material
+
+
+			if ( THREE.LuminosityHighPassShader === undefined ) console.error( 'THREE.UnrealBloomPass relies on THREE.LuminosityHighPassShader' );
+			const highPassShader = THREE.LuminosityHighPassShader;
+			this.highPassUniforms = THREE.UniformsUtils.clone( highPassShader.uniforms );
+			this.highPassUniforms[ 'luminosityThreshold' ].value = threshold;
+			this.highPassUniforms[ 'smoothWidth' ].value = 0.01;
+			this.materialHighPassFilter = new THREE.ShaderMaterial( {
+				uniforms: this.highPassUniforms,
+				vertexShader: highPassShader.vertexShader,
+				fragmentShader: highPassShader.fragmentShader,
+				defines: {}
+			} ); // Gaussian Blur Materials
+
+			this.separableBlurMaterials = [];
+			const kernelSizeArray = [ 3, 5, 7, 9, 11 ];
+			resx = Math.round( this.resolution.x / 2 );
+			resy = Math.round( this.resolution.y / 2 );
+
+			for ( let i = 0; i < this.nMips; i ++ ) {
+
+				this.separableBlurMaterials.push( this.getSeperableBlurMaterial( kernelSizeArray[ i ] ) );
+				this.separableBlurMaterials[ i ].uniforms[ 'texSize' ].value = new THREE.Vector2( resx, resy );
+				resx = Math.round( resx / 2 );
+				resy = Math.round( resy / 2 );
+
+			} // Composite material
+
+
+			this.compositeMaterial = this.getCompositeMaterial( this.nMips );
+			this.compositeMaterial.uniforms[ 'blurTexture1' ].value = this.renderTargetsVertical[ 0 ].texture;
+			this.compositeMaterial.uniforms[ 'blurTexture2' ].value = this.renderTargetsVertical[ 1 ].texture;
+			this.compositeMaterial.uniforms[ 'blurTexture3' ].value = this.renderTargetsVertical[ 2 ].texture;
+			this.compositeMaterial.uniforms[ 'blurTexture4' ].value = this.renderTargetsVertical[ 3 ].texture;
+			this.compositeMaterial.uniforms[ 'blurTexture5' ].value = this.renderTargetsVertical[ 4 ].texture;
+			this.compositeMaterial.uniforms[ 'bloomStrength' ].value = strength;
+			this.compositeMaterial.uniforms[ 'bloomRadius' ].value = 0.1;
+			this.compositeMaterial.needsUpdate = true;
+			const bloomFactors = [ 1.0, 0.8, 0.6, 0.4, 0.2 ];
+			this.compositeMaterial.uniforms[ 'bloomFactors' ].value = bloomFactors;
+			this.bloomTintColors = [ new THREE.Vector3( 1, 1, 1 ), new THREE.Vector3( 1, 1, 1 ), new THREE.Vector3( 1, 1, 1 ), new THREE.Vector3( 1, 1, 1 ), new THREE.Vector3( 1, 1, 1 ) ];
+			this.compositeMaterial.uniforms[ 'bloomTintColors' ].value = this.bloomTintColors; // copy material
+
+			if ( THREE.CopyShader === undefined ) {
+
+				console.error( 'THREE.UnrealBloomPass relies on THREE.CopyShader' );
+
+			}
+
+			const copyShader = THREE.CopyShader;
+			this.copyUniforms = THREE.UniformsUtils.clone( copyShader.uniforms );
+			this.copyUniforms[ 'opacity' ].value = 1.0;
+			this.materialCopy = new THREE.ShaderMaterial( {
+				uniforms: this.copyUniforms,
+				vertexShader: copyShader.vertexShader,
+				fragmentShader: copyShader.fragmentShader,
+				blending: THREE.AdditiveBlending,
+				depthTest: false,
+				depthWrite: false,
+				transparent: true
+			} );
+			this.enabled = true;
+			this.needsSwap = false;
+			this._oldClearColor = new THREE.Color();
+			this.oldClearAlpha = 1;
+			this.basic = new THREE.MeshBasicMaterial();
+			this.fsQuad = new THREE.FullScreenQuad( null );
 
 
 		}
 		}
 
 
-		var copyShader = THREE.CopyShader;
-		this.copyUniforms = THREE.UniformsUtils.clone( copyShader.uniforms );
-		this.copyUniforms[ 'opacity' ].value = 1.0;
-		this.materialCopy = new THREE.ShaderMaterial( {
-			uniforms: this.copyUniforms,
-			vertexShader: copyShader.vertexShader,
-			fragmentShader: copyShader.fragmentShader,
-			blending: THREE.AdditiveBlending,
-			depthTest: false,
-			depthWrite: false,
-			transparent: true
-		} );
-		this.enabled = true;
-		this.needsSwap = false;
-		this._oldClearColor = new THREE.Color();
-		this.oldClearAlpha = 1;
-		this.basic = new THREE.MeshBasicMaterial();
-		this.fsQuad = new THREE.Pass.FullScreenQuad( null );
-
-	};
-
-	UnrealBloomPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
-		constructor: UnrealBloomPass,
-		dispose: function () {
-
-			for ( var i = 0; i < this.renderTargetsHorizontal.length; i ++ ) {
+		dispose() {
+
+			for ( let i = 0; i < this.renderTargetsHorizontal.length; i ++ ) {
 
 
 				this.renderTargetsHorizontal[ i ].dispose();
 				this.renderTargetsHorizontal[ i ].dispose();
 
 
 			}
 			}
 
 
-			for ( var i = 0; i < this.renderTargetsVertical.length; i ++ ) {
+			for ( let i = 0; i < this.renderTargetsVertical.length; i ++ ) {
 
 
 				this.renderTargetsVertical[ i ].dispose();
 				this.renderTargetsVertical[ i ].dispose();
 
 
@@ -136,14 +136,15 @@
 
 
 			this.renderTargetBright.dispose();
 			this.renderTargetBright.dispose();
 
 
-		},
-		setSize: function ( width, height ) {
+		}
+
+		setSize( width, height ) {
 
 
-			var resx = Math.round( width / 2 );
-			var resy = Math.round( height / 2 );
+			let resx = Math.round( width / 2 );
+			let resy = Math.round( height / 2 );
 			this.renderTargetBright.setSize( resx, resy );
 			this.renderTargetBright.setSize( resx, resy );
 
 
-			for ( var i = 0; i < this.nMips; i ++ ) {
+			for ( let i = 0; i < this.nMips; i ++ ) {
 
 
 				this.renderTargetsHorizontal[ i ].setSize( resx, resy );
 				this.renderTargetsHorizontal[ i ].setSize( resx, resy );
 				this.renderTargetsVertical[ i ].setSize( resx, resy );
 				this.renderTargetsVertical[ i ].setSize( resx, resy );
@@ -153,12 +154,13 @@
 
 
 			}
 			}
 
 
-		},
-		render: function ( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {
+		}
+
+		render( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {
 
 
 			renderer.getClearColor( this._oldClearColor );
 			renderer.getClearColor( this._oldClearColor );
 			this.oldClearAlpha = renderer.getClearAlpha();
 			this.oldClearAlpha = renderer.getClearAlpha();
-			var oldAutoClear = renderer.autoClear;
+			const oldAutoClear = renderer.autoClear;
 			renderer.autoClear = false;
 			renderer.autoClear = false;
 			renderer.setClearColor( this.clearColor, 0 );
 			renderer.setClearColor( this.clearColor, 0 );
 			if ( maskActive ) renderer.state.buffers.stencil.setTest( false ); // Render input to screen
 			if ( maskActive ) renderer.state.buffers.stencil.setTest( false ); // Render input to screen
@@ -181,9 +183,9 @@
 			renderer.clear();
 			renderer.clear();
 			this.fsQuad.render( renderer ); // 2. Blur All the mips progressively
 			this.fsQuad.render( renderer ); // 2. Blur All the mips progressively
 
 
-			var inputRenderTarget = this.renderTargetBright;
+			let inputRenderTarget = this.renderTargetBright;
 
 
-			for ( var i = 0; i < this.nMips; i ++ ) {
+			for ( let i = 0; i < this.nMips; i ++ ) {
 
 
 				this.fsQuad.material = this.separableBlurMaterials[ i ];
 				this.fsQuad.material = this.separableBlurMaterials[ i ];
 				this.separableBlurMaterials[ i ].uniforms[ 'colorTexture' ].value = inputRenderTarget.texture;
 				this.separableBlurMaterials[ i ].uniforms[ 'colorTexture' ].value = inputRenderTarget.texture;
@@ -229,8 +231,9 @@
 			renderer.setClearColor( this._oldClearColor, this.oldClearAlpha );
 			renderer.setClearColor( this._oldClearColor, this.oldClearAlpha );
 			renderer.autoClear = oldAutoClear;
 			renderer.autoClear = oldAutoClear;
 
 
-		},
-		getSeperableBlurMaterial: function ( kernelRadius ) {
+		}
+
+		getSeperableBlurMaterial( kernelRadius ) {
 
 
 			return new THREE.ShaderMaterial( {
 			return new THREE.ShaderMaterial( {
 				defines: {
 				defines: {
@@ -248,40 +251,41 @@
 						value: new THREE.Vector2( 0.5, 0.5 )
 						value: new THREE.Vector2( 0.5, 0.5 )
 					}
 					}
 				},
 				},
-				vertexShader: 'varying vec2 vUv;\n\
-				void main() {\n\
-					vUv = uv;\n\
-					gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\
-				}',
-				fragmentShader: '#include <common>\
-				varying vec2 vUv;\n\
-				uniform sampler2D colorTexture;\n\
-				uniform vec2 texSize;\
-				uniform vec2 direction;\
-				\
-				float gaussianPdf(in float x, in float sigma) {\
-					return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\
-				}\
-				void main() {\n\
-					vec2 invSize = 1.0 / texSize;\
-					float fSigma = float(SIGMA);\
-					float weightSum = gaussianPdf(0.0, fSigma);\
-					vec3 diffuseSum = texture2D( colorTexture, vUv).rgb * weightSum;\
-					for( int i = 1; i < KERNEL_RADIUS; i ++ ) {\
-						float x = float(i);\
-						float w = gaussianPdf(x, fSigma);\
-						vec2 uvOffset = direction * invSize * x;\
-						vec3 sample1 = texture2D( colorTexture, vUv + uvOffset).rgb;\
-						vec3 sample2 = texture2D( colorTexture, vUv - uvOffset).rgb;\
-						diffuseSum += (sample1 + sample2) * w;\
-						weightSum += 2.0 * w;\
-					}\
-					gl_FragColor = vec4(diffuseSum/weightSum, 1.0);\n\
-				}'
+				vertexShader: `varying vec2 vUv;
+				void main() {
+					vUv = uv;
+					gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+				}`,
+				fragmentShader: `#include <common>
+				varying vec2 vUv;
+				uniform sampler2D colorTexture;
+				uniform vec2 texSize;
+				uniform vec2 direction;
+
+				float gaussianPdf(in float x, in float sigma) {
+					return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;
+				}
+				void main() {
+					vec2 invSize = 1.0 / texSize;
+					float fSigma = float(SIGMA);
+					float weightSum = gaussianPdf(0.0, fSigma);
+					vec3 diffuseSum = texture2D( colorTexture, vUv).rgb * weightSum;
+					for( int i = 1; i < KERNEL_RADIUS; i ++ ) {
+						float x = float(i);
+						float w = gaussianPdf(x, fSigma);
+						vec2 uvOffset = direction * invSize * x;
+						vec3 sample1 = texture2D( colorTexture, vUv + uvOffset).rgb;
+						vec3 sample2 = texture2D( colorTexture, vUv - uvOffset).rgb;
+						diffuseSum += (sample1 + sample2) * w;
+						weightSum += 2.0 * w;
+					}
+					gl_FragColor = vec4(diffuseSum/weightSum, 1.0);
+				}`
 			} );
 			} );
 
 
-		},
-		getCompositeMaterial: function ( nMips ) {
+		}
+
+		getCompositeMaterial( nMips ) {
 
 
 			return new THREE.ShaderMaterial( {
 			return new THREE.ShaderMaterial( {
 				defines: {
 				defines: {
@@ -319,39 +323,41 @@
 						value: 0.0
 						value: 0.0
 					}
 					}
 				},
 				},
-				vertexShader: 'varying vec2 vUv;\n\
-				void main() {\n\
-					vUv = uv;\n\
-					gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\
-				}',
-				fragmentShader: 'varying vec2 vUv;\
-				uniform sampler2D blurTexture1;\
-				uniform sampler2D blurTexture2;\
-				uniform sampler2D blurTexture3;\
-				uniform sampler2D blurTexture4;\
-				uniform sampler2D blurTexture5;\
-				uniform sampler2D dirtTexture;\
-				uniform float bloomStrength;\
-				uniform float bloomRadius;\
-				uniform float bloomFactors[NUM_MIPS];\
-				uniform vec3 bloomTintColors[NUM_MIPS];\
-				\
-				float lerpBloomFactor(const in float factor) { \
-					float mirrorFactor = 1.2 - factor;\
-					return mix(factor, mirrorFactor, bloomRadius);\
-				}\
-				\
-				void main() {\
-					gl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) + \
-													 lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) + \
-													 lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) + \
-													 lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) + \
-													 lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );\
-				}'
+				vertexShader: `varying vec2 vUv;
+				void main() {
+					vUv = uv;
+					gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+				}`,
+				fragmentShader: `varying vec2 vUv;
+				uniform sampler2D blurTexture1;
+				uniform sampler2D blurTexture2;
+				uniform sampler2D blurTexture3;
+				uniform sampler2D blurTexture4;
+				uniform sampler2D blurTexture5;
+				uniform sampler2D dirtTexture;
+				uniform float bloomStrength;
+				uniform float bloomRadius;
+				uniform float bloomFactors[NUM_MIPS];
+				uniform vec3 bloomTintColors[NUM_MIPS];
+
+				float lerpBloomFactor(const in float factor) {
+					float mirrorFactor = 1.2 - factor;
+					return mix(factor, mirrorFactor, bloomRadius);
+				}
+
+				void main() {
+					gl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +
+						lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +
+						lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +
+						lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +
+						lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );
+				}`
 			} );
 			} );
 
 
 		}
 		}
-	} );
+
+	}
+
 	UnrealBloomPass.BlurDirectionX = new THREE.Vector2( 1.0, 0.0 );
 	UnrealBloomPass.BlurDirectionX = new THREE.Vector2( 1.0, 0.0 );
 	UnrealBloomPass.BlurDirectionY = new THREE.Vector2( 0.0, 1.0 );
 	UnrealBloomPass.BlurDirectionY = new THREE.Vector2( 0.0, 1.0 );
 
 

+ 17 - 17
examples/jsm/WebGL.js

@@ -1,10 +1,10 @@
-var WEBGL = {
+class WEBGL {
 
 
-	isWebGLAvailable: function () {
+	static isWebGLAvailable() {
 
 
 		try {
 		try {
 
 
-			var canvas = document.createElement( 'canvas' );
+			const canvas = document.createElement( 'canvas' );
 			return !! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) );
 			return !! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) );
 
 
 		} catch ( e ) {
 		} catch ( e ) {
@@ -13,13 +13,13 @@ var WEBGL = {
 
 
 		}
 		}
 
 
-	},
+	}
 
 
-	isWebGL2Available: function () {
+	static isWebGL2Available() {
 
 
 		try {
 		try {
 
 
-			var canvas = document.createElement( 'canvas' );
+			const canvas = document.createElement( 'canvas' );
 			return !! ( window.WebGL2RenderingContext && canvas.getContext( 'webgl2' ) );
 			return !! ( window.WebGL2RenderingContext && canvas.getContext( 'webgl2' ) );
 
 
 		} catch ( e ) {
 		} catch ( e ) {
@@ -28,35 +28,35 @@ var WEBGL = {
 
 
 		}
 		}
 
 
-	},
+	}
 
 
-	getWebGLErrorMessage: function () {
+	static getWebGLErrorMessage() {
 
 
 		return this.getErrorMessage( 1 );
 		return this.getErrorMessage( 1 );
 
 
-	},
+	}
 
 
-	getWebGL2ErrorMessage: function () {
+	static getWebGL2ErrorMessage() {
 
 
 		return this.getErrorMessage( 2 );
 		return this.getErrorMessage( 2 );
 
 
-	},
+	}
 
 
-	getErrorMessage: function ( version ) {
+	static getErrorMessage( version ) {
 
 
-		var names = {
+		const names = {
 			1: 'WebGL',
 			1: 'WebGL',
 			2: 'WebGL 2'
 			2: 'WebGL 2'
 		};
 		};
 
 
-		var contexts = {
+		const contexts = {
 			1: window.WebGLRenderingContext,
 			1: window.WebGLRenderingContext,
 			2: window.WebGL2RenderingContext
 			2: window.WebGL2RenderingContext
 		};
 		};
 
 
-		var message = 'Your $0 does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">$1</a>';
+		let message = 'Your $0 does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">$1</a>';
 
 
-		var element = document.createElement( 'div' );
+		const element = document.createElement( 'div' );
 		element.id = 'webglmessage';
 		element.id = 'webglmessage';
 		element.style.fontFamily = 'monospace';
 		element.style.fontFamily = 'monospace';
 		element.style.fontSize = '13px';
 		element.style.fontSize = '13px';
@@ -86,6 +86,6 @@ var WEBGL = {
 
 
 	}
 	}
 
 
-};
+}
 
 
 export { WEBGL };
 export { WEBGL };

+ 46 - 45
examples/jsm/nodes/postprocessing/NodePass.js

@@ -4,89 +4,90 @@ import { ShaderPass } from '../../postprocessing/ShaderPass.js';
 import { NodeMaterial } from '../materials/NodeMaterial.js';
 import { NodeMaterial } from '../materials/NodeMaterial.js';
 import { ScreenNode } from '../inputs/ScreenNode.js';
 import { ScreenNode } from '../inputs/ScreenNode.js';
 
 
-function NodePass() {
+class NodePass extends ShaderPass {
 
 
-	ShaderPass.call( this );
+	constructor() {
 
 
-	this.name = '';
-	this.uuid = MathUtils.generateUUID();
+		super();
 
 
-	this.userData = {};
+		this.name = '';
+		this.uuid = MathUtils.generateUUID();
 
 
-	this.textureID = 'renderTexture';
+		this.userData = {};
 
 
-	this.input = new ScreenNode();
+		this.textureID = 'renderTexture';
 
 
-	this.material = new NodeMaterial();
+		this.input = new ScreenNode();
 
 
-	this.needsUpdate = true;
+		this.material = new NodeMaterial();
 
 
-}
+		this.needsUpdate = true;
 
 
-NodePass.prototype = Object.create( ShaderPass.prototype );
-NodePass.prototype.constructor = NodePass;
+	}
 
 
-NodePass.prototype.render = function () {
+	render() {
 
 
-	if ( this.needsUpdate ) {
+		if ( this.needsUpdate ) {
 
 
-		this.material.dispose();
+			this.material.dispose();
 
 
-		this.material.fragment.value = this.input;
+			this.material.fragment.value = this.input;
 
 
-		this.needsUpdate = false;
+			this.needsUpdate = false;
 
 
-	}
+		}
 
 
-	this.uniforms = this.material.uniforms;
+		this.uniforms = this.material.uniforms;
 
 
-	ShaderPass.prototype.render.apply( this, arguments );
+		super.render( ...arguments );
+
+	}
 
 
-};
+	copy( source ) {
 
 
-NodePass.prototype.copy = function ( source ) {
+		this.input = source.input;
 
 
-	this.input = source.input;
+		return this;
 
 
-	return this;
+	}
 
 
-};
+	toJSON( meta ) {
 
 
-NodePass.prototype.toJSON = function ( meta ) {
+		var isRootObject = ( meta === undefined || typeof meta === 'string' );
 
 
-	var isRootObject = ( meta === undefined || typeof meta === 'string' );
+		if ( isRootObject ) {
 
 
-	if ( isRootObject ) {
+			meta = {
+				nodes: {}
+			};
 
 
-		meta = {
-			nodes: {}
-		};
+		}
 
 
-	}
+		if ( meta && ! meta.passes ) meta.passes = {};
 
 
-	if ( meta && ! meta.passes ) meta.passes = {};
+		if ( ! meta.passes[ this.uuid ] ) {
 
 
-	if ( ! meta.passes[ this.uuid ] ) {
+			var data = {};
 
 
-		var data = {};
+			data.uuid = this.uuid;
+			data.type = 'NodePass';
 
 
-		data.uuid = this.uuid;
-		data.type = 'NodePass';
+			meta.passes[ this.uuid ] = data;
 
 
-		meta.passes[ this.uuid ] = data;
+			if ( this.name !== '' ) data.name = this.name;
 
 
-		if ( this.name !== '' ) data.name = this.name;
+			if ( JSON.stringify( this.userData ) !== '{}' ) data.userData = this.userData;
 
 
-		if ( JSON.stringify( this.userData ) !== '{}' ) data.userData = this.userData;
+			data.input = this.input.toJSON( meta ).uuid;
 
 
-		data.input = this.input.toJSON( meta ).uuid;
+		}
 
 
-	}
+		meta.pass = this.uuid;
 
 
-	meta.pass = this.uuid;
+		return meta;
 
 
-	return meta;
+	}
 
 
-};
+}
 
 
 export { NodePass };
 export { NodePass };

+ 103 - 106
examples/jsm/postprocessing/AdaptiveToneMappingPass.js

@@ -8,7 +8,7 @@ import {
 	UniformsUtils,
 	UniformsUtils,
 	WebGLRenderTarget
 	WebGLRenderTarget
 } from '../../../build/three.module.js';
 } from '../../../build/three.module.js';
-import { Pass } from '../postprocessing/Pass.js';
+import { Pass, FullScreenQuad } from '../postprocessing/Pass.js';
 import { CopyShader } from '../shaders/CopyShader.js';
 import { CopyShader } from '../shaders/CopyShader.js';
 import { LuminosityShader } from '../shaders/LuminosityShader.js';
 import { LuminosityShader } from '../shaders/LuminosityShader.js';
 import { ToneMapShader } from '../shaders/ToneMapShader.js';
 import { ToneMapShader } from '../shaders/ToneMapShader.js';
@@ -21,125 +21,122 @@ import { ToneMapShader } from '../shaders/ToneMapShader.js';
  * Full-screen tone-mapping shader based on http://www.graphics.cornell.edu/~jaf/publications/sig02_paper.pdf
  * Full-screen tone-mapping shader based on http://www.graphics.cornell.edu/~jaf/publications/sig02_paper.pdf
  */
  */
 
 
-var AdaptiveToneMappingPass = function ( adaptive, resolution ) {
+class AdaptiveToneMappingPass extends Pass {
 
 
-	Pass.call( this );
+	constructor( adaptive, resolution ) {
 
 
-	this.resolution = ( resolution !== undefined ) ? resolution : 256;
-	this.needsInit = true;
-	this.adaptive = adaptive !== undefined ? !! adaptive : true;
+		super();
 
 
-	this.luminanceRT = null;
-	this.previousLuminanceRT = null;
-	this.currentLuminanceRT = null;
+		this.resolution = ( resolution !== undefined ) ? resolution : 256;
+		this.needsInit = true;
+		this.adaptive = adaptive !== undefined ? !! adaptive : true;
 
 
-	if ( CopyShader === undefined )
-		console.error( 'THREE.AdaptiveToneMappingPass relies on CopyShader' );
+		this.luminanceRT = null;
+		this.previousLuminanceRT = null;
+		this.currentLuminanceRT = null;
 
 
-	var copyShader = CopyShader;
+		if ( CopyShader === undefined ) console.error( 'THREE.AdaptiveToneMappingPass relies on CopyShader' );
 
 
-	this.copyUniforms = UniformsUtils.clone( copyShader.uniforms );
+		const copyShader = CopyShader;
 
 
-	this.materialCopy = new ShaderMaterial( {
+		this.copyUniforms = UniformsUtils.clone( copyShader.uniforms );
 
 
-		uniforms: this.copyUniforms,
-		vertexShader: copyShader.vertexShader,
-		fragmentShader: copyShader.fragmentShader,
-		blending: NoBlending,
-		depthTest: false
+		this.materialCopy = new ShaderMaterial( {
 
 
-	} );
+			uniforms: this.copyUniforms,
+			vertexShader: copyShader.vertexShader,
+			fragmentShader: copyShader.fragmentShader,
+			blending: NoBlending,
+			depthTest: false
 
 
-	if ( LuminosityShader === undefined )
-		console.error( 'THREE.AdaptiveToneMappingPass relies on LuminosityShader' );
+		} );
 
 
-	this.materialLuminance = new ShaderMaterial( {
+		if ( LuminosityShader === undefined )
+			console.error( 'THREE.AdaptiveToneMappingPass relies on LuminosityShader' );
 
 
-		uniforms: UniformsUtils.clone( LuminosityShader.uniforms ),
-		vertexShader: LuminosityShader.vertexShader,
-		fragmentShader: LuminosityShader.fragmentShader,
-		blending: NoBlending
-	} );
+		this.materialLuminance = new ShaderMaterial( {
 
 
-	this.adaptLuminanceShader = {
-		defines: {
-			'MIP_LEVEL_1X1': ( Math.log( this.resolution ) / Math.log( 2.0 ) ).toFixed( 1 )
-		},
-		uniforms: {
-			'lastLum': { value: null },
-			'currentLum': { value: null },
-			'minLuminance': { value: 0.01 },
-			'delta': { value: 0.016 },
-			'tau': { value: 1.0 }
-		},
-		vertexShader: [
-			'varying vec2 vUv;',
+			uniforms: UniformsUtils.clone( LuminosityShader.uniforms ),
+			vertexShader: LuminosityShader.vertexShader,
+			fragmentShader: LuminosityShader.fragmentShader,
+			blending: NoBlending
+		} );
 
 
-			'void main() {',
+		this.adaptLuminanceShader = {
+			defines: {
+				'MIP_LEVEL_1X1': ( Math.log( this.resolution ) / Math.log( 2.0 ) ).toFixed( 1 )
+			},
+			uniforms: {
+				'lastLum': { value: null },
+				'currentLum': { value: null },
+				'minLuminance': { value: 0.01 },
+				'delta': { value: 0.016 },
+				'tau': { value: 1.0 }
+			},
+			vertexShader:
+				`varying vec2 vUv;
 
 
-			'	vUv = uv;',
-			'	gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );',
+				void main() {
 
 
-			'}'
-		].join( '\n' ),
-		fragmentShader: [
-			'varying vec2 vUv;',
+					vUv = uv;
+					gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
 
 
-			'uniform sampler2D lastLum;',
-			'uniform sampler2D currentLum;',
-			'uniform float minLuminance;',
-			'uniform float delta;',
-			'uniform float tau;',
+				}`,
 
 
-			'void main() {',
+			fragmentShader:
+				`varying vec2 vUv;
 
 
-			'	vec4 lastLum = texture2D( lastLum, vUv, MIP_LEVEL_1X1 );',
-			'	vec4 currentLum = texture2D( currentLum, vUv, MIP_LEVEL_1X1 );',
+				uniform sampler2D lastLum;
+				uniform sampler2D currentLum;
+				uniform float minLuminance;
+				uniform float delta;
+				uniform float tau;
 
 
-			'	float fLastLum = max( minLuminance, lastLum.r );',
-			'	float fCurrentLum = max( minLuminance, currentLum.r );',
+				void main() {
 
 
-			//The adaption seems to work better in extreme lighting differences
-			//if the input luminance is squared.
-			'	fCurrentLum *= fCurrentLum;',
+					vec4 lastLum = texture2D( lastLum, vUv, MIP_LEVEL_1X1 );
+					vec4 currentLum = texture2D( currentLum, vUv, MIP_LEVEL_1X1 );
 
 
-			// Adapt the luminance using Pattanaik's technique
-			'	float fAdaptedLum = fLastLum + (fCurrentLum - fLastLum) * (1.0 - exp(-delta * tau));',
-			// "fAdaptedLum = sqrt(fAdaptedLum);",
-			'	gl_FragColor.r = fAdaptedLum;',
-			'}'
-		].join( '\n' )
-	};
+					float fLastLum = max( minLuminance, lastLum.r );
+					float fCurrentLum = max( minLuminance, currentLum.r );
 
 
-	this.materialAdaptiveLum = new ShaderMaterial( {
+					//The adaption seems to work better in extreme lighting differences
+					//if the input luminance is squared.
+					fCurrentLum *= fCurrentLum;
 
 
-		uniforms: UniformsUtils.clone( this.adaptLuminanceShader.uniforms ),
-		vertexShader: this.adaptLuminanceShader.vertexShader,
-		fragmentShader: this.adaptLuminanceShader.fragmentShader,
-		defines: Object.assign( {}, this.adaptLuminanceShader.defines ),
-		blending: NoBlending
-	} );
+					// Adapt the luminance using Pattanaik's technique
+					float fAdaptedLum = fLastLum + (fCurrentLum - fLastLum) * (1.0 - exp(-delta * tau));
+					// "fAdaptedLum = sqrt(fAdaptedLum);
+					gl_FragColor.r = fAdaptedLum;
+				}`
 
 
-	if ( ToneMapShader === undefined )
-		console.error( 'THREE.AdaptiveToneMappingPass relies on ToneMapShader' );
+		};
 
 
-	this.materialToneMap = new ShaderMaterial( {
+		this.materialAdaptiveLum = new ShaderMaterial( {
 
 
-		uniforms: UniformsUtils.clone( ToneMapShader.uniforms ),
-		vertexShader: ToneMapShader.vertexShader,
-		fragmentShader: ToneMapShader.fragmentShader,
-		blending: NoBlending
-	} );
+			uniforms: UniformsUtils.clone( this.adaptLuminanceShader.uniforms ),
+			vertexShader: this.adaptLuminanceShader.vertexShader,
+			fragmentShader: this.adaptLuminanceShader.fragmentShader,
+			defines: Object.assign( {}, this.adaptLuminanceShader.defines ),
+			blending: NoBlending
+		} );
 
 
-	this.fsQuad = new Pass.FullScreenQuad( null );
+		if ( ToneMapShader === undefined )
+			console.error( 'THREE.AdaptiveToneMappingPass relies on ToneMapShader' );
 
 
-};
+		this.materialToneMap = new ShaderMaterial( {
 
 
-AdaptiveToneMappingPass.prototype = Object.assign( Object.create( Pass.prototype ), {
+			uniforms: UniformsUtils.clone( ToneMapShader.uniforms ),
+			vertexShader: ToneMapShader.vertexShader,
+			fragmentShader: ToneMapShader.fragmentShader,
+			blending: NoBlending
+		} );
 
 
-	constructor: AdaptiveToneMappingPass,
+		this.fsQuad = new FullScreenQuad( null );
 
 
-	render: function ( renderer, writeBuffer, readBuffer, deltaTime/*, maskActive*/ ) {
+	}
+
+	render( renderer, writeBuffer, readBuffer, deltaTime/*, maskActive*/ ) {
 
 
 		if ( this.needsInit ) {
 		if ( this.needsInit ) {
 
 
@@ -195,9 +192,9 @@ AdaptiveToneMappingPass.prototype = Object.assign( Object.create( Pass.prototype
 
 
 		}
 		}
 
 
-	},
+	}
 
 
-	reset: function () {
+	reset() {
 
 
 		// render targets
 		// render targets
 		if ( this.luminanceRT ) {
 		if ( this.luminanceRT ) {
@@ -218,7 +215,7 @@ AdaptiveToneMappingPass.prototype = Object.assign( Object.create( Pass.prototype
 
 
 		}
 		}
 
 
-		var pars = { minFilter: LinearFilter, magFilter: LinearFilter, format: RGBAFormat }; // was RGB format. changed to RGBA format. see discussion in #8415 / #8450
+		const pars = { minFilter: LinearFilter, magFilter: LinearFilter, format: RGBAFormat }; // was RGB format. changed to RGBA format. see discussion in #8415 / #8450
 
 
 		this.luminanceRT = new WebGLRenderTarget( this.resolution, this.resolution, pars );
 		this.luminanceRT = new WebGLRenderTarget( this.resolution, this.resolution, pars );
 		this.luminanceRT.texture.name = 'AdaptiveToneMappingPass.l';
 		this.luminanceRT.texture.name = 'AdaptiveToneMappingPass.l';
@@ -250,9 +247,9 @@ AdaptiveToneMappingPass.prototype = Object.assign( Object.create( Pass.prototype
 		// renderer.render( this.scene, this.camera, this.previousLuminanceRT );
 		// renderer.render( this.scene, this.camera, this.previousLuminanceRT );
 		// renderer.render( this.scene, this.camera, this.currentLuminanceRT );
 		// renderer.render( this.scene, this.camera, this.currentLuminanceRT );
 
 
-	},
+	}
 
 
-	setAdaptive: function ( adaptive ) {
+	setAdaptive( adaptive ) {
 
 
 		if ( adaptive ) {
 		if ( adaptive ) {
 
 
@@ -270,9 +267,9 @@ AdaptiveToneMappingPass.prototype = Object.assign( Object.create( Pass.prototype
 
 
 		this.materialToneMap.needsUpdate = true;
 		this.materialToneMap.needsUpdate = true;
 
 
-	},
+	}
 
 
-	setAdaptionRate: function ( rate ) {
+	setAdaptionRate( rate ) {
 
 
 		if ( rate ) {
 		if ( rate ) {
 
 
@@ -280,9 +277,9 @@ AdaptiveToneMappingPass.prototype = Object.assign( Object.create( Pass.prototype
 
 
 		}
 		}
 
 
-	},
+	}
 
 
-	setMinLuminance: function ( minLum ) {
+	setMinLuminance( minLum ) {
 
 
 		if ( minLum ) {
 		if ( minLum ) {
 
 
@@ -291,9 +288,9 @@ AdaptiveToneMappingPass.prototype = Object.assign( Object.create( Pass.prototype
 
 
 		}
 		}
 
 
-	},
+	}
 
 
-	setMaxLuminance: function ( maxLum ) {
+	setMaxLuminance( maxLum ) {
 
 
 		if ( maxLum ) {
 		if ( maxLum ) {
 
 
@@ -301,9 +298,9 @@ AdaptiveToneMappingPass.prototype = Object.assign( Object.create( Pass.prototype
 
 
 		}
 		}
 
 
-	},
+	}
 
 
-	setAverageLuminance: function ( avgLum ) {
+	setAverageLuminance( avgLum ) {
 
 
 		if ( avgLum ) {
 		if ( avgLum ) {
 
 
@@ -311,9 +308,9 @@ AdaptiveToneMappingPass.prototype = Object.assign( Object.create( Pass.prototype
 
 
 		}
 		}
 
 
-	},
+	}
 
 
-	setMiddleGrey: function ( middleGrey ) {
+	setMiddleGrey( middleGrey ) {
 
 
 		if ( middleGrey ) {
 		if ( middleGrey ) {
 
 
@@ -321,9 +318,9 @@ AdaptiveToneMappingPass.prototype = Object.assign( Object.create( Pass.prototype
 
 
 		}
 		}
 
 
-	},
+	}
 
 
-	dispose: function () {
+	dispose() {
 
 
 		if ( this.luminanceRT ) {
 		if ( this.luminanceRT ) {
 
 
@@ -369,6 +366,6 @@ AdaptiveToneMappingPass.prototype = Object.assign( Object.create( Pass.prototype
 
 
 	}
 	}
 
 
-} );
+}
 
 
 export { AdaptiveToneMappingPass };
 export { AdaptiveToneMappingPass };

+ 32 - 35
examples/jsm/postprocessing/AfterimagePass.js

@@ -7,58 +7,55 @@ import {
 	UniformsUtils,
 	UniformsUtils,
 	WebGLRenderTarget
 	WebGLRenderTarget
 } from '../../../build/three.module.js';
 } from '../../../build/three.module.js';
-import { Pass } from '../postprocessing/Pass.js';
+import { Pass, FullScreenQuad } from '../postprocessing/Pass.js';
 import { AfterimageShader } from '../shaders/AfterimageShader.js';
 import { AfterimageShader } from '../shaders/AfterimageShader.js';
 
 
-var AfterimagePass = function ( damp ) {
+class AfterimagePass extends Pass {
 
 
-	Pass.call( this );
+	constructor( damp = 0.96 ) {
 
 
-	if ( AfterimageShader === undefined )
-		console.error( 'THREE.AfterimagePass relies on AfterimageShader' );
+		super();
 
 
-	this.shader = AfterimageShader;
+		if ( AfterimageShader === undefined ) console.error( 'THREE.AfterimagePass relies on AfterimageShader' );
 
 
-	this.uniforms = UniformsUtils.clone( this.shader.uniforms );
+		this.shader = AfterimageShader;
 
 
-	this.uniforms[ 'damp' ].value = damp !== undefined ? damp : 0.96;
+		this.uniforms = UniformsUtils.clone( this.shader.uniforms );
 
 
-	this.textureComp = new WebGLRenderTarget( window.innerWidth, window.innerHeight, {
+		this.uniforms[ 'damp' ].value = damp;
 
 
-		minFilter: LinearFilter,
-		magFilter: NearestFilter,
-		format: RGBAFormat
+		this.textureComp = new WebGLRenderTarget( window.innerWidth, window.innerHeight, {
 
 
-	} );
+			minFilter: LinearFilter,
+			magFilter: NearestFilter,
+			format: RGBAFormat
 
 
-	this.textureOld = new WebGLRenderTarget( window.innerWidth, window.innerHeight, {
+		} );
 
 
-		minFilter: LinearFilter,
-		magFilter: NearestFilter,
-		format: RGBAFormat
+		this.textureOld = new WebGLRenderTarget( window.innerWidth, window.innerHeight, {
 
 
-	} );
+			minFilter: LinearFilter,
+			magFilter: NearestFilter,
+			format: RGBAFormat
 
 
-	this.shaderMaterial = new ShaderMaterial( {
+		} );
 
 
-		uniforms: this.uniforms,
-		vertexShader: this.shader.vertexShader,
-		fragmentShader: this.shader.fragmentShader
+		this.shaderMaterial = new ShaderMaterial( {
 
 
-	} );
+			uniforms: this.uniforms,
+			vertexShader: this.shader.vertexShader,
+			fragmentShader: this.shader.fragmentShader
 
 
-	this.compFsQuad = new Pass.FullScreenQuad( this.shaderMaterial );
+		} );
 
 
-	var material = new MeshBasicMaterial();
-	this.copyFsQuad = new Pass.FullScreenQuad( material );
+		this.compFsQuad = new FullScreenQuad( this.shaderMaterial );
 
 
-};
+		const material = new MeshBasicMaterial();
+		this.copyFsQuad = new FullScreenQuad( material );
 
 
-AfterimagePass.prototype = Object.assign( Object.create( Pass.prototype ), {
-
-	constructor: AfterimagePass,
+	}
 
 
-	render: function ( renderer, writeBuffer, readBuffer ) {
+	render( renderer, writeBuffer, readBuffer/*, deltaTime, maskActive*/ ) {
 
 
 		this.uniforms[ 'tOld' ].value = this.textureOld.texture;
 		this.uniforms[ 'tOld' ].value = this.textureOld.texture;
 		this.uniforms[ 'tNew' ].value = readBuffer.texture;
 		this.uniforms[ 'tNew' ].value = readBuffer.texture;
@@ -84,20 +81,20 @@ AfterimagePass.prototype = Object.assign( Object.create( Pass.prototype ), {
 		}
 		}
 
 
 		// Swap buffers.
 		// Swap buffers.
-		var temp = this.textureOld;
+		const temp = this.textureOld;
 		this.textureOld = this.textureComp;
 		this.textureOld = this.textureComp;
 		this.textureComp = temp;
 		this.textureComp = temp;
 		// Now textureOld contains the latest image, ready for the next frame.
 		// Now textureOld contains the latest image, ready for the next frame.
 
 
-	},
+	}
 
 
-	setSize: function ( width, height ) {
+	setSize( width, height ) {
 
 
 		this.textureComp.setSize( width, height );
 		this.textureComp.setSize( width, height );
 		this.textureOld.setSize( width, height );
 		this.textureOld.setSize( width, height );
 
 
 	}
 	}
 
 
-} );
+}
 
 
 export { AfterimagePass };
 export { AfterimagePass };

+ 42 - 51
examples/jsm/postprocessing/BloomPass.js

@@ -7,84 +7,75 @@ import {
 	Vector2,
 	Vector2,
 	WebGLRenderTarget
 	WebGLRenderTarget
 } from '../../../build/three.module.js';
 } from '../../../build/three.module.js';
-import { Pass } from '../postprocessing/Pass.js';
+import { Pass, FullScreenQuad } from '../postprocessing/Pass.js';
 import { CopyShader } from '../shaders/CopyShader.js';
 import { CopyShader } from '../shaders/CopyShader.js';
 import { ConvolutionShader } from '../shaders/ConvolutionShader.js';
 import { ConvolutionShader } from '../shaders/ConvolutionShader.js';
 
 
-var BloomPass = function ( strength, kernelSize, sigma, resolution ) {
+class BloomPass extends Pass {
 
 
-	Pass.call( this );
+	constructor( strength = 1, kernelSize = 25, sigma = 4, resolution = 256 ) {
 
 
-	strength = ( strength !== undefined ) ? strength : 1;
-	kernelSize = ( kernelSize !== undefined ) ? kernelSize : 25;
-	sigma = ( sigma !== undefined ) ? sigma : 4.0;
-	resolution = ( resolution !== undefined ) ? resolution : 256;
+		super();
 
 
-	// render targets
+		// render targets
 
 
-	var pars = { minFilter: LinearFilter, magFilter: LinearFilter, format: RGBAFormat };
+		const pars = { minFilter: LinearFilter, magFilter: LinearFilter, format: RGBAFormat };
 
 
-	this.renderTargetX = new WebGLRenderTarget( resolution, resolution, pars );
-	this.renderTargetX.texture.name = 'BloomPass.x';
-	this.renderTargetY = new WebGLRenderTarget( resolution, resolution, pars );
-	this.renderTargetY.texture.name = 'BloomPass.y';
+		this.renderTargetX = new WebGLRenderTarget( resolution, resolution, pars );
+		this.renderTargetX.texture.name = 'BloomPass.x';
+		this.renderTargetY = new WebGLRenderTarget( resolution, resolution, pars );
+		this.renderTargetY.texture.name = 'BloomPass.y';
 
 
-	// copy material
+		// copy material
 
 
-	if ( CopyShader === undefined )
-		console.error( 'THREE.BloomPass relies on CopyShader' );
+		if ( CopyShader === undefined ) console.error( 'THREE.BloomPass relies on CopyShader' );
 
 
-	var copyShader = CopyShader;
+		const copyShader = CopyShader;
 
 
-	this.copyUniforms = UniformsUtils.clone( copyShader.uniforms );
+		this.copyUniforms = UniformsUtils.clone( copyShader.uniforms );
 
 
-	this.copyUniforms[ 'opacity' ].value = strength;
+		this.copyUniforms[ 'opacity' ].value = strength;
 
 
-	this.materialCopy = new ShaderMaterial( {
+		this.materialCopy = new ShaderMaterial( {
 
 
-		uniforms: this.copyUniforms,
-		vertexShader: copyShader.vertexShader,
-		fragmentShader: copyShader.fragmentShader,
-		blending: AdditiveBlending,
-		transparent: true
+			uniforms: this.copyUniforms,
+			vertexShader: copyShader.vertexShader,
+			fragmentShader: copyShader.fragmentShader,
+			blending: AdditiveBlending,
+			transparent: true
 
 
-	} );
+		} );
 
 
-	// convolution material
+		// convolution material
 
 
-	if ( ConvolutionShader === undefined )
-		console.error( 'THREE.BloomPass relies on ConvolutionShader' );
+		if ( ConvolutionShader === undefined ) console.error( 'THREE.BloomPass relies on ConvolutionShader' );
 
 
-	var convolutionShader = ConvolutionShader;
+		const convolutionShader = ConvolutionShader;
 
 
-	this.convolutionUniforms = UniformsUtils.clone( convolutionShader.uniforms );
+		this.convolutionUniforms = UniformsUtils.clone( convolutionShader.uniforms );
 
 
-	this.convolutionUniforms[ 'uImageIncrement' ].value = BloomPass.blurX;
-	this.convolutionUniforms[ 'cKernel' ].value = ConvolutionShader.buildKernel( sigma );
-
-	this.materialConvolution = new ShaderMaterial( {
-
-		uniforms: this.convolutionUniforms,
-		vertexShader: convolutionShader.vertexShader,
-		fragmentShader: convolutionShader.fragmentShader,
-		defines: {
-			'KERNEL_SIZE_FLOAT': kernelSize.toFixed( 1 ),
-			'KERNEL_SIZE_INT': kernelSize.toFixed( 0 )
-		}
+		this.convolutionUniforms[ 'uImageIncrement' ].value = BloomPass.blurX;
+		this.convolutionUniforms[ 'cKernel' ].value = ConvolutionShader.buildKernel( sigma );
 
 
-	} );
+		this.materialConvolution = new ShaderMaterial( {
 
 
-	this.needsSwap = false;
+			uniforms: this.convolutionUniforms,
+			vertexShader: convolutionShader.vertexShader,
+			fragmentShader: convolutionShader.fragmentShader,
+			defines: {
+				'KERNEL_SIZE_FLOAT': kernelSize.toFixed( 1 ),
+				'KERNEL_SIZE_INT': kernelSize.toFixed( 0 )
+			}
 
 
-	this.fsQuad = new Pass.FullScreenQuad( null );
+		} );
 
 
-};
+		this.needsSwap = false;
 
 
-BloomPass.prototype = Object.assign( Object.create( Pass.prototype ), {
+		this.fsQuad = new FullScreenQuad( null );
 
 
-	constructor: BloomPass,
+	}
 
 
-	render: function ( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {
+	render( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {
 
 
 		if ( maskActive ) renderer.state.buffers.stencil.setTest( false );
 		if ( maskActive ) renderer.state.buffers.stencil.setTest( false );
 
 
@@ -123,7 +114,7 @@ BloomPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 	}
 	}
 
 
-} );
+}
 
 
 BloomPass.blurX = new Vector2( 0.001953125, 0.0 );
 BloomPass.blurX = new Vector2( 0.001953125, 0.0 );
 BloomPass.blurY = new Vector2( 0.0, 0.001953125 );
 BloomPass.blurY = new Vector2( 0.0, 0.001953125 );

+ 50 - 52
examples/jsm/postprocessing/BokehPass.js

@@ -8,92 +8,90 @@ import {
 	UniformsUtils,
 	UniformsUtils,
 	WebGLRenderTarget
 	WebGLRenderTarget
 } from '../../../build/three.module.js';
 } from '../../../build/three.module.js';
-import { Pass } from '../postprocessing/Pass.js';
+import { Pass, FullScreenQuad } from '../postprocessing/Pass.js';
 import { BokehShader } from '../shaders/BokehShader.js';
 import { BokehShader } from '../shaders/BokehShader.js';
 
 
 /**
 /**
  * Depth-of-field post-process with bokeh shader
  * Depth-of-field post-process with bokeh shader
  */
  */
 
 
-var BokehPass = function ( scene, camera, params ) {
+class BokehPass extends Pass {
 
 
-	Pass.call( this );
+	constructor( scene, camera, params ) {
 
 
-	this.scene = scene;
-	this.camera = camera;
+		super();
 
 
-	var focus = ( params.focus !== undefined ) ? params.focus : 1.0;
-	var aspect = ( params.aspect !== undefined ) ? params.aspect : camera.aspect;
-	var aperture = ( params.aperture !== undefined ) ? params.aperture : 0.025;
-	var maxblur = ( params.maxblur !== undefined ) ? params.maxblur : 1.0;
+		this.scene = scene;
+		this.camera = camera;
 
 
-	// render targets
+		const focus = ( params.focus !== undefined ) ? params.focus : 1.0;
+		const aspect = ( params.aspect !== undefined ) ? params.aspect : camera.aspect;
+		const aperture = ( params.aperture !== undefined ) ? params.aperture : 0.025;
+		const maxblur = ( params.maxblur !== undefined ) ? params.maxblur : 1.0;
 
 
-	var width = params.width || window.innerWidth || 1;
-	var height = params.height || window.innerHeight || 1;
+		// render targets
 
 
-	this.renderTargetDepth = new WebGLRenderTarget( width, height, {
-		minFilter: NearestFilter,
-		magFilter: NearestFilter
-	} );
+		const width = params.width || window.innerWidth || 1;
+		const height = params.height || window.innerHeight || 1;
 
 
-	this.renderTargetDepth.texture.name = 'BokehPass.depth';
+		this.renderTargetDepth = new WebGLRenderTarget( width, height, {
+			minFilter: NearestFilter,
+			magFilter: NearestFilter
+		} );
 
 
-	// depth material
+		this.renderTargetDepth.texture.name = 'BokehPass.depth';
 
 
-	this.materialDepth = new MeshDepthMaterial();
-	this.materialDepth.depthPacking = RGBADepthPacking;
-	this.materialDepth.blending = NoBlending;
+		// depth material
 
 
-	// bokeh material
+		this.materialDepth = new MeshDepthMaterial();
+		this.materialDepth.depthPacking = RGBADepthPacking;
+		this.materialDepth.blending = NoBlending;
 
 
-	if ( BokehShader === undefined ) {
+		// bokeh material
 
 
-		console.error( 'THREE.BokehPass relies on BokehShader' );
+		if ( BokehShader === undefined ) {
 
 
-	}
-
-	var bokehShader = BokehShader;
-	var bokehUniforms = UniformsUtils.clone( bokehShader.uniforms );
+			console.error( 'THREE.BokehPass relies on BokehShader' );
 
 
-	bokehUniforms[ 'tDepth' ].value = this.renderTargetDepth.texture;
+		}
 
 
-	bokehUniforms[ 'focus' ].value = focus;
-	bokehUniforms[ 'aspect' ].value = aspect;
-	bokehUniforms[ 'aperture' ].value = aperture;
-	bokehUniforms[ 'maxblur' ].value = maxblur;
-	bokehUniforms[ 'nearClip' ].value = camera.near;
-	bokehUniforms[ 'farClip' ].value = camera.far;
+		const bokehShader = BokehShader;
+		const bokehUniforms = UniformsUtils.clone( bokehShader.uniforms );
 
 
-	this.materialBokeh = new ShaderMaterial( {
-		defines: Object.assign( {}, bokehShader.defines ),
-		uniforms: bokehUniforms,
-		vertexShader: bokehShader.vertexShader,
-		fragmentShader: bokehShader.fragmentShader
-	} );
+		bokehUniforms[ 'tDepth' ].value = this.renderTargetDepth.texture;
 
 
-	this.uniforms = bokehUniforms;
-	this.needsSwap = false;
+		bokehUniforms[ 'focus' ].value = focus;
+		bokehUniforms[ 'aspect' ].value = aspect;
+		bokehUniforms[ 'aperture' ].value = aperture;
+		bokehUniforms[ 'maxblur' ].value = maxblur;
+		bokehUniforms[ 'nearClip' ].value = camera.near;
+		bokehUniforms[ 'farClip' ].value = camera.far;
 
 
-	this.fsQuad = new Pass.FullScreenQuad( this.materialBokeh );
+		this.materialBokeh = new ShaderMaterial( {
+			defines: Object.assign( {}, bokehShader.defines ),
+			uniforms: bokehUniforms,
+			vertexShader: bokehShader.vertexShader,
+			fragmentShader: bokehShader.fragmentShader
+		} );
 
 
-	this._oldClearColor = new Color();
+		this.uniforms = bokehUniforms;
+		this.needsSwap = false;
 
 
-};
+		this.fsQuad = new FullScreenQuad( this.materialBokeh );
 
 
-BokehPass.prototype = Object.assign( Object.create( Pass.prototype ), {
+		this._oldClearColor = new Color();
 
 
-	constructor: BokehPass,
+	}
 
 
-	render: function ( renderer, writeBuffer, readBuffer/*, deltaTime, maskActive*/ ) {
+	render( renderer, writeBuffer, readBuffer/*, deltaTime, maskActive*/ ) {
 
 
 		// Render depth into texture
 		// Render depth into texture
 
 
 		this.scene.overrideMaterial = this.materialDepth;
 		this.scene.overrideMaterial = this.materialDepth;
 
 
 		renderer.getClearColor( this._oldClearColor );
 		renderer.getClearColor( this._oldClearColor );
-		var oldClearAlpha = renderer.getClearAlpha();
-		var oldAutoClear = renderer.autoClear;
+		const oldClearAlpha = renderer.getClearAlpha();
+		const oldAutoClear = renderer.autoClear;
 		renderer.autoClear = false;
 		renderer.autoClear = false;
 
 
 		renderer.setClearColor( 0xffffff );
 		renderer.setClearColor( 0xffffff );
@@ -128,6 +126,6 @@ BokehPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 	}
 	}
 
 
-} );
+}
 
 
 export { BokehPass };
 export { BokehPass };

+ 11 - 13
examples/jsm/postprocessing/ClearPass.js

@@ -3,25 +3,23 @@ import {
 } from '../../../build/three.module.js';
 } from '../../../build/three.module.js';
 import { Pass } from '../postprocessing/Pass.js';
 import { Pass } from '../postprocessing/Pass.js';
 
 
-var ClearPass = function ( clearColor, clearAlpha ) {
+class ClearPass extends Pass {
 
 
-	Pass.call( this );
+	constructor( clearColor, clearAlpha ) {
 
 
-	this.needsSwap = false;
+		super();
 
 
-	this.clearColor = ( clearColor !== undefined ) ? clearColor : 0x000000;
-	this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0;
-	this._oldClearColor = new Color();
+		this.needsSwap = false;
 
 
-};
+		this.clearColor = ( clearColor !== undefined ) ? clearColor : 0x000000;
+		this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0;
+		this._oldClearColor = new Color();
 
 
-ClearPass.prototype = Object.assign( Object.create( Pass.prototype ), {
-
-	constructor: ClearPass,
+	}
 
 
-	render: function ( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
+	render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
 
 
-		var oldClearAlpha;
+		let oldClearAlpha;
 
 
 		if ( this.clearColor ) {
 		if ( this.clearColor ) {
 
 
@@ -43,6 +41,6 @@ ClearPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 	}
 	}
 
 
-} );
+}
 
 
 export { ClearPass };
 export { ClearPass };

+ 31 - 33
examples/jsm/postprocessing/CubeTexturePass.js

@@ -10,53 +10,51 @@ import {
 } from '../../../build/three.module.js';
 } from '../../../build/three.module.js';
 import { Pass } from '../postprocessing/Pass.js';
 import { Pass } from '../postprocessing/Pass.js';
 
 
-var CubeTexturePass = function ( camera, envMap, opacity ) {
+class CubeTexturePass extends Pass {
 
 
-	Pass.call( this );
+	constructor( camera, envMap, opacity = 1 ) {
 
 
-	this.camera = camera;
+		super();
 
 
-	this.needsSwap = false;
+		this.camera = camera;
 
 
-	this.cubeShader = ShaderLib[ 'cube' ];
-	this.cubeMesh = new Mesh(
-		new BoxGeometry( 10, 10, 10 ),
-		new ShaderMaterial( {
-			uniforms: UniformsUtils.clone( this.cubeShader.uniforms ),
-			vertexShader: this.cubeShader.vertexShader,
-			fragmentShader: this.cubeShader.fragmentShader,
-			depthTest: false,
-			depthWrite: false,
-			side: BackSide
-		} )
-	);
+		this.needsSwap = false;
 
 
-	Object.defineProperty( this.cubeMesh.material, 'envMap', {
+		this.cubeShader = ShaderLib[ 'cube' ];
+		this.cubeMesh = new Mesh(
+			new BoxGeometry( 10, 10, 10 ),
+			new ShaderMaterial( {
+				uniforms: UniformsUtils.clone( this.cubeShader.uniforms ),
+				vertexShader: this.cubeShader.vertexShader,
+				fragmentShader: this.cubeShader.fragmentShader,
+				depthTest: false,
+				depthWrite: false,
+				side: BackSide
+			} )
+		);
 
 
-		get: function () {
+		Object.defineProperty( this.cubeMesh.material, 'envMap', {
 
 
-			return this.uniforms.envMap.value;
+			get: function () {
 
 
-		}
+				return this.uniforms.envMap.value;
 
 
-	} );
+			}
 
 
-	this.envMap = envMap;
-	this.opacity = ( opacity !== undefined ) ? opacity : 1.0;
+		} );
 
 
-	this.cubeScene = new Scene();
-	this.cubeCamera = new PerspectiveCamera();
-	this.cubeScene.add( this.cubeMesh );
+		this.envMap = envMap;
+		this.opacity = opacity;
 
 
-};
+		this.cubeScene = new Scene();
+		this.cubeCamera = new PerspectiveCamera();
+		this.cubeScene.add( this.cubeMesh );
 
 
-CubeTexturePass.prototype = Object.assign( Object.create( Pass.prototype ), {
-
-	constructor: CubeTexturePass,
+	}
 
 
-	render: function ( renderer, writeBuffer, readBuffer/*, deltaTime, maskActive*/ ) {
+	render( renderer, writeBuffer, readBuffer/*, deltaTime, maskActive*/ ) {
 
 
-		var oldAutoClear = renderer.autoClear;
+		const oldAutoClear = renderer.autoClear;
 		renderer.autoClear = false;
 		renderer.autoClear = false;
 
 
 		this.cubeCamera.projectionMatrix.copy( this.camera.projectionMatrix );
 		this.cubeCamera.projectionMatrix.copy( this.camera.projectionMatrix );
@@ -75,6 +73,6 @@ CubeTexturePass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 	}
 	}
 
 
-} );
+}
 
 
 export { CubeTexturePass };
 export { CubeTexturePass };

+ 19 - 22
examples/jsm/postprocessing/DotScreenPass.js

@@ -2,41 +2,38 @@ import {
 	ShaderMaterial,
 	ShaderMaterial,
 	UniformsUtils
 	UniformsUtils
 } from '../../../build/three.module.js';
 } from '../../../build/three.module.js';
-import { Pass } from '../postprocessing/Pass.js';
+import { Pass, FullScreenQuad } from '../postprocessing/Pass.js';
 import { DotScreenShader } from '../shaders/DotScreenShader.js';
 import { DotScreenShader } from '../shaders/DotScreenShader.js';
 
 
-var DotScreenPass = function ( center, angle, scale ) {
+class DotScreenPass extends Pass {
 
 
-	Pass.call( this );
+	constructor( center, angle, scale ) {
 
 
-	if ( DotScreenShader === undefined )
-		console.error( 'THREE.DotScreenPass relies on DotScreenShader' );
+		super();
 
 
-	var shader = DotScreenShader;
+		if ( DotScreenShader === undefined ) console.error( 'THREE.DotScreenPass relies on DotScreenShader' );
 
 
-	this.uniforms = UniformsUtils.clone( shader.uniforms );
+		var shader = DotScreenShader;
 
 
-	if ( center !== undefined ) this.uniforms[ 'center' ].value.copy( center );
-	if ( angle !== undefined ) this.uniforms[ 'angle' ].value = angle;
-	if ( scale !== undefined ) this.uniforms[ 'scale' ].value = scale;
+		this.uniforms = UniformsUtils.clone( shader.uniforms );
 
 
-	this.material = new ShaderMaterial( {
+		if ( center !== undefined ) this.uniforms[ 'center' ].value.copy( center );
+		if ( angle !== undefined ) this.uniforms[ 'angle' ].value = angle;
+		if ( scale !== undefined ) this.uniforms[ 'scale' ].value = scale;
 
 
-		uniforms: this.uniforms,
-		vertexShader: shader.vertexShader,
-		fragmentShader: shader.fragmentShader
+		this.material = new ShaderMaterial( {
 
 
-	} );
+			uniforms: this.uniforms,
+			vertexShader: shader.vertexShader,
+			fragmentShader: shader.fragmentShader
 
 
-	this.fsQuad = new Pass.FullScreenQuad( this.material );
+		} );
 
 
-};
+		this.fsQuad = new FullScreenQuad( this.material );
 
 
-DotScreenPass.prototype = Object.assign( Object.create( Pass.prototype ), {
-
-	constructor: DotScreenPass,
+	}
 
 
-	render: function ( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
+	render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
 
 
 		this.uniforms[ 'tDiffuse' ].value = readBuffer.texture;
 		this.uniforms[ 'tDiffuse' ].value = readBuffer.texture;
 		this.uniforms[ 'tSize' ].value.set( readBuffer.width, readBuffer.height );
 		this.uniforms[ 'tSize' ].value.set( readBuffer.width, readBuffer.height );
@@ -56,6 +53,6 @@ DotScreenPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 	}
 	}
 
 
-} );
+}
 
 
 export { DotScreenPass };
 export { DotScreenPass };

+ 104 - 115
examples/jsm/postprocessing/EffectComposer.js

@@ -14,90 +14,90 @@ import { ShaderPass } from '../postprocessing/ShaderPass.js';
 import { MaskPass } from '../postprocessing/MaskPass.js';
 import { MaskPass } from '../postprocessing/MaskPass.js';
 import { ClearMaskPass } from '../postprocessing/MaskPass.js';
 import { ClearMaskPass } from '../postprocessing/MaskPass.js';
 
 
-var EffectComposer = function ( renderer, renderTarget ) {
+class EffectComposer {
 
 
-	this.renderer = renderer;
+	constructor( renderer, renderTarget ) {
 
 
-	if ( renderTarget === undefined ) {
+		this.renderer = renderer;
 
 
-		var parameters = {
-			minFilter: LinearFilter,
-			magFilter: LinearFilter,
-			format: RGBAFormat
-		};
+		if ( renderTarget === undefined ) {
 
 
-		var size = renderer.getSize( new Vector2() );
-		this._pixelRatio = renderer.getPixelRatio();
-		this._width = size.width;
-		this._height = size.height;
+			const parameters = {
+				minFilter: LinearFilter,
+				magFilter: LinearFilter,
+				format: RGBAFormat
+			};
 
 
-		renderTarget = new WebGLRenderTarget( this._width * this._pixelRatio, this._height * this._pixelRatio, parameters );
-		renderTarget.texture.name = 'EffectComposer.rt1';
+			const size = renderer.getSize( new Vector2() );
+			this._pixelRatio = renderer.getPixelRatio();
+			this._width = size.width;
+			this._height = size.height;
 
 
-	} else {
+			renderTarget = new WebGLRenderTarget( this._width * this._pixelRatio, this._height * this._pixelRatio, parameters );
+			renderTarget.texture.name = 'EffectComposer.rt1';
 
 
-		this._pixelRatio = 1;
-		this._width = renderTarget.width;
-		this._height = renderTarget.height;
+		} else {
 
 
-	}
+			this._pixelRatio = 1;
+			this._width = renderTarget.width;
+			this._height = renderTarget.height;
 
 
-	this.renderTarget1 = renderTarget;
-	this.renderTarget2 = renderTarget.clone();
-	this.renderTarget2.texture.name = 'EffectComposer.rt2';
+		}
 
 
-	this.writeBuffer = this.renderTarget1;
-	this.readBuffer = this.renderTarget2;
+		this.renderTarget1 = renderTarget;
+		this.renderTarget2 = renderTarget.clone();
+		this.renderTarget2.texture.name = 'EffectComposer.rt2';
 
 
-	this.renderToScreen = true;
+		this.writeBuffer = this.renderTarget1;
+		this.readBuffer = this.renderTarget2;
 
 
-	this.passes = [];
+		this.renderToScreen = true;
 
 
-	// dependencies
+		this.passes = [];
 
 
-	if ( CopyShader === undefined ) {
+		// dependencies
 
 
-		console.error( 'THREE.EffectComposer relies on CopyShader' );
+		if ( CopyShader === undefined ) {
 
 
-	}
+			console.error( 'THREE.EffectComposer relies on CopyShader' );
 
 
-	if ( ShaderPass === undefined ) {
+		}
 
 
-		console.error( 'THREE.EffectComposer relies on ShaderPass' );
+		if ( ShaderPass === undefined ) {
 
 
-	}
+			console.error( 'THREE.EffectComposer relies on ShaderPass' );
 
 
-	this.copyPass = new ShaderPass( CopyShader );
+		}
 
 
-	this.clock = new Clock();
+		this.copyPass = new ShaderPass( CopyShader );
 
 
-};
+		this.clock = new Clock();
 
 
-Object.assign( EffectComposer.prototype, {
+	}
 
 
-	swapBuffers: function () {
+	swapBuffers() {
 
 
-		var tmp = this.readBuffer;
+		const tmp = this.readBuffer;
 		this.readBuffer = this.writeBuffer;
 		this.readBuffer = this.writeBuffer;
 		this.writeBuffer = tmp;
 		this.writeBuffer = tmp;
 
 
-	},
+	}
 
 
-	addPass: function ( pass ) {
+	addPass( pass ) {
 
 
 		this.passes.push( pass );
 		this.passes.push( pass );
 		pass.setSize( this._width * this._pixelRatio, this._height * this._pixelRatio );
 		pass.setSize( this._width * this._pixelRatio, this._height * this._pixelRatio );
 
 
-	},
+	}
 
 
-	insertPass: function ( pass, index ) {
+	insertPass( pass, index ) {
 
 
 		this.passes.splice( index, 0, pass );
 		this.passes.splice( index, 0, pass );
 		pass.setSize( this._width * this._pixelRatio, this._height * this._pixelRatio );
 		pass.setSize( this._width * this._pixelRatio, this._height * this._pixelRatio );
 
 
-	},
+	}
 
 
-	removePass: function ( pass ) {
+	removePass( pass ) {
 
 
 		const index = this.passes.indexOf( pass );
 		const index = this.passes.indexOf( pass );
 
 
@@ -107,11 +107,11 @@ Object.assign( EffectComposer.prototype, {
 
 
 		}
 		}
 
 
-	},
+	}
 
 
-	isLastEnabledPass: function ( passIndex ) {
+	isLastEnabledPass( passIndex ) {
 
 
-		for ( var i = passIndex + 1; i < this.passes.length; i ++ ) {
+		for ( let i = passIndex + 1; i < this.passes.length; i ++ ) {
 
 
 			if ( this.passes[ i ].enabled ) {
 			if ( this.passes[ i ].enabled ) {
 
 
@@ -123,9 +123,9 @@ Object.assign( EffectComposer.prototype, {
 
 
 		return true;
 		return true;
 
 
-	},
+	}
 
 
-	render: function ( deltaTime ) {
+	render( deltaTime ) {
 
 
 		// deltaTime value is in seconds
 		// deltaTime value is in seconds
 
 
@@ -135,15 +135,13 @@ Object.assign( EffectComposer.prototype, {
 
 
 		}
 		}
 
 
-		var currentRenderTarget = this.renderer.getRenderTarget();
-
-		var maskActive = false;
+		const currentRenderTarget = this.renderer.getRenderTarget();
 
 
-		var pass, i, il = this.passes.length;
+		let maskActive = false;
 
 
-		for ( i = 0; i < il; i ++ ) {
+		for ( let i = 0, il = this.passes.length; i < il; i ++ ) {
 
 
-			pass = this.passes[ i ];
+			const pass = this.passes[ i ];
 
 
 			if ( pass.enabled === false ) continue;
 			if ( pass.enabled === false ) continue;
 
 
@@ -154,8 +152,8 @@ Object.assign( EffectComposer.prototype, {
 
 
 				if ( maskActive ) {
 				if ( maskActive ) {
 
 
-					var context = this.renderer.getContext();
-					var stencil = this.renderer.state.buffers.stencil;
+					const context = this.renderer.getContext();
+					const stencil = this.renderer.state.buffers.stencil;
 
 
 					//context.stencilFunc( context.NOTEQUAL, 1, 0xffffffff );
 					//context.stencilFunc( context.NOTEQUAL, 1, 0xffffffff );
 					stencil.setFunc( context.NOTEQUAL, 1, 0xffffffff );
 					stencil.setFunc( context.NOTEQUAL, 1, 0xffffffff );
@@ -189,13 +187,13 @@ Object.assign( EffectComposer.prototype, {
 
 
 		this.renderer.setRenderTarget( currentRenderTarget );
 		this.renderer.setRenderTarget( currentRenderTarget );
 
 
-	},
+	}
 
 
-	reset: function ( renderTarget ) {
+	reset( renderTarget ) {
 
 
 		if ( renderTarget === undefined ) {
 		if ( renderTarget === undefined ) {
 
 
-			var size = this.renderer.getSize( new Vector2() );
+			const size = this.renderer.getSize( new Vector2() );
 			this._pixelRatio = this.renderer.getPixelRatio();
 			this._pixelRatio = this.renderer.getPixelRatio();
 			this._width = size.width;
 			this._width = size.width;
 			this._height = size.height;
 			this._height = size.height;
@@ -213,28 +211,28 @@ Object.assign( EffectComposer.prototype, {
 		this.writeBuffer = this.renderTarget1;
 		this.writeBuffer = this.renderTarget1;
 		this.readBuffer = this.renderTarget2;
 		this.readBuffer = this.renderTarget2;
 
 
-	},
+	}
 
 
-	setSize: function ( width, height ) {
+	setSize( width, height ) {
 
 
 		this._width = width;
 		this._width = width;
 		this._height = height;
 		this._height = height;
 
 
-		var effectiveWidth = this._width * this._pixelRatio;
-		var effectiveHeight = this._height * this._pixelRatio;
+		const effectiveWidth = this._width * this._pixelRatio;
+		const effectiveHeight = this._height * this._pixelRatio;
 
 
 		this.renderTarget1.setSize( effectiveWidth, effectiveHeight );
 		this.renderTarget1.setSize( effectiveWidth, effectiveHeight );
 		this.renderTarget2.setSize( effectiveWidth, effectiveHeight );
 		this.renderTarget2.setSize( effectiveWidth, effectiveHeight );
 
 
-		for ( var i = 0; i < this.passes.length; i ++ ) {
+		for ( let i = 0; i < this.passes.length; i ++ ) {
 
 
 			this.passes[ i ].setSize( effectiveWidth, effectiveHeight );
 			this.passes[ i ].setSize( effectiveWidth, effectiveHeight );
 
 
 		}
 		}
 
 
-	},
+	}
 
 
-	setPixelRatio: function ( pixelRatio ) {
+	setPixelRatio( pixelRatio ) {
 
 
 		this._pixelRatio = pixelRatio;
 		this._pixelRatio = pixelRatio;
 
 
@@ -242,88 +240,79 @@ Object.assign( EffectComposer.prototype, {
 
 
 	}
 	}
 
 
-} );
+}
 
 
 
 
-var Pass = function () {
+class Pass {
 
 
-	// if set to true, the pass is processed by the composer
-	this.enabled = true;
+	constructor() {
 
 
-	// if set to true, the pass indicates to swap read and write buffer after rendering
-	this.needsSwap = true;
+		// if set to true, the pass is processed by the composer
+		this.enabled = true;
 
 
-	// if set to true, the pass clears its buffer before rendering
-	this.clear = false;
+		// if set to true, the pass indicates to swap read and write buffer after rendering
+		this.needsSwap = true;
 
 
-	// if set to true, the result of the pass is rendered to screen. This is set automatically by EffectComposer.
-	this.renderToScreen = false;
+		// if set to true, the pass clears its buffer before rendering
+		this.clear = false;
 
 
-};
+		// if set to true, the result of the pass is rendered to screen. This is set automatically by EffectComposer.
+		this.renderToScreen = false;
 
 
-Object.assign( Pass.prototype, {
+	}
 
 
-	setSize: function ( /* width, height */ ) {},
+	setSize( /* width, height */ ) {}
 
 
-	render: function ( /* renderer, writeBuffer, readBuffer, deltaTime, maskActive */ ) {
+	render( /* renderer, writeBuffer, readBuffer, deltaTime, maskActive */ ) {
 
 
 		console.error( 'THREE.Pass: .render() must be implemented in derived pass.' );
 		console.error( 'THREE.Pass: .render() must be implemented in derived pass.' );
 
 
 	}
 	}
 
 
-} );
+}
 
 
 // Helper for passes that need to fill the viewport with a single quad.
 // Helper for passes that need to fill the viewport with a single quad.
-Pass.FullScreenQuad = ( function () {
-
-	var camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
-
-	// https://github.com/mrdoob/three.js/pull/21358
-
-	var geometry = new BufferGeometry();
-	geometry.setAttribute( 'position', new Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );
-	geometry.setAttribute( 'uv', new Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );
 
 
-	var FullScreenQuad = function ( material ) {
+const _camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
 
 
-		this._mesh = new Mesh( geometry, material );
+// https://github.com/mrdoob/three.js/pull/21358
 
 
-	};
+const _geometry = new BufferGeometry();
+_geometry.setAttribute( 'position', new Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );
+_geometry.setAttribute( 'uv', new Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );
 
 
-	Object.defineProperty( FullScreenQuad.prototype, 'material', {
+class FullScreenQuad {
 
 
-		get: function () {
+	constructor( material ) {
 
 
-			return this._mesh.material;
+		this._mesh = new Mesh( _geometry, material );
 
 
-		},
-
-		set: function ( value ) {
+	}
 
 
-			this._mesh.material = value;
+	dispose() {
 
 
-		}
+		this._mesh.geometry.dispose();
 
 
-	} );
+	}
 
 
-	Object.assign( FullScreenQuad.prototype, {
+	render( renderer ) {
 
 
-		dispose: function () {
+		renderer.render( this._mesh, _camera );
 
 
-			this._mesh.geometry.dispose();
+	}
 
 
-		},
+	get material() {
 
 
-		render: function ( renderer ) {
+		return this._mesh.material;
 
 
-			renderer.render( this._mesh, camera );
+	}
 
 
-		}
+	set material( value ) {
 
 
-	} );
+		this._mesh.material = value;
 
 
-	return FullScreenQuad;
+	}
 
 
-} )();
+}
 
 
-export { EffectComposer, Pass };
+export { EffectComposer, Pass, FullScreenQuad };

+ 20 - 23
examples/jsm/postprocessing/FilmPass.js

@@ -2,42 +2,39 @@ import {
 	ShaderMaterial,
 	ShaderMaterial,
 	UniformsUtils
 	UniformsUtils
 } from '../../../build/three.module.js';
 } from '../../../build/three.module.js';
-import { Pass } from '../postprocessing/Pass.js';
+import { Pass, FullScreenQuad } from '../postprocessing/Pass.js';
 import { FilmShader } from '../shaders/FilmShader.js';
 import { FilmShader } from '../shaders/FilmShader.js';
 
 
-var FilmPass = function ( noiseIntensity, scanlinesIntensity, scanlinesCount, grayscale ) {
+class FilmPass extends Pass {
 
 
-	Pass.call( this );
+	constructor( noiseIntensity, scanlinesIntensity, scanlinesCount, grayscale ) {
 
 
-	if ( FilmShader === undefined )
-		console.error( 'THREE.FilmPass relies on FilmShader' );
+		super();
 
 
-	var shader = FilmShader;
+		if ( FilmShader === undefined ) console.error( 'THREE.FilmPass relies on FilmShader' );
 
 
-	this.uniforms = UniformsUtils.clone( shader.uniforms );
+		const shader = FilmShader;
 
 
-	this.material = new ShaderMaterial( {
+		this.uniforms = UniformsUtils.clone( shader.uniforms );
 
 
-		uniforms: this.uniforms,
-		vertexShader: shader.vertexShader,
-		fragmentShader: shader.fragmentShader
+		this.material = new ShaderMaterial( {
 
 
-	} );
+			uniforms: this.uniforms,
+			vertexShader: shader.vertexShader,
+			fragmentShader: shader.fragmentShader
 
 
-	if ( grayscale !== undefined )	this.uniforms.grayscale.value = grayscale;
-	if ( noiseIntensity !== undefined ) this.uniforms.nIntensity.value = noiseIntensity;
-	if ( scanlinesIntensity !== undefined ) this.uniforms.sIntensity.value = scanlinesIntensity;
-	if ( scanlinesCount !== undefined ) this.uniforms.sCount.value = scanlinesCount;
+		} );
 
 
-	this.fsQuad = new Pass.FullScreenQuad( this.material );
+		if ( grayscale !== undefined )	this.uniforms.grayscale.value = grayscale;
+		if ( noiseIntensity !== undefined ) this.uniforms.nIntensity.value = noiseIntensity;
+		if ( scanlinesIntensity !== undefined ) this.uniforms.sIntensity.value = scanlinesIntensity;
+		if ( scanlinesCount !== undefined ) this.uniforms.sCount.value = scanlinesCount;
 
 
-};
+		this.fsQuad = new FullScreenQuad( this.material );
 
 
-FilmPass.prototype = Object.assign( Object.create( Pass.prototype ), {
-
-	constructor: FilmPass,
+	}
 
 
-	render: function ( renderer, writeBuffer, readBuffer, deltaTime /*, maskActive */ ) {
+	render( renderer, writeBuffer, readBuffer, deltaTime /*, maskActive */ ) {
 
 
 		this.uniforms[ 'tDiffuse' ].value = readBuffer.texture;
 		this.uniforms[ 'tDiffuse' ].value = readBuffer.texture;
 		this.uniforms[ 'time' ].value += deltaTime;
 		this.uniforms[ 'time' ].value += deltaTime;
@@ -57,6 +54,6 @@ FilmPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 	}
 	}
 
 
-} );
+}
 
 
 export { FilmPass };
 export { FilmPass };

+ 28 - 33
examples/jsm/postprocessing/GlitchPass.js

@@ -6,43 +6,38 @@ import {
 	ShaderMaterial,
 	ShaderMaterial,
 	UniformsUtils
 	UniformsUtils
 } from '../../../build/three.module.js';
 } from '../../../build/three.module.js';
-import { Pass } from '../postprocessing/Pass.js';
+import { Pass, FullScreenQuad } from '../postprocessing/Pass.js';
 import { DigitalGlitch } from '../shaders/DigitalGlitch.js';
 import { DigitalGlitch } from '../shaders/DigitalGlitch.js';
 
 
-var GlitchPass = function ( dt_size ) {
+class GlitchPass extends Pass {
 
 
-	Pass.call( this );
+	constructor( dt_size = 64 ) {
 
 
-	if ( DigitalGlitch === undefined ) console.error( 'THREE.GlitchPass relies on DigitalGlitch' );
+		super();
 
 
-	var shader = DigitalGlitch;
-	this.uniforms = UniformsUtils.clone( shader.uniforms );
+		if ( DigitalGlitch === undefined ) console.error( 'THREE.GlitchPass relies on DigitalGlitch' );
 
 
-	if ( dt_size == undefined ) dt_size = 64;
+		const shader = DigitalGlitch;
 
 
+		this.uniforms = UniformsUtils.clone( shader.uniforms );
 
 
-	this.uniforms[ 'tDisp' ].value = this.generateHeightmap( dt_size );
+		this.uniforms[ 'tDisp' ].value = this.generateHeightmap( dt_size );
 
 
+		this.material = new ShaderMaterial( {
+			uniforms: this.uniforms,
+			vertexShader: shader.vertexShader,
+			fragmentShader: shader.fragmentShader
+		} );
 
 
-	this.material = new ShaderMaterial( {
-		uniforms: this.uniforms,
-		vertexShader: shader.vertexShader,
-		fragmentShader: shader.fragmentShader
-	} );
+		this.fsQuad = new FullScreenQuad( this.material );
 
 
-	this.fsQuad = new Pass.FullScreenQuad( this.material );
+		this.goWild = false;
+		this.curF = 0;
+		this.generateTrigger();
 
 
-	this.goWild = false;
-	this.curF = 0;
-	this.generateTrigger();
-
-};
-
-GlitchPass.prototype = Object.assign( Object.create( Pass.prototype ), {
-
-	constructor: GlitchPass,
+	}
 
 
-	render: function ( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
+	render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
 
 
 		this.uniforms[ 'tDiffuse' ].value = readBuffer.texture;
 		this.uniforms[ 'tDiffuse' ].value = readBuffer.texture;
 		this.uniforms[ 'seed' ].value = Math.random();//default seeding
 		this.uniforms[ 'seed' ].value = Math.random();//default seeding
@@ -89,22 +84,22 @@ GlitchPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		}
 		}
 
 
-	},
+	}
 
 
-	generateTrigger: function () {
+	generateTrigger() {
 
 
 		this.randX = MathUtils.randInt( 120, 240 );
 		this.randX = MathUtils.randInt( 120, 240 );
 
 
-	},
+	}
 
 
-	generateHeightmap: function ( dt_size ) {
+	generateHeightmap( dt_size ) {
 
 
-		var data_arr = new Float32Array( dt_size * dt_size * 3 );
-		var length = dt_size * dt_size;
+		const data_arr = new Float32Array( dt_size * dt_size * 3 );
+		const length = dt_size * dt_size;
 
 
-		for ( var i = 0; i < length; i ++ ) {
+		for ( let i = 0; i < length; i ++ ) {
 
 
-			var val = MathUtils.randFloat( 0, 1 );
+			const val = MathUtils.randFloat( 0, 1 );
 			data_arr[ i * 3 + 0 ] = val;
 			data_arr[ i * 3 + 0 ] = val;
 			data_arr[ i * 3 + 1 ] = val;
 			data_arr[ i * 3 + 1 ] = val;
 			data_arr[ i * 3 + 2 ] = val;
 			data_arr[ i * 3 + 2 ] = val;
@@ -115,6 +110,6 @@ GlitchPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 	}
 	}
 
 
-} );
+}
 
 
 export { GlitchPass };
 export { GlitchPass };

+ 28 - 29
examples/jsm/postprocessing/HalftonePass.js

@@ -2,53 +2,51 @@ import {
 	ShaderMaterial,
 	ShaderMaterial,
 	UniformsUtils
 	UniformsUtils
 } from '../../../build/three.module.js';
 } from '../../../build/three.module.js';
-import { Pass } from '../postprocessing/Pass.js';
+import { Pass, FullScreenQuad } from '../postprocessing/Pass.js';
 import { HalftoneShader } from '../shaders/HalftoneShader.js';
 import { HalftoneShader } from '../shaders/HalftoneShader.js';
 
 
 /**
 /**
  * RGB Halftone pass for three.js effects composer. Requires HalftoneShader.
  * RGB Halftone pass for three.js effects composer. Requires HalftoneShader.
  */
  */
 
 
-var HalftonePass = function ( width, height, params ) {
+class HalftonePass extends Pass {
 
 
-	Pass.call( this );
+	constructor( width, height, params ) {
 
 
- 	if ( HalftoneShader === undefined ) {
+		super();
 
 
- 		console.error( 'THREE.HalftonePass requires HalftoneShader' );
+	 	if ( HalftoneShader === undefined ) {
 
 
- 	}
-
- 	this.uniforms = UniformsUtils.clone( HalftoneShader.uniforms );
- 	this.material = new ShaderMaterial( {
- 		uniforms: this.uniforms,
- 		fragmentShader: HalftoneShader.fragmentShader,
- 		vertexShader: HalftoneShader.vertexShader
- 	} );
+	 		console.error( 'THREE.HalftonePass requires HalftoneShader' );
 
 
-	// set params
-	this.uniforms.width.value = width;
-	this.uniforms.height.value = height;
+	 	}
 
 
-	for ( var key in params ) {
+	 	this.uniforms = UniformsUtils.clone( HalftoneShader.uniforms );
+	 	this.material = new ShaderMaterial( {
+	 		uniforms: this.uniforms,
+	 		fragmentShader: HalftoneShader.fragmentShader,
+	 		vertexShader: HalftoneShader.vertexShader
+	 	} );
 
 
-		if ( params.hasOwnProperty( key ) && this.uniforms.hasOwnProperty( key ) ) {
+		// set params
+		this.uniforms.width.value = width;
+		this.uniforms.height.value = height;
 
 
-			this.uniforms[ key ].value = params[ key ];
+		for ( const key in params ) {
 
 
-		}
+			if ( params.hasOwnProperty( key ) && this.uniforms.hasOwnProperty( key ) ) {
 
 
-	}
+				this.uniforms[ key ].value = params[ key ];
 
 
-	this.fsQuad = new Pass.FullScreenQuad( this.material );
+			}
 
 
-};
+		}
 
 
-HalftonePass.prototype = Object.assign( Object.create( Pass.prototype ), {
+		this.fsQuad = new FullScreenQuad( this.material );
 
 
-	constructor: HalftonePass,
+	}
 
 
-	render: function ( renderer, writeBuffer, readBuffer/*, deltaTime, maskActive*/ ) {
+	render( renderer, writeBuffer, readBuffer/*, deltaTime, maskActive*/ ) {
 
 
  		this.material.uniforms[ 'tDiffuse' ].value = readBuffer.texture;
  		this.material.uniforms[ 'tDiffuse' ].value = readBuffer.texture;
 
 
@@ -65,14 +63,15 @@ HalftonePass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		}
 		}
 
 
- 	},
+ 	}
 
 
- 	setSize: function ( width, height ) {
+ 	setSize( width, height ) {
 
 
  		this.uniforms.width.value = width;
  		this.uniforms.width.value = width;
  		this.uniforms.height.value = height;
  		this.uniforms.height.value = height;
 
 
  	}
  	}
-} );
+
+}
 
 
 export { HalftonePass };
 export { HalftonePass };

+ 21 - 26
examples/jsm/postprocessing/MaskPass.js

@@ -1,27 +1,25 @@
 import { Pass } from '../postprocessing/Pass.js';
 import { Pass } from '../postprocessing/Pass.js';
 
 
-var MaskPass = function ( scene, camera ) {
+class MaskPass extends Pass {
 
 
-	Pass.call( this );
+	constructor( scene, camera ) {
 
 
-	this.scene = scene;
-	this.camera = camera;
+		super();
 
 
-	this.clear = true;
-	this.needsSwap = false;
+		this.scene = scene;
+		this.camera = camera;
 
 
-	this.inverse = false;
+		this.clear = true;
+		this.needsSwap = false;
 
 
-};
+		this.inverse = false;
 
 
-MaskPass.prototype = Object.assign( Object.create( Pass.prototype ), {
-
-	constructor: MaskPass,
+	}
 
 
-	render: function ( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
+	render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
 
 
-		var context = renderer.getContext();
-		var state = renderer.state;
+		const context = renderer.getContext();
+		const state = renderer.state;
 
 
 		// don't update color or depth
 		// don't update color or depth
 
 
@@ -35,7 +33,7 @@ MaskPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		// set up stencil
 		// set up stencil
 
 
-		var writeValue, clearValue;
+		let writeValue, clearValue;
 
 
 		if ( this.inverse ) {
 		if ( this.inverse ) {
 
 
@@ -79,28 +77,25 @@ MaskPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 	}
 	}
 
 
-} );
-
+}
 
 
-var ClearMaskPass = function () {
+class ClearMaskPass extends Pass {
 
 
-	Pass.call( this );
+	constructor() {
 
 
-	this.needsSwap = false;
+		super();
 
 
-};
+		this.needsSwap = false;
 
 
-ClearMaskPass.prototype = Object.create( Pass.prototype );
-
-Object.assign( ClearMaskPass.prototype, {
+	}
 
 
-	render: function ( renderer /*, writeBuffer, readBuffer, deltaTime, maskActive */ ) {
+	render( renderer /*, writeBuffer, readBuffer, deltaTime, maskActive */ ) {
 
 
 		renderer.state.buffers.stencil.setLocked( false );
 		renderer.state.buffers.stencil.setLocked( false );
 		renderer.state.buffers.stencil.setTest( false );
 		renderer.state.buffers.stencil.setTest( false );
 
 
 	}
 	}
 
 
-} );
+}
 
 
 export { MaskPass, ClearMaskPass };
 export { MaskPass, ClearMaskPass };

+ 243 - 241
examples/jsm/postprocessing/OutlinePass.js

@@ -15,131 +15,129 @@ import {
 	Vector3,
 	Vector3,
 	WebGLRenderTarget
 	WebGLRenderTarget
 } from '../../../build/three.module.js';
 } from '../../../build/three.module.js';
-import { Pass } from '../postprocessing/Pass.js';
+import { Pass, FullScreenQuad } from '../postprocessing/Pass.js';
 import { CopyShader } from '../shaders/CopyShader.js';
 import { CopyShader } from '../shaders/CopyShader.js';
 
 
-var OutlinePass = function ( resolution, scene, camera, selectedObjects ) {
-
-	this.renderScene = scene;
-	this.renderCamera = camera;
-	this.selectedObjects = selectedObjects !== undefined ? selectedObjects : [];
-	this.visibleEdgeColor = new Color( 1, 1, 1 );
-	this.hiddenEdgeColor = new Color( 0.1, 0.04, 0.02 );
-	this.edgeGlow = 0.0;
-	this.usePatternTexture = false;
-	this.edgeThickness = 1.0;
-	this.edgeStrength = 3.0;
-	this.downSampleRatio = 2;
-	this.pulsePeriod = 0;
+class OutlinePass extends Pass {
 
 
-	this._visibilityCache = new Map();
+	constructor( resolution, scene, camera, selectedObjects ) {
 
 
-	Pass.call( this );
+		super();
 
 
-	this.resolution = ( resolution !== undefined ) ? new Vector2( resolution.x, resolution.y ) : new Vector2( 256, 256 );
+		this.renderScene = scene;
+		this.renderCamera = camera;
+		this.selectedObjects = selectedObjects !== undefined ? selectedObjects : [];
+		this.visibleEdgeColor = new Color( 1, 1, 1 );
+		this.hiddenEdgeColor = new Color( 0.1, 0.04, 0.02 );
+		this.edgeGlow = 0.0;
+		this.usePatternTexture = false;
+		this.edgeThickness = 1.0;
+		this.edgeStrength = 3.0;
+		this.downSampleRatio = 2;
+		this.pulsePeriod = 0;
 
 
-	var pars = { minFilter: LinearFilter, magFilter: LinearFilter, format: RGBAFormat };
+		this._visibilityCache = new Map();
 
 
-	var resx = Math.round( this.resolution.x / this.downSampleRatio );
-	var resy = Math.round( this.resolution.y / this.downSampleRatio );
 
 
-	this.maskBufferMaterial = new MeshBasicMaterial( { color: 0xffffff } );
-	this.maskBufferMaterial.side = DoubleSide;
-	this.renderTargetMaskBuffer = new WebGLRenderTarget( this.resolution.x, this.resolution.y, pars );
-	this.renderTargetMaskBuffer.texture.name = 'OutlinePass.mask';
-	this.renderTargetMaskBuffer.texture.generateMipmaps = false;
+		this.resolution = ( resolution !== undefined ) ? new Vector2( resolution.x, resolution.y ) : new Vector2( 256, 256 );
 
 
-	this.depthMaterial = new MeshDepthMaterial();
-	this.depthMaterial.side = DoubleSide;
-	this.depthMaterial.depthPacking = RGBADepthPacking;
-	this.depthMaterial.blending = NoBlending;
+		const pars = { minFilter: LinearFilter, magFilter: LinearFilter, format: RGBAFormat };
 
 
-	this.prepareMaskMaterial = this.getPrepareMaskMaterial();
-	this.prepareMaskMaterial.side = DoubleSide;
-	this.prepareMaskMaterial.fragmentShader = replaceDepthToViewZ( this.prepareMaskMaterial.fragmentShader, this.renderCamera );
+		const resx = Math.round( this.resolution.x / this.downSampleRatio );
+		const resy = Math.round( this.resolution.y / this.downSampleRatio );
 
 
-	this.renderTargetDepthBuffer = new WebGLRenderTarget( this.resolution.x, this.resolution.y, pars );
-	this.renderTargetDepthBuffer.texture.name = 'OutlinePass.depth';
-	this.renderTargetDepthBuffer.texture.generateMipmaps = false;
+		this.maskBufferMaterial = new MeshBasicMaterial( { color: 0xffffff } );
+		this.maskBufferMaterial.side = DoubleSide;
+		this.renderTargetMaskBuffer = new WebGLRenderTarget( this.resolution.x, this.resolution.y, pars );
+		this.renderTargetMaskBuffer.texture.name = 'OutlinePass.mask';
+		this.renderTargetMaskBuffer.texture.generateMipmaps = false;
 
 
-	this.renderTargetMaskDownSampleBuffer = new WebGLRenderTarget( resx, resy, pars );
-	this.renderTargetMaskDownSampleBuffer.texture.name = 'OutlinePass.depthDownSample';
-	this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps = false;
+		this.depthMaterial = new MeshDepthMaterial();
+		this.depthMaterial.side = DoubleSide;
+		this.depthMaterial.depthPacking = RGBADepthPacking;
+		this.depthMaterial.blending = NoBlending;
 
 
-	this.renderTargetBlurBuffer1 = new WebGLRenderTarget( resx, resy, pars );
-	this.renderTargetBlurBuffer1.texture.name = 'OutlinePass.blur1';
-	this.renderTargetBlurBuffer1.texture.generateMipmaps = false;
-	this.renderTargetBlurBuffer2 = new WebGLRenderTarget( Math.round( resx / 2 ), Math.round( resy / 2 ), pars );
-	this.renderTargetBlurBuffer2.texture.name = 'OutlinePass.blur2';
-	this.renderTargetBlurBuffer2.texture.generateMipmaps = false;
+		this.prepareMaskMaterial = this.getPrepareMaskMaterial();
+		this.prepareMaskMaterial.side = DoubleSide;
+		this.prepareMaskMaterial.fragmentShader = replaceDepthToViewZ( this.prepareMaskMaterial.fragmentShader, this.renderCamera );
 
 
-	this.edgeDetectionMaterial = this.getEdgeDetectionMaterial();
-	this.renderTargetEdgeBuffer1 = new WebGLRenderTarget( resx, resy, pars );
-	this.renderTargetEdgeBuffer1.texture.name = 'OutlinePass.edge1';
-	this.renderTargetEdgeBuffer1.texture.generateMipmaps = false;
-	this.renderTargetEdgeBuffer2 = new WebGLRenderTarget( Math.round( resx / 2 ), Math.round( resy / 2 ), pars );
-	this.renderTargetEdgeBuffer2.texture.name = 'OutlinePass.edge2';
-	this.renderTargetEdgeBuffer2.texture.generateMipmaps = false;
+		this.renderTargetDepthBuffer = new WebGLRenderTarget( this.resolution.x, this.resolution.y, pars );
+		this.renderTargetDepthBuffer.texture.name = 'OutlinePass.depth';
+		this.renderTargetDepthBuffer.texture.generateMipmaps = false;
 
 
-	var MAX_EDGE_THICKNESS = 4;
-	var MAX_EDGE_GLOW = 4;
+		this.renderTargetMaskDownSampleBuffer = new WebGLRenderTarget( resx, resy, pars );
+		this.renderTargetMaskDownSampleBuffer.texture.name = 'OutlinePass.depthDownSample';
+		this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps = false;
 
 
-	this.separableBlurMaterial1 = this.getSeperableBlurMaterial( MAX_EDGE_THICKNESS );
-	this.separableBlurMaterial1.uniforms[ 'texSize' ].value.set( resx, resy );
-	this.separableBlurMaterial1.uniforms[ 'kernelRadius' ].value = 1;
-	this.separableBlurMaterial2 = this.getSeperableBlurMaterial( MAX_EDGE_GLOW );
-	this.separableBlurMaterial2.uniforms[ 'texSize' ].value.set( Math.round( resx / 2 ), Math.round( resy / 2 ) );
-	this.separableBlurMaterial2.uniforms[ 'kernelRadius' ].value = MAX_EDGE_GLOW;
+		this.renderTargetBlurBuffer1 = new WebGLRenderTarget( resx, resy, pars );
+		this.renderTargetBlurBuffer1.texture.name = 'OutlinePass.blur1';
+		this.renderTargetBlurBuffer1.texture.generateMipmaps = false;
+		this.renderTargetBlurBuffer2 = new WebGLRenderTarget( Math.round( resx / 2 ), Math.round( resy / 2 ), pars );
+		this.renderTargetBlurBuffer2.texture.name = 'OutlinePass.blur2';
+		this.renderTargetBlurBuffer2.texture.generateMipmaps = false;
 
 
-	// Overlay material
-	this.overlayMaterial = this.getOverlayMaterial();
+		this.edgeDetectionMaterial = this.getEdgeDetectionMaterial();
+		this.renderTargetEdgeBuffer1 = new WebGLRenderTarget( resx, resy, pars );
+		this.renderTargetEdgeBuffer1.texture.name = 'OutlinePass.edge1';
+		this.renderTargetEdgeBuffer1.texture.generateMipmaps = false;
+		this.renderTargetEdgeBuffer2 = new WebGLRenderTarget( Math.round( resx / 2 ), Math.round( resy / 2 ), pars );
+		this.renderTargetEdgeBuffer2.texture.name = 'OutlinePass.edge2';
+		this.renderTargetEdgeBuffer2.texture.generateMipmaps = false;
 
 
-	// copy material
-	if ( CopyShader === undefined )
-		console.error( 'THREE.OutlinePass relies on CopyShader' );
+		const MAX_EDGE_THICKNESS = 4;
+		const MAX_EDGE_GLOW = 4;
 
 
-	var copyShader = CopyShader;
+		this.separableBlurMaterial1 = this.getSeperableBlurMaterial( MAX_EDGE_THICKNESS );
+		this.separableBlurMaterial1.uniforms[ 'texSize' ].value.set( resx, resy );
+		this.separableBlurMaterial1.uniforms[ 'kernelRadius' ].value = 1;
+		this.separableBlurMaterial2 = this.getSeperableBlurMaterial( MAX_EDGE_GLOW );
+		this.separableBlurMaterial2.uniforms[ 'texSize' ].value.set( Math.round( resx / 2 ), Math.round( resy / 2 ) );
+		this.separableBlurMaterial2.uniforms[ 'kernelRadius' ].value = MAX_EDGE_GLOW;
 
 
-	this.copyUniforms = UniformsUtils.clone( copyShader.uniforms );
-	this.copyUniforms[ 'opacity' ].value = 1.0;
+		// Overlay material
+		this.overlayMaterial = this.getOverlayMaterial();
 
 
-	this.materialCopy = new ShaderMaterial( {
-		uniforms: this.copyUniforms,
-		vertexShader: copyShader.vertexShader,
-		fragmentShader: copyShader.fragmentShader,
-		blending: NoBlending,
-		depthTest: false,
-		depthWrite: false,
-		transparent: true
-	} );
+		// copy material
+		if ( CopyShader === undefined ) console.error( 'THREE.OutlinePass relies on CopyShader' );
 
 
-	this.enabled = true;
-	this.needsSwap = false;
+		const copyShader = CopyShader;
 
 
-	this._oldClearColor = new Color();
-	this.oldClearAlpha = 1;
+		this.copyUniforms = UniformsUtils.clone( copyShader.uniforms );
+		this.copyUniforms[ 'opacity' ].value = 1.0;
 
 
-	this.fsQuad = new Pass.FullScreenQuad( null );
+		this.materialCopy = new ShaderMaterial( {
+			uniforms: this.copyUniforms,
+			vertexShader: copyShader.vertexShader,
+			fragmentShader: copyShader.fragmentShader,
+			blending: NoBlending,
+			depthTest: false,
+			depthWrite: false,
+			transparent: true
+		} );
 
 
-	this.tempPulseColor1 = new Color();
-	this.tempPulseColor2 = new Color();
-	this.textureMatrix = new Matrix4();
+		this.enabled = true;
+		this.needsSwap = false;
 
 
-	function replaceDepthToViewZ( string, camera ) {
+		this._oldClearColor = new Color();
+		this.oldClearAlpha = 1;
 
 
-		var type = camera.isPerspectiveCamera ? 'perspective' : 'orthographic';
+		this.fsQuad = new FullScreenQuad( null );
 
 
-		return string.replace( /DEPTH_TO_VIEW_Z/g, type + 'DepthToViewZ' );
+		this.tempPulseColor1 = new Color();
+		this.tempPulseColor2 = new Color();
+		this.textureMatrix = new Matrix4();
 
 
-	}
+		function replaceDepthToViewZ( string, camera ) {
 
 
-};
+			var type = camera.isPerspectiveCamera ? 'perspective' : 'orthographic';
 
 
-OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), {
+			return string.replace( /DEPTH_TO_VIEW_Z/g, type + 'DepthToViewZ' );
 
 
-	constructor: OutlinePass,
+		}
 
 
-	dispose: function () {
+	}
+
+	dispose() {
 
 
 		this.renderTargetMaskBuffer.dispose();
 		this.renderTargetMaskBuffer.dispose();
 		this.renderTargetDepthBuffer.dispose();
 		this.renderTargetDepthBuffer.dispose();
@@ -149,15 +147,15 @@ OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), {
 		this.renderTargetEdgeBuffer1.dispose();
 		this.renderTargetEdgeBuffer1.dispose();
 		this.renderTargetEdgeBuffer2.dispose();
 		this.renderTargetEdgeBuffer2.dispose();
 
 
-	},
+	}
 
 
-	setSize: function ( width, height ) {
+	setSize( width, height ) {
 
 
 		this.renderTargetMaskBuffer.setSize( width, height );
 		this.renderTargetMaskBuffer.setSize( width, height );
 		this.renderTargetDepthBuffer.setSize( width, height );
 		this.renderTargetDepthBuffer.setSize( width, height );
 
 
-		var resx = Math.round( width / this.downSampleRatio );
-		var resy = Math.round( height / this.downSampleRatio );
+		let resx = Math.round( width / this.downSampleRatio );
+		let resy = Math.round( height / this.downSampleRatio );
 		this.renderTargetMaskDownSampleBuffer.setSize( resx, resy );
 		this.renderTargetMaskDownSampleBuffer.setSize( resx, resy );
 		this.renderTargetBlurBuffer1.setSize( resx, resy );
 		this.renderTargetBlurBuffer1.setSize( resx, resy );
 		this.renderTargetEdgeBuffer1.setSize( resx, resy );
 		this.renderTargetEdgeBuffer1.setSize( resx, resy );
@@ -171,11 +169,11 @@ OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		this.separableBlurMaterial2.uniforms[ 'texSize' ].value.set( resx, resy );
 		this.separableBlurMaterial2.uniforms[ 'texSize' ].value.set( resx, resy );
 
 
-	},
+	}
 
 
-	changeVisibilityOfSelectedObjects: function ( bVisible ) {
+	changeVisibilityOfSelectedObjects( bVisible ) {
 
 
-		var cache = this._visibilityCache;
+		const cache = this._visibilityCache;
 
 
 		function gatherSelectedMeshesCallBack( object ) {
 		function gatherSelectedMeshesCallBack( object ) {
 
 
@@ -196,19 +194,19 @@ OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		}
 		}
 
 
-		for ( var i = 0; i < this.selectedObjects.length; i ++ ) {
+		for ( let i = 0; i < this.selectedObjects.length; i ++ ) {
 
 
-			var selectedObject = this.selectedObjects[ i ];
+			const selectedObject = this.selectedObjects[ i ];
 			selectedObject.traverse( gatherSelectedMeshesCallBack );
 			selectedObject.traverse( gatherSelectedMeshesCallBack );
 
 
 		}
 		}
 
 
-	},
+	}
 
 
-	changeVisibilityOfNonSelectedObjects: function ( bVisible ) {
+	changeVisibilityOfNonSelectedObjects( bVisible ) {
 
 
-		var cache = this._visibilityCache;
-		var selectedMeshes = [];
+		const cache = this._visibilityCache;
+		const selectedMeshes = [];
 
 
 		function gatherSelectedMeshesCallBack( object ) {
 		function gatherSelectedMeshesCallBack( object ) {
 
 
@@ -216,9 +214,9 @@ OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		}
 		}
 
 
-		for ( var i = 0; i < this.selectedObjects.length; i ++ ) {
+		for ( let i = 0; i < this.selectedObjects.length; i ++ ) {
 
 
-			var selectedObject = this.selectedObjects[ i ];
+			const selectedObject = this.selectedObjects[ i ];
 			selectedObject.traverse( gatherSelectedMeshesCallBack );
 			selectedObject.traverse( gatherSelectedMeshesCallBack );
 
 
 		}
 		}
@@ -229,11 +227,11 @@ OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 				// only meshes and sprites are supported by OutlinePass
 				// only meshes and sprites are supported by OutlinePass
 
 
-				var bFound = false;
+				let bFound = false;
 
 
-				for ( var i = 0; i < selectedMeshes.length; i ++ ) {
+				for ( let i = 0; i < selectedMeshes.length; i ++ ) {
 
 
-					var selectedObjectId = selectedMeshes[ i ].id;
+					const selectedObjectId = selectedMeshes[ i ].id;
 
 
 					if ( selectedObjectId === object.id ) {
 					if ( selectedObjectId === object.id ) {
 
 
@@ -246,7 +244,7 @@ OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 				if ( bFound === false ) {
 				if ( bFound === false ) {
 
 
-					var visibility = object.visible;
+					const visibility = object.visible;
 
 
 					if ( bVisible === false || cache.get( object ) === true ) {
 					if ( bVisible === false || cache.get( object ) === true ) {
 
 
@@ -280,9 +278,9 @@ OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		this.renderScene.traverse( VisibilityChangeCallBack );
 		this.renderScene.traverse( VisibilityChangeCallBack );
 
 
-	},
+	}
 
 
-	updateTextureMatrix: function () {
+	updateTextureMatrix() {
 
 
 		this.textureMatrix.set( 0.5, 0.0, 0.0, 0.5,
 		this.textureMatrix.set( 0.5, 0.0, 0.0, 0.5,
 			0.0, 0.5, 0.0, 0.5,
 			0.0, 0.5, 0.0, 0.5,
@@ -291,15 +289,15 @@ OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), {
 		this.textureMatrix.multiply( this.renderCamera.projectionMatrix );
 		this.textureMatrix.multiply( this.renderCamera.projectionMatrix );
 		this.textureMatrix.multiply( this.renderCamera.matrixWorldInverse );
 		this.textureMatrix.multiply( this.renderCamera.matrixWorldInverse );
 
 
-	},
+	}
 
 
-	render: function ( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {
+	render( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {
 
 
 		if ( this.selectedObjects.length > 0 ) {
 		if ( this.selectedObjects.length > 0 ) {
 
 
 			renderer.getClearColor( this._oldClearColor );
 			renderer.getClearColor( this._oldClearColor );
 			this.oldClearAlpha = renderer.getClearAlpha();
 			this.oldClearAlpha = renderer.getClearAlpha();
-			var oldAutoClear = renderer.autoClear;
+			const oldAutoClear = renderer.autoClear;
 
 
 			renderer.autoClear = false;
 			renderer.autoClear = false;
 
 
@@ -310,7 +308,7 @@ OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), {
 			// Make selected objects invisible
 			// Make selected objects invisible
 			this.changeVisibilityOfSelectedObjects( false );
 			this.changeVisibilityOfSelectedObjects( false );
 
 
-			var currentBackground = this.renderScene.background;
+			const currentBackground = this.renderScene.background;
 			this.renderScene.background = null;
 			this.renderScene.background = null;
 
 
 			// 1. Draw Non Selected objects in the depth buffer
 			// 1. Draw Non Selected objects in the depth buffer
@@ -353,7 +351,7 @@ OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 			if ( this.pulsePeriod > 0 ) {
 			if ( this.pulsePeriod > 0 ) {
 
 
-				var scalar = ( 1 + 0.25 ) / 2 + Math.cos( performance.now() * 0.01 / this.pulsePeriod ) * ( 1.0 - 0.25 ) / 2;
+				const scalar = ( 1 + 0.25 ) / 2 + Math.cos( performance.now() * 0.01 / this.pulsePeriod ) * ( 1.0 - 0.25 ) / 2;
 				this.tempPulseColor1.multiplyScalar( scalar );
 				this.tempPulseColor1.multiplyScalar( scalar );
 				this.tempPulseColor2.multiplyScalar( scalar );
 				this.tempPulseColor2.multiplyScalar( scalar );
 
 
@@ -426,9 +424,9 @@ OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		}
 		}
 
 
-	},
+	}
 
 
-	getPrepareMaskMaterial: function () {
+	getPrepareMaskMaterial() {
 
 
 		return new ShaderMaterial( {
 		return new ShaderMaterial( {
 
 
@@ -438,51 +436,49 @@ OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), {
 				'textureMatrix': { value: null }
 				'textureMatrix': { value: null }
 			},
 			},
 
 
-			vertexShader: [
-				'#include <morphtarget_pars_vertex>',
-				'#include <skinning_pars_vertex>',
+			vertexShader:
+				`#include <morphtarget_pars_vertex>
+				#include <skinning_pars_vertex>
 
 
-				'varying vec4 projTexCoord;',
-				'varying vec4 vPosition;',
-				'uniform mat4 textureMatrix;',
+				varying vec4 projTexCoord;
+				varying vec4 vPosition;
+				uniform mat4 textureMatrix;
 
 
-				'void main() {',
+				void main() {
 
 
-				'	#include <skinbase_vertex>',
-				'	#include <begin_vertex>',
-				'	#include <morphtarget_vertex>',
-				'	#include <skinning_vertex>',
-				'	#include <project_vertex>',
+					#include <skinbase_vertex>
+					#include <begin_vertex>
+					#include <morphtarget_vertex>
+					#include <skinning_vertex>
+					#include <project_vertex>
 
 
-				'	vPosition = mvPosition;',
-				'	vec4 worldPosition = modelMatrix * vec4( position, 1.0 );',
-				'	projTexCoord = textureMatrix * worldPosition;',
+					vPosition = mvPosition;
+					vec4 worldPosition = modelMatrix * vec4( position, 1.0 );
+					projTexCoord = textureMatrix * worldPosition;
 
 
-				'}'
-			].join( '\n' ),
+				}`,
 
 
-			fragmentShader: [
-				'#include <packing>',
-				'varying vec4 vPosition;',
-				'varying vec4 projTexCoord;',
-				'uniform sampler2D depthTexture;',
-				'uniform vec2 cameraNearFar;',
+			fragmentShader:
+				`#include <packing>
+				varying vec4 vPosition;
+				varying vec4 projTexCoord;
+				uniform sampler2D depthTexture;
+				uniform vec2 cameraNearFar;
 
 
-				'void main() {',
+				void main() {
 
 
-				'	float depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));',
-				'	float viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );',
-				'	float depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;',
-				'	gl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);',
+					float depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));
+					float viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );
+					float depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;
+					gl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);
 
 
-				'}'
-			].join( '\n' )
+				}`
 
 
 		} );
 		} );
 
 
-	},
+	}
 
 
-	getEdgeDetectionMaterial: function () {
+	getEdgeDetectionMaterial() {
 
 
 		return new ShaderMaterial( {
 		return new ShaderMaterial( {
 
 
@@ -494,40 +490,42 @@ OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), {
 			},
 			},
 
 
 			vertexShader:
 			vertexShader:
-				'varying vec2 vUv;\n\
-				void main() {\n\
-					vUv = uv;\n\
-					gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\
-				}',
+				`varying vec2 vUv;
+
+				void main() {
+					vUv = uv;
+					gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+				}`,
 
 
 			fragmentShader:
 			fragmentShader:
-				'varying vec2 vUv;\
-				uniform sampler2D maskTexture;\
-				uniform vec2 texSize;\
-				uniform vec3 visibleEdgeColor;\
-				uniform vec3 hiddenEdgeColor;\
-				\
-				void main() {\n\
-					vec2 invSize = 1.0 / texSize;\
-					vec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\
-					vec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\
-					vec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\
-					vec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\
-					vec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\
-					float diff1 = (c1.r - c2.r)*0.5;\
-					float diff2 = (c3.r - c4.r)*0.5;\
-					float d = length( vec2(diff1, diff2) );\
-					float a1 = min(c1.g, c2.g);\
-					float a2 = min(c3.g, c4.g);\
-					float visibilityFactor = min(a1, a2);\
-					vec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\
-					gl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\
-				}'
+				`varying vec2 vUv;
+
+				uniform sampler2D maskTexture;
+				uniform vec2 texSize;
+				uniform vec3 visibleEdgeColor;
+				uniform vec3 hiddenEdgeColor;
+
+				void main() {
+					vec2 invSize = 1.0 / texSize;
+					vec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);
+					vec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);
+					vec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);
+					vec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);
+					vec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);
+					float diff1 = (c1.r - c2.r)*0.5;
+					float diff2 = (c3.r - c4.r)*0.5;
+					float d = length( vec2(diff1, diff2) );
+					float a1 = min(c1.g, c2.g);
+					float a2 = min(c3.g, c4.g);
+					float visibilityFactor = min(a1, a2);
+					vec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;
+					gl_FragColor = vec4(edgeColor, 1.0) * vec4(d);
+				}`
 		} );
 		} );
 
 
-	},
+	}
 
 
-	getSeperableBlurMaterial: function ( maxRadius ) {
+	getSeperableBlurMaterial( maxRadius ) {
 
 
 		return new ShaderMaterial( {
 		return new ShaderMaterial( {
 
 
@@ -543,44 +541,46 @@ OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), {
 			},
 			},
 
 
 			vertexShader:
 			vertexShader:
-				'varying vec2 vUv;\n\
-				void main() {\n\
-					vUv = uv;\n\
-					gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\
-				}',
+				`varying vec2 vUv;
+
+				void main() {
+					vUv = uv;
+					gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+				}`,
 
 
 			fragmentShader:
 			fragmentShader:
-				'#include <common>\
-				varying vec2 vUv;\
-				uniform sampler2D colorTexture;\
-				uniform vec2 texSize;\
-				uniform vec2 direction;\
-				uniform float kernelRadius;\
-				\
-				float gaussianPdf(in float x, in float sigma) {\
-					return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\
-				}\
-				void main() {\
-					vec2 invSize = 1.0 / texSize;\
-					float weightSum = gaussianPdf(0.0, kernelRadius);\
-					vec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;\
-					vec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\
-					vec2 uvOffset = delta;\
-					for( int i = 1; i <= MAX_RADIUS; i ++ ) {\
-						float w = gaussianPdf(uvOffset.x, kernelRadius);\
-						vec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\
-						vec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\
-						diffuseSum += ((sample1 + sample2) * w);\
-						weightSum += (2.0 * w);\
-						uvOffset += delta;\
-					}\
-					gl_FragColor = diffuseSum/weightSum;\
-				}'
+				`#include <common>
+				varying vec2 vUv;
+				uniform sampler2D colorTexture;
+				uniform vec2 texSize;
+				uniform vec2 direction;
+				uniform float kernelRadius;
+
+				float gaussianPdf(in float x, in float sigma) {
+					return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;
+				}
+
+				void main() {
+					vec2 invSize = 1.0 / texSize;
+					float weightSum = gaussianPdf(0.0, kernelRadius);
+					vec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;
+					vec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);
+					vec2 uvOffset = delta;
+					for( int i = 1; i <= MAX_RADIUS; i ++ ) {
+						float w = gaussianPdf(uvOffset.x, kernelRadius);
+						vec4 sample1 = texture2D( colorTexture, vUv + uvOffset);
+						vec4 sample2 = texture2D( colorTexture, vUv - uvOffset);
+						diffuseSum += ((sample1 + sample2) * w);
+						weightSum += (2.0 * w);
+						uvOffset += delta;
+					}
+					gl_FragColor = diffuseSum/weightSum;
+				}`
 		} );
 		} );
 
 
-	},
+	}
 
 
-	getOverlayMaterial: function () {
+	getOverlayMaterial() {
 
 
 		return new ShaderMaterial( {
 		return new ShaderMaterial( {
 
 
@@ -595,34 +595,36 @@ OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), {
 			},
 			},
 
 
 			vertexShader:
 			vertexShader:
-				'varying vec2 vUv;\n\
-				void main() {\n\
-					vUv = uv;\n\
-					gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\
-				}',
+				`varying vec2 vUv;
+
+				void main() {
+					vUv = uv;
+					gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+				}`,
 
 
 			fragmentShader:
 			fragmentShader:
-				'varying vec2 vUv;\
-				uniform sampler2D maskTexture;\
-				uniform sampler2D edgeTexture1;\
-				uniform sampler2D edgeTexture2;\
-				uniform sampler2D patternTexture;\
-				uniform float edgeStrength;\
-				uniform float edgeGlow;\
-				uniform bool usePatternTexture;\
-				\
-				void main() {\
-					vec4 edgeValue1 = texture2D(edgeTexture1, vUv);\
-					vec4 edgeValue2 = texture2D(edgeTexture2, vUv);\
-					vec4 maskColor = texture2D(maskTexture, vUv);\
-					vec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\
-					float visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\
-					vec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\
-					vec4 finalColor = edgeStrength * maskColor.r * edgeValue;\
-					if(usePatternTexture)\
-						finalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\
-					gl_FragColor = finalColor;\
-				}',
+				`varying vec2 vUv;
+
+				uniform sampler2D maskTexture;
+				uniform sampler2D edgeTexture1;
+				uniform sampler2D edgeTexture2;
+				uniform sampler2D patternTexture;
+				uniform float edgeStrength;
+				uniform float edgeGlow;
+				uniform bool usePatternTexture;
+
+				void main() {
+					vec4 edgeValue1 = texture2D(edgeTexture1, vUv);
+					vec4 edgeValue2 = texture2D(edgeTexture2, vUv);
+					vec4 maskColor = texture2D(maskTexture, vUv);
+					vec4 patternColor = texture2D(patternTexture, 6.0 * vUv);
+					float visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;
+					vec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;
+					vec4 finalColor = edgeStrength * maskColor.r * edgeValue;
+					if(usePatternTexture)
+						finalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);
+					gl_FragColor = finalColor;
+				}`,
 			blending: AdditiveBlending,
 			blending: AdditiveBlending,
 			depthTest: false,
 			depthTest: false,
 			depthWrite: false,
 			depthWrite: false,
@@ -631,7 +633,7 @@ OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 	}
 	}
 
 
-} );
+}
 
 
 OutlinePass.BlurDirectionX = new Vector2( 1.0, 0.0 );
 OutlinePass.BlurDirectionX = new Vector2( 1.0, 0.0 );
 OutlinePass.BlurDirectionY = new Vector2( 0.0, 1.0 );
 OutlinePass.BlurDirectionY = new Vector2( 0.0, 1.0 );

+ 37 - 51
examples/jsm/postprocessing/Pass.js

@@ -5,90 +5,76 @@ import {
 	Mesh
 	Mesh
 } from '../../../build/three.module.js';
 } from '../../../build/three.module.js';
 
 
-function Pass() {
+class Pass {
 
 
-	// if set to true, the pass is processed by the composer
-	this.enabled = true;
+	constructor() {
 
 
-	// if set to true, the pass indicates to swap read and write buffer after rendering
-	this.needsSwap = true;
+		// if set to true, the pass is processed by the composer
+		this.enabled = true;
 
 
-	// if set to true, the pass clears its buffer before rendering
-	this.clear = false;
+		// if set to true, the pass indicates to swap read and write buffer after rendering
+		this.needsSwap = true;
 
 
-	// if set to true, the result of the pass is rendered to screen. This is set automatically by EffectComposer.
-	this.renderToScreen = false;
+		// if set to true, the pass clears its buffer before rendering
+		this.clear = false;
 
 
-}
+		// if set to true, the result of the pass is rendered to screen. This is set automatically by EffectComposer.
+		this.renderToScreen = false;
 
 
-Object.assign( Pass.prototype, {
+	}
 
 
-	setSize: function ( /* width, height */ ) {},
+	setSize( /* width, height */ ) {}
 
 
-	render: function ( /* renderer, writeBuffer, readBuffer, deltaTime, maskActive */ ) {
+	render( /* renderer, writeBuffer, readBuffer, deltaTime, maskActive */ ) {
 
 
 		console.error( 'THREE.Pass: .render() must be implemented in derived pass.' );
 		console.error( 'THREE.Pass: .render() must be implemented in derived pass.' );
 
 
 	}
 	}
 
 
-} );
+}
 
 
 // Helper for passes that need to fill the viewport with a single quad.
 // Helper for passes that need to fill the viewport with a single quad.
 
 
-// Important: It's actually a hack to put FullScreenQuad into the Pass namespace. This is only
-// done to make examples/js code work. Normally, FullScreenQuad should be exported
-// from this module like Pass.
-
-Pass.FullScreenQuad = ( function () {
-
-	var camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
-
-	// https://github.com/mrdoob/three.js/pull/21358
-
-	var geometry = new BufferGeometry();
-	geometry.setAttribute( 'position', new Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );
-	geometry.setAttribute( 'uv', new Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );
-
-	var FullScreenQuad = function ( material ) {
+const _camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
 
 
-		this._mesh = new Mesh( geometry, material );
+// https://github.com/mrdoob/three.js/pull/21358
 
 
-	};
+const _geometry = new BufferGeometry();
+_geometry.setAttribute( 'position', new Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );
+_geometry.setAttribute( 'uv', new Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );
 
 
-	Object.defineProperty( FullScreenQuad.prototype, 'material', {
+class FullScreenQuad {
 
 
-		get: function () {
+	constructor( material ) {
 
 
-			return this._mesh.material;
+		this._mesh = new Mesh( _geometry, material );
 
 
-		},
-
-		set: function ( value ) {
+	}
 
 
-			this._mesh.material = value;
+	dispose() {
 
 
-		}
+		this._mesh.geometry.dispose();
 
 
-	} );
+	}
 
 
-	Object.assign( FullScreenQuad.prototype, {
+	render( renderer ) {
 
 
-		dispose: function () {
+		renderer.render( this._mesh, _camera );
 
 
-			this._mesh.geometry.dispose();
+	}
 
 
-		},
+	get material() {
 
 
-		render: function ( renderer ) {
+		return this._mesh.material;
 
 
-			renderer.render( this._mesh, camera );
+	}
 
 
-		}
+	set material( value ) {
 
 
-	} );
+		this._mesh.material = value;
 
 
-	return FullScreenQuad;
+	}
 
 
-} )();
+}
 
 
-export { Pass };
+export { Pass, FullScreenQuad };

+ 17 - 19
examples/jsm/postprocessing/RenderPass.js

@@ -3,35 +3,33 @@ import {
 } from '../../../build/three.module.js';
 } from '../../../build/three.module.js';
 import { Pass } from '../postprocessing/Pass.js';
 import { Pass } from '../postprocessing/Pass.js';
 
 
-var RenderPass = function ( scene, camera, overrideMaterial, clearColor, clearAlpha ) {
+class RenderPass extends Pass {
 
 
-	Pass.call( this );
+	constructor( scene, camera, overrideMaterial, clearColor, clearAlpha ) {
 
 
-	this.scene = scene;
-	this.camera = camera;
+		super();
 
 
-	this.overrideMaterial = overrideMaterial;
+		this.scene = scene;
+		this.camera = camera;
 
 
-	this.clearColor = clearColor;
-	this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0;
+		this.overrideMaterial = overrideMaterial;
 
 
-	this.clear = true;
-	this.clearDepth = false;
-	this.needsSwap = false;
-	this._oldClearColor = new Color();
+		this.clearColor = clearColor;
+		this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0;
 
 
-};
+		this.clear = true;
+		this.clearDepth = false;
+		this.needsSwap = false;
+		this._oldClearColor = new Color();
 
 
-RenderPass.prototype = Object.assign( Object.create( Pass.prototype ), {
-
-	constructor: RenderPass,
+	}
 
 
-	render: function ( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
+	render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
 
 
-		var oldAutoClear = renderer.autoClear;
+		const oldAutoClear = renderer.autoClear;
 		renderer.autoClear = false;
 		renderer.autoClear = false;
 
 
-		var oldClearAlpha, oldOverrideMaterial;
+		let oldClearAlpha, oldOverrideMaterial;
 
 
 		if ( this.overrideMaterial !== undefined ) {
 		if ( this.overrideMaterial !== undefined ) {
 
 
@@ -78,6 +76,6 @@ RenderPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 	}
 	}
 
 
-} );
+}
 
 
 export { RenderPass };
 export { RenderPass };

+ 155 - 156
examples/jsm/postprocessing/SAOPass.js

@@ -19,7 +19,7 @@ import {
 	WebGLRenderTarget,
 	WebGLRenderTarget,
 	ZeroFactor
 	ZeroFactor
 } from '../../../build/three.module.js';
 } from '../../../build/three.module.js';
-import { Pass } from '../postprocessing/Pass.js';
+import { Pass, FullScreenQuad } from '../postprocessing/Pass.js';
 import { SAOShader } from '../shaders/SAOShader.js';
 import { SAOShader } from '../shaders/SAOShader.js';
 import { DepthLimitedBlurShader } from '../shaders/DepthLimitedBlurShader.js';
 import { DepthLimitedBlurShader } from '../shaders/DepthLimitedBlurShader.js';
 import { BlurShaderUtils } from '../shaders/DepthLimitedBlurShader.js';
 import { BlurShaderUtils } from '../shaders/DepthLimitedBlurShader.js';
@@ -30,177 +30,168 @@ import { UnpackDepthRGBAShader } from '../shaders/UnpackDepthRGBAShader.js';
  * SAO implementation inspired from bhouston previous SAO work
  * SAO implementation inspired from bhouston previous SAO work
  */
  */
 
 
-var SAOPass = function ( scene, camera, depthTexture, useNormals, resolution ) {
+class SAOPass extends Pass {
 
 
-	Pass.call( this );
+	constructor( scene, camera, depthTexture, useNormals, resolution ) {
 
 
-	this.scene = scene;
-	this.camera = camera;
+		super();
 
 
-	this.clear = true;
-	this.needsSwap = false;
+		this.scene = scene;
+		this.camera = camera;
 
 
-	this.supportsDepthTextureExtension = ( depthTexture !== undefined ) ? depthTexture : false;
-	this.supportsNormalTexture = ( useNormals !== undefined ) ? useNormals : false;
+		this.clear = true;
+		this.needsSwap = false;
 
 
-	this.originalClearColor = new Color();
-	this._oldClearColor = new Color();
-	this.oldClearAlpha = 1;
+		this.supportsDepthTextureExtension = ( depthTexture !== undefined ) ? depthTexture : false;
+		this.supportsNormalTexture = ( useNormals !== undefined ) ? useNormals : false;
 
 
-	this.params = {
-		output: 0,
-		saoBias: 0.5,
-		saoIntensity: 0.18,
-		saoScale: 1,
-		saoKernelRadius: 100,
-		saoMinResolution: 0,
-		saoBlur: true,
-		saoBlurRadius: 8,
-		saoBlurStdDev: 4,
-		saoBlurDepthCutoff: 0.01
-	};
+		this.originalClearColor = new Color();
+		this._oldClearColor = new Color();
+		this.oldClearAlpha = 1;
 
 
-	this.resolution = ( resolution !== undefined ) ? new Vector2( resolution.x, resolution.y ) : new Vector2( 256, 256 );
+		this.params = {
+			output: 0,
+			saoBias: 0.5,
+			saoIntensity: 0.18,
+			saoScale: 1,
+			saoKernelRadius: 100,
+			saoMinResolution: 0,
+			saoBlur: true,
+			saoBlurRadius: 8,
+			saoBlurStdDev: 4,
+			saoBlurDepthCutoff: 0.01
+		};
 
 
-	this.saoRenderTarget = new WebGLRenderTarget( this.resolution.x, this.resolution.y, {
-		minFilter: LinearFilter,
-		magFilter: LinearFilter,
-		format: RGBAFormat
-	} );
-	this.blurIntermediateRenderTarget = this.saoRenderTarget.clone();
-	this.beautyRenderTarget = this.saoRenderTarget.clone();
+		this.resolution = ( resolution !== undefined ) ? new Vector2( resolution.x, resolution.y ) : new Vector2( 256, 256 );
 
 
-	this.normalRenderTarget = new WebGLRenderTarget( this.resolution.x, this.resolution.y, {
-		minFilter: NearestFilter,
-		magFilter: NearestFilter,
-		format: RGBAFormat
-	} );
-	this.depthRenderTarget = this.normalRenderTarget.clone();
+		this.saoRenderTarget = new WebGLRenderTarget( this.resolution.x, this.resolution.y, {
+			minFilter: LinearFilter,
+			magFilter: LinearFilter,
+			format: RGBAFormat
+		} );
+		this.blurIntermediateRenderTarget = this.saoRenderTarget.clone();
+		this.beautyRenderTarget = this.saoRenderTarget.clone();
 
 
-	if ( this.supportsDepthTextureExtension ) {
+		this.normalRenderTarget = new WebGLRenderTarget( this.resolution.x, this.resolution.y, {
+			minFilter: NearestFilter,
+			magFilter: NearestFilter,
+			format: RGBAFormat
+		} );
+		this.depthRenderTarget = this.normalRenderTarget.clone();
 
 
-		var depthTexture = new DepthTexture();
-		depthTexture.type = UnsignedShortType;
+		if ( this.supportsDepthTextureExtension ) {
 
 
-		this.beautyRenderTarget.depthTexture = depthTexture;
-		this.beautyRenderTarget.depthBuffer = true;
+			const depthTexture = new DepthTexture();
+			depthTexture.type = UnsignedShortType;
 
 
-	}
+			this.beautyRenderTarget.depthTexture = depthTexture;
+			this.beautyRenderTarget.depthBuffer = true;
 
 
-	this.depthMaterial = new MeshDepthMaterial();
-	this.depthMaterial.depthPacking = RGBADepthPacking;
-	this.depthMaterial.blending = NoBlending;
+		}
 
 
-	this.normalMaterial = new MeshNormalMaterial();
-	this.normalMaterial.blending = NoBlending;
+		this.depthMaterial = new MeshDepthMaterial();
+		this.depthMaterial.depthPacking = RGBADepthPacking;
+		this.depthMaterial.blending = NoBlending;
 
 
-	if ( SAOShader === undefined ) {
+		this.normalMaterial = new MeshNormalMaterial();
+		this.normalMaterial.blending = NoBlending;
 
 
-		console.error( 'THREE.SAOPass relies on SAOShader' );
+		if ( SAOShader === undefined ) {
 
 
-	}
+			console.error( 'THREE.SAOPass relies on SAOShader' );
 
 
-	this.saoMaterial = new ShaderMaterial( {
-		defines: Object.assign( {}, SAOShader.defines ),
-		fragmentShader: SAOShader.fragmentShader,
-		vertexShader: SAOShader.vertexShader,
-		uniforms: UniformsUtils.clone( SAOShader.uniforms )
-	} );
-	this.saoMaterial.extensions.derivatives = true;
-	this.saoMaterial.defines[ 'DEPTH_PACKING' ] = this.supportsDepthTextureExtension ? 0 : 1;
-	this.saoMaterial.defines[ 'NORMAL_TEXTURE' ] = this.supportsNormalTexture ? 1 : 0;
-	this.saoMaterial.defines[ 'PERSPECTIVE_CAMERA' ] = this.camera.isPerspectiveCamera ? 1 : 0;
-	this.saoMaterial.uniforms[ 'tDepth' ].value = ( this.supportsDepthTextureExtension ) ? depthTexture : this.depthRenderTarget.texture;
-	this.saoMaterial.uniforms[ 'tNormal' ].value = this.normalRenderTarget.texture;
-	this.saoMaterial.uniforms[ 'size' ].value.set( this.resolution.x, this.resolution.y );
-	this.saoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
-	this.saoMaterial.uniforms[ 'cameraProjectionMatrix' ].value = this.camera.projectionMatrix;
-	this.saoMaterial.blending = NoBlending;
-
-	if ( DepthLimitedBlurShader === undefined ) {
-
-		console.error( 'THREE.SAOPass relies on DepthLimitedBlurShader' );
+		}
 
 
-	}
+		this.saoMaterial = new ShaderMaterial( {
+			defines: Object.assign( {}, SAOShader.defines ),
+			fragmentShader: SAOShader.fragmentShader,
+			vertexShader: SAOShader.vertexShader,
+			uniforms: UniformsUtils.clone( SAOShader.uniforms )
+		} );
+		this.saoMaterial.extensions.derivatives = true;
+		this.saoMaterial.defines[ 'DEPTH_PACKING' ] = this.supportsDepthTextureExtension ? 0 : 1;
+		this.saoMaterial.defines[ 'NORMAL_TEXTURE' ] = this.supportsNormalTexture ? 1 : 0;
+		this.saoMaterial.defines[ 'PERSPECTIVE_CAMERA' ] = this.camera.isPerspectiveCamera ? 1 : 0;
+		this.saoMaterial.uniforms[ 'tDepth' ].value = ( this.supportsDepthTextureExtension ) ? depthTexture : this.depthRenderTarget.texture;
+		this.saoMaterial.uniforms[ 'tNormal' ].value = this.normalRenderTarget.texture;
+		this.saoMaterial.uniforms[ 'size' ].value.set( this.resolution.x, this.resolution.y );
+		this.saoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
+		this.saoMaterial.uniforms[ 'cameraProjectionMatrix' ].value = this.camera.projectionMatrix;
+		this.saoMaterial.blending = NoBlending;
 
 
-	this.vBlurMaterial = new ShaderMaterial( {
-		uniforms: UniformsUtils.clone( DepthLimitedBlurShader.uniforms ),
-		defines: Object.assign( {}, DepthLimitedBlurShader.defines ),
-		vertexShader: DepthLimitedBlurShader.vertexShader,
-		fragmentShader: DepthLimitedBlurShader.fragmentShader
-	} );
-	this.vBlurMaterial.defines[ 'DEPTH_PACKING' ] = this.supportsDepthTextureExtension ? 0 : 1;
-	this.vBlurMaterial.defines[ 'PERSPECTIVE_CAMERA' ] = this.camera.isPerspectiveCamera ? 1 : 0;
-	this.vBlurMaterial.uniforms[ 'tDiffuse' ].value = this.saoRenderTarget.texture;
-	this.vBlurMaterial.uniforms[ 'tDepth' ].value = ( this.supportsDepthTextureExtension ) ? depthTexture : this.depthRenderTarget.texture;
-	this.vBlurMaterial.uniforms[ 'size' ].value.set( this.resolution.x, this.resolution.y );
-	this.vBlurMaterial.blending = NoBlending;
-
-	this.hBlurMaterial = new ShaderMaterial( {
-		uniforms: UniformsUtils.clone( DepthLimitedBlurShader.uniforms ),
-		defines: Object.assign( {}, DepthLimitedBlurShader.defines ),
-		vertexShader: DepthLimitedBlurShader.vertexShader,
-		fragmentShader: DepthLimitedBlurShader.fragmentShader
-	} );
-	this.hBlurMaterial.defines[ 'DEPTH_PACKING' ] = this.supportsDepthTextureExtension ? 0 : 1;
-	this.hBlurMaterial.defines[ 'PERSPECTIVE_CAMERA' ] = this.camera.isPerspectiveCamera ? 1 : 0;
-	this.hBlurMaterial.uniforms[ 'tDiffuse' ].value = this.blurIntermediateRenderTarget.texture;
-	this.hBlurMaterial.uniforms[ 'tDepth' ].value = ( this.supportsDepthTextureExtension ) ? depthTexture : this.depthRenderTarget.texture;
-	this.hBlurMaterial.uniforms[ 'size' ].value.set( this.resolution.x, this.resolution.y );
-	this.hBlurMaterial.blending = NoBlending;
-
-	if ( CopyShader === undefined ) {
-
-		console.error( 'THREE.SAOPass relies on CopyShader' );
+		if ( DepthLimitedBlurShader === undefined ) {
 
 
-	}
+			console.error( 'THREE.SAOPass relies on DepthLimitedBlurShader' );
 
 
-	this.materialCopy = new ShaderMaterial( {
-		uniforms: UniformsUtils.clone( CopyShader.uniforms ),
-		vertexShader: CopyShader.vertexShader,
-		fragmentShader: CopyShader.fragmentShader,
-		blending: NoBlending
-	} );
-	this.materialCopy.transparent = true;
-	this.materialCopy.depthTest = false;
-	this.materialCopy.depthWrite = false;
-	this.materialCopy.blending = CustomBlending;
-	this.materialCopy.blendSrc = DstColorFactor;
-	this.materialCopy.blendDst = ZeroFactor;
-	this.materialCopy.blendEquation = AddEquation;
-	this.materialCopy.blendSrcAlpha = DstAlphaFactor;
-	this.materialCopy.blendDstAlpha = ZeroFactor;
-	this.materialCopy.blendEquationAlpha = AddEquation;
-
-	if ( UnpackDepthRGBAShader === undefined ) {
-
-		console.error( 'THREE.SAOPass relies on UnpackDepthRGBAShader' );
+		}
 
 
-	}
+		this.vBlurMaterial = new ShaderMaterial( {
+			uniforms: UniformsUtils.clone( DepthLimitedBlurShader.uniforms ),
+			defines: Object.assign( {}, DepthLimitedBlurShader.defines ),
+			vertexShader: DepthLimitedBlurShader.vertexShader,
+			fragmentShader: DepthLimitedBlurShader.fragmentShader
+		} );
+		this.vBlurMaterial.defines[ 'DEPTH_PACKING' ] = this.supportsDepthTextureExtension ? 0 : 1;
+		this.vBlurMaterial.defines[ 'PERSPECTIVE_CAMERA' ] = this.camera.isPerspectiveCamera ? 1 : 0;
+		this.vBlurMaterial.uniforms[ 'tDiffuse' ].value = this.saoRenderTarget.texture;
+		this.vBlurMaterial.uniforms[ 'tDepth' ].value = ( this.supportsDepthTextureExtension ) ? depthTexture : this.depthRenderTarget.texture;
+		this.vBlurMaterial.uniforms[ 'size' ].value.set( this.resolution.x, this.resolution.y );
+		this.vBlurMaterial.blending = NoBlending;
+
+		this.hBlurMaterial = new ShaderMaterial( {
+			uniforms: UniformsUtils.clone( DepthLimitedBlurShader.uniforms ),
+			defines: Object.assign( {}, DepthLimitedBlurShader.defines ),
+			vertexShader: DepthLimitedBlurShader.vertexShader,
+			fragmentShader: DepthLimitedBlurShader.fragmentShader
+		} );
+		this.hBlurMaterial.defines[ 'DEPTH_PACKING' ] = this.supportsDepthTextureExtension ? 0 : 1;
+		this.hBlurMaterial.defines[ 'PERSPECTIVE_CAMERA' ] = this.camera.isPerspectiveCamera ? 1 : 0;
+		this.hBlurMaterial.uniforms[ 'tDiffuse' ].value = this.blurIntermediateRenderTarget.texture;
+		this.hBlurMaterial.uniforms[ 'tDepth' ].value = ( this.supportsDepthTextureExtension ) ? depthTexture : this.depthRenderTarget.texture;
+		this.hBlurMaterial.uniforms[ 'size' ].value.set( this.resolution.x, this.resolution.y );
+		this.hBlurMaterial.blending = NoBlending;
+
+		if ( CopyShader === undefined ) {
+
+			console.error( 'THREE.SAOPass relies on CopyShader' );
 
 
-	this.depthCopy = new ShaderMaterial( {
-		uniforms: UniformsUtils.clone( UnpackDepthRGBAShader.uniforms ),
-		vertexShader: UnpackDepthRGBAShader.vertexShader,
-		fragmentShader: UnpackDepthRGBAShader.fragmentShader,
-		blending: NoBlending
-	} );
+		}
 
 
-	this.fsQuad = new Pass.FullScreenQuad( null );
+		this.materialCopy = new ShaderMaterial( {
+			uniforms: UniformsUtils.clone( CopyShader.uniforms ),
+			vertexShader: CopyShader.vertexShader,
+			fragmentShader: CopyShader.fragmentShader,
+			blending: NoBlending
+		} );
+		this.materialCopy.transparent = true;
+		this.materialCopy.depthTest = false;
+		this.materialCopy.depthWrite = false;
+		this.materialCopy.blending = CustomBlending;
+		this.materialCopy.blendSrc = DstColorFactor;
+		this.materialCopy.blendDst = ZeroFactor;
+		this.materialCopy.blendEquation = AddEquation;
+		this.materialCopy.blendSrcAlpha = DstAlphaFactor;
+		this.materialCopy.blendDstAlpha = ZeroFactor;
+		this.materialCopy.blendEquationAlpha = AddEquation;
+
+		if ( UnpackDepthRGBAShader === undefined ) {
+
+			console.error( 'THREE.SAOPass relies on UnpackDepthRGBAShader' );
 
 
-};
+		}
 
 
-SAOPass.OUTPUT = {
-	'Beauty': 1,
-	'Default': 0,
-	'SAO': 2,
-	'Depth': 3,
-	'Normal': 4
-};
+		this.depthCopy = new ShaderMaterial( {
+			uniforms: UniformsUtils.clone( UnpackDepthRGBAShader.uniforms ),
+			vertexShader: UnpackDepthRGBAShader.vertexShader,
+			fragmentShader: UnpackDepthRGBAShader.fragmentShader,
+			blending: NoBlending
+		} );
+
+		this.fsQuad = new FullScreenQuad( null );
 
 
-SAOPass.prototype = Object.assign( Object.create( Pass.prototype ), {
-	constructor: SAOPass,
+	}
 
 
-	render: function ( renderer, writeBuffer, readBuffer/*, deltaTime, maskActive*/ ) {
+	render( renderer, writeBuffer, readBuffer/*, deltaTime, maskActive*/ ) {
 
 
 		// Rendering readBuffer first when rendering to screen
 		// Rendering readBuffer first when rendering to screen
 		if ( this.renderToScreen ) {
 		if ( this.renderToScreen ) {
@@ -220,7 +211,7 @@ SAOPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		renderer.getClearColor( this._oldClearColor );
 		renderer.getClearColor( this._oldClearColor );
 		this.oldClearAlpha = renderer.getClearAlpha();
 		this.oldClearAlpha = renderer.getClearAlpha();
-		var oldAutoClear = renderer.autoClear;
+		const oldAutoClear = renderer.autoClear;
 		renderer.autoClear = false;
 		renderer.autoClear = false;
 
 
 		renderer.setRenderTarget( this.depthRenderTarget );
 		renderer.setRenderTarget( this.depthRenderTarget );
@@ -235,7 +226,7 @@ SAOPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 		this.saoMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
 		this.saoMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
 		// this.saoMaterial.uniforms['randomSeed'].value = Math.random();
 		// this.saoMaterial.uniforms['randomSeed'].value = Math.random();
 
 
-		var depthCutoff = this.params.saoBlurDepthCutoff * ( this.camera.far - this.camera.near );
+		const depthCutoff = this.params.saoBlurDepthCutoff * ( this.camera.far - this.camera.near );
 		this.vBlurMaterial.uniforms[ 'depthCutoff' ].value = depthCutoff;
 		this.vBlurMaterial.uniforms[ 'depthCutoff' ].value = depthCutoff;
 		this.hBlurMaterial.uniforms[ 'depthCutoff' ].value = depthCutoff;
 		this.hBlurMaterial.uniforms[ 'depthCutoff' ].value = depthCutoff;
 
 
@@ -286,7 +277,7 @@ SAOPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		}
 		}
 
 
-		var outputMaterial = this.materialCopy;
+		let outputMaterial = this.materialCopy;
 		// Setting up SAO rendering
 		// Setting up SAO rendering
 		if ( this.params.output === 3 ) {
 		if ( this.params.output === 3 ) {
 
 
@@ -332,14 +323,14 @@ SAOPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 		renderer.setClearColor( this._oldClearColor, this.oldClearAlpha );
 		renderer.setClearColor( this._oldClearColor, this.oldClearAlpha );
 		renderer.autoClear = oldAutoClear;
 		renderer.autoClear = oldAutoClear;
 
 
-	},
+	}
 
 
-	renderPass: function ( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
+	renderPass( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
 		// save original state
 		// save original state
 		renderer.getClearColor( this.originalClearColor );
 		renderer.getClearColor( this.originalClearColor );
-		var originalClearAlpha = renderer.getClearAlpha();
-		var originalAutoClear = renderer.autoClear;
+		const originalClearAlpha = renderer.getClearAlpha();
+		const originalAutoClear = renderer.autoClear;
 
 
 		renderer.setRenderTarget( renderTarget );
 		renderer.setRenderTarget( renderTarget );
 
 
@@ -361,13 +352,13 @@ SAOPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 		renderer.setClearColor( this.originalClearColor );
 		renderer.setClearColor( this.originalClearColor );
 		renderer.setClearAlpha( originalClearAlpha );
 		renderer.setClearAlpha( originalClearAlpha );
 
 
-	},
+	}
 
 
-	renderOverride: function ( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
+	renderOverride( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
 		renderer.getClearColor( this.originalClearColor );
 		renderer.getClearColor( this.originalClearColor );
-		var originalClearAlpha = renderer.getClearAlpha();
-		var originalAutoClear = renderer.autoClear;
+		const originalClearAlpha = renderer.getClearAlpha();
+		const originalAutoClear = renderer.autoClear;
 
 
 		renderer.setRenderTarget( renderTarget );
 		renderer.setRenderTarget( renderTarget );
 		renderer.autoClear = false;
 		renderer.autoClear = false;
@@ -391,9 +382,9 @@ SAOPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 		renderer.setClearColor( this.originalClearColor );
 		renderer.setClearColor( this.originalClearColor );
 		renderer.setClearAlpha( originalClearAlpha );
 		renderer.setClearAlpha( originalClearAlpha );
 
 
-	},
+	}
 
 
-	setSize: function ( width, height ) {
+	setSize( width, height ) {
 
 
 		this.beautyRenderTarget.setSize( width, height );
 		this.beautyRenderTarget.setSize( width, height );
 		this.saoRenderTarget.setSize( width, height );
 		this.saoRenderTarget.setSize( width, height );
@@ -414,6 +405,14 @@ SAOPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 	}
 	}
 
 
-} );
+}
+
+SAOPass.OUTPUT = {
+	'Beauty': 1,
+	'Default': 0,
+	'SAO': 2,
+	'Depth': 3,
+	'Normal': 4
+};
 
 
 export { SAOPass };
 export { SAOPass };

File diff suppressed because it is too large
+ 88 - 90
examples/jsm/postprocessing/SMAAPass.js


+ 44 - 46
examples/jsm/postprocessing/SSAARenderPass.js

@@ -7,7 +7,7 @@ import {
 	UniformsUtils,
 	UniformsUtils,
 	WebGLRenderTarget
 	WebGLRenderTarget
 } from '../../../build/three.module.js';
 } from '../../../build/three.module.js';
-import { Pass } from '../postprocessing/Pass.js';
+import { Pass, FullScreenQuad } from '../postprocessing/Pass.js';
 import { CopyShader } from '../shaders/CopyShader.js';
 import { CopyShader } from '../shaders/CopyShader.js';
 
 
 /**
 /**
@@ -20,46 +20,44 @@ import { CopyShader } from '../shaders/CopyShader.js';
 *
 *
 */
 */
 
 
-var SSAARenderPass = function ( scene, camera, clearColor, clearAlpha ) {
+class SSAARenderPass extends Pass {
 
 
-	Pass.call( this );
+	constructor( scene, camera, clearColor, clearAlpha ) {
 
 
-	this.scene = scene;
-	this.camera = camera;
+		super();
 
 
-	this.sampleLevel = 4; // specified as n, where the number of samples is 2^n, so sampleLevel = 4, is 2^4 samples, 16.
-	this.unbiased = true;
+		this.scene = scene;
+		this.camera = camera;
 
 
-	// as we need to clear the buffer in this pass, clearColor must be set to something, defaults to black.
-	this.clearColor = ( clearColor !== undefined ) ? clearColor : 0x000000;
-	this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0;
-	this._oldClearColor = new Color();
+		this.sampleLevel = 4; // specified as n, where the number of samples is 2^n, so sampleLevel = 4, is 2^4 samples, 16.
+		this.unbiased = true;
 
 
-	if ( CopyShader === undefined ) console.error( 'THREE.SSAARenderPass relies on CopyShader' );
+		// as we need to clear the buffer in this pass, clearColor must be set to something, defaults to black.
+		this.clearColor = ( clearColor !== undefined ) ? clearColor : 0x000000;
+		this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0;
+		this._oldClearColor = new Color();
 
 
-	var copyShader = CopyShader;
-	this.copyUniforms = UniformsUtils.clone( copyShader.uniforms );
+		if ( CopyShader === undefined ) console.error( 'THREE.SSAARenderPass relies on CopyShader' );
 
 
-	this.copyMaterial = new ShaderMaterial(	{
-		uniforms: this.copyUniforms,
-		vertexShader: copyShader.vertexShader,
-		fragmentShader: copyShader.fragmentShader,
-		premultipliedAlpha: true,
-		transparent: true,
-		blending: AdditiveBlending,
-		depthTest: false,
-		depthWrite: false
-	} );
+		const copyShader = CopyShader;
+		this.copyUniforms = UniformsUtils.clone( copyShader.uniforms );
 
 
-	this.fsQuad = new Pass.FullScreenQuad( this.copyMaterial );
+		this.copyMaterial = new ShaderMaterial(	{
+			uniforms: this.copyUniforms,
+			vertexShader: copyShader.vertexShader,
+			fragmentShader: copyShader.fragmentShader,
+			premultipliedAlpha: true,
+			transparent: true,
+			blending: AdditiveBlending,
+			depthTest: false,
+			depthWrite: false
+		} );
 
 
-};
+		this.fsQuad = new FullScreenQuad( this.copyMaterial );
 
 
-SSAARenderPass.prototype = Object.assign( Object.create( Pass.prototype ), {
-
-	constructor: SSAARenderPass,
+	}
 
 
-	dispose: function () {
+	dispose() {
 
 
 		if ( this.sampleRenderTarget ) {
 		if ( this.sampleRenderTarget ) {
 
 
@@ -68,15 +66,15 @@ SSAARenderPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		}
 		}
 
 
-	},
+	}
 
 
-	setSize: function ( width, height ) {
+	setSize( width, height ) {
 
 
 		if ( this.sampleRenderTarget )	this.sampleRenderTarget.setSize( width, height );
 		if ( this.sampleRenderTarget )	this.sampleRenderTarget.setSize( width, height );
 
 
-	},
+	}
 
 
-	render: function ( renderer, writeBuffer, readBuffer ) {
+	render( renderer, writeBuffer, readBuffer ) {
 
 
 		if ( ! this.sampleRenderTarget ) {
 		if ( ! this.sampleRenderTarget ) {
 
 
@@ -85,24 +83,24 @@ SSAARenderPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		}
 		}
 
 
-		var jitterOffsets = SSAARenderPass.JitterVectors[ Math.max( 0, Math.min( this.sampleLevel, 5 ) ) ];
+		const jitterOffsets = _JitterVectors[ Math.max( 0, Math.min( this.sampleLevel, 5 ) ) ];
 
 
-		var autoClear = renderer.autoClear;
+		const autoClear = renderer.autoClear;
 		renderer.autoClear = false;
 		renderer.autoClear = false;
 
 
 		renderer.getClearColor( this._oldClearColor );
 		renderer.getClearColor( this._oldClearColor );
-		var oldClearAlpha = renderer.getClearAlpha();
+		const oldClearAlpha = renderer.getClearAlpha();
 
 
-		var baseSampleWeight = 1.0 / jitterOffsets.length;
-		var roundingRange = 1 / 32;
+		const baseSampleWeight = 1.0 / jitterOffsets.length;
+		const roundingRange = 1 / 32;
 		this.copyUniforms[ 'tDiffuse' ].value = this.sampleRenderTarget.texture;
 		this.copyUniforms[ 'tDiffuse' ].value = this.sampleRenderTarget.texture;
 
 
-		var width = readBuffer.width, height = readBuffer.height;
+		const width = readBuffer.width, height = readBuffer.height;
 
 
 		// render the scene multiple times, each slightly jitter offset from the last and accumulate the results.
 		// render the scene multiple times, each slightly jitter offset from the last and accumulate the results.
-		for ( var i = 0; i < jitterOffsets.length; i ++ ) {
+		for ( let i = 0; i < jitterOffsets.length; i ++ ) {
 
 
-			var jitterOffset = jitterOffsets[ i ];
+			const jitterOffset = jitterOffsets[ i ];
 
 
 			if ( this.camera.setViewOffset ) {
 			if ( this.camera.setViewOffset ) {
 
 
@@ -112,7 +110,7 @@ SSAARenderPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 			}
 			}
 
 
-			var sampleWeight = baseSampleWeight;
+			let sampleWeight = baseSampleWeight;
 
 
 			if ( this.unbiased ) {
 			if ( this.unbiased ) {
 
 
@@ -120,7 +118,7 @@ SSAARenderPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 				// The following equation varies the sampleWeight per sample so that it is uniformly distributed
 				// The following equation varies the sampleWeight per sample so that it is uniformly distributed
 				// across a range of values whose rounding errors cancel each other out.
 				// across a range of values whose rounding errors cancel each other out.
 
 
-				var uniformCenteredDistribution = ( - 0.5 + ( i + 0.5 ) / jitterOffsets.length );
+				const uniformCenteredDistribution = ( - 0.5 + ( i + 0.5 ) / jitterOffsets.length );
 				sampleWeight += roundingRange * uniformCenteredDistribution;
 				sampleWeight += roundingRange * uniformCenteredDistribution;
 
 
 			}
 			}
@@ -151,7 +149,7 @@ SSAARenderPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 	}
 	}
 
 
-} );
+}
 
 
 
 
 // These jitter vectors are specified in integers because it is easier.
 // These jitter vectors are specified in integers because it is easier.
@@ -159,7 +157,7 @@ SSAARenderPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 // before being used, thus these integers need to be scaled by 1/16.
 // before being used, thus these integers need to be scaled by 1/16.
 //
 //
 // Sample patterns reference: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476218%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
 // Sample patterns reference: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476218%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
-SSAARenderPass.JitterVectors = [
+const _JitterVectors = [
 	[
 	[
 		[ 0, 0 ]
 		[ 0, 0 ]
 	],
 	],

+ 156 - 158
examples/jsm/postprocessing/SSAOPass.js

@@ -21,155 +21,153 @@ import {
 	WebGLRenderTarget,
 	WebGLRenderTarget,
 	ZeroFactor
 	ZeroFactor
 } from '../../../build/three.module.js';
 } from '../../../build/three.module.js';
-import { Pass } from '../postprocessing/Pass.js';
+import { Pass, FullScreenQuad } from '../postprocessing/Pass.js';
 import { SimplexNoise } from '../math/SimplexNoise.js';
 import { SimplexNoise } from '../math/SimplexNoise.js';
 import { SSAOShader } from '../shaders/SSAOShader.js';
 import { SSAOShader } from '../shaders/SSAOShader.js';
 import { SSAOBlurShader } from '../shaders/SSAOShader.js';
 import { SSAOBlurShader } from '../shaders/SSAOShader.js';
 import { SSAODepthShader } from '../shaders/SSAOShader.js';
 import { SSAODepthShader } from '../shaders/SSAOShader.js';
 import { CopyShader } from '../shaders/CopyShader.js';
 import { CopyShader } from '../shaders/CopyShader.js';
 
 
-var SSAOPass = function ( scene, camera, width, height ) {
+class SSAOPass extends Pass {
 
 
-	Pass.call( this );
+	constructor( scene, camera, width, height ) {
 
 
-	this.width = ( width !== undefined ) ? width : 512;
-	this.height = ( height !== undefined ) ? height : 512;
+		super();
 
 
-	this.clear = true;
+		this.width = ( width !== undefined ) ? width : 512;
+		this.height = ( height !== undefined ) ? height : 512;
 
 
-	this.camera = camera;
-	this.scene = scene;
+		this.clear = true;
 
 
-	this.kernelRadius = 8;
-	this.kernelSize = 32;
-	this.kernel = [];
-	this.noiseTexture = null;
-	this.output = 0;
+		this.camera = camera;
+		this.scene = scene;
 
 
-	this.minDistance = 0.005;
-	this.maxDistance = 0.1;
+		this.kernelRadius = 8;
+		this.kernelSize = 32;
+		this.kernel = [];
+		this.noiseTexture = null;
+		this.output = 0;
 
 
-	this._visibilityCache = new Map();
+		this.minDistance = 0.005;
+		this.maxDistance = 0.1;
 
 
-	//
+		this._visibilityCache = new Map();
 
 
-	this.generateSampleKernel();
-	this.generateRandomKernelRotations();
+		//
 
 
-	// beauty render target
+		this.generateSampleKernel();
+		this.generateRandomKernelRotations();
 
 
-	var depthTexture = new DepthTexture();
-	depthTexture.type = UnsignedShortType;
+		// beauty render target
 
 
-	this.beautyRenderTarget = new WebGLRenderTarget( this.width, this.height, {
-		minFilter: LinearFilter,
-		magFilter: LinearFilter,
-		format: RGBAFormat
-	} );
+		const depthTexture = new DepthTexture();
+		depthTexture.type = UnsignedShortType;
 
 
-	// normal render target with depth buffer
+		this.beautyRenderTarget = new WebGLRenderTarget( this.width, this.height, {
+			minFilter: LinearFilter,
+			magFilter: LinearFilter,
+			format: RGBAFormat
+		} );
 
 
-	this.normalRenderTarget = new WebGLRenderTarget( this.width, this.height, {
-		minFilter: NearestFilter,
-		magFilter: NearestFilter,
-		format: RGBAFormat,
-		depthTexture: depthTexture
-	} );
+		// normal render target with depth buffer
 
 
-	// ssao render target
+		this.normalRenderTarget = new WebGLRenderTarget( this.width, this.height, {
+			minFilter: NearestFilter,
+			magFilter: NearestFilter,
+			format: RGBAFormat,
+			depthTexture: depthTexture
+		} );
 
 
-	this.ssaoRenderTarget = new WebGLRenderTarget( this.width, this.height, {
-		minFilter: LinearFilter,
-		magFilter: LinearFilter,
-		format: RGBAFormat
-	} );
+		// ssao render target
 
 
-	this.blurRenderTarget = this.ssaoRenderTarget.clone();
+		this.ssaoRenderTarget = new WebGLRenderTarget( this.width, this.height, {
+			minFilter: LinearFilter,
+			magFilter: LinearFilter,
+			format: RGBAFormat
+		} );
 
 
-	// ssao material
+		this.blurRenderTarget = this.ssaoRenderTarget.clone();
 
 
-	if ( SSAOShader === undefined ) {
+		// ssao material
 
 
-		console.error( 'THREE.SSAOPass: The pass relies on SSAOShader.' );
+		if ( SSAOShader === undefined ) {
 
 
-	}
+			console.error( 'THREE.SSAOPass: The pass relies on SSAOShader.' );
 
 
-	this.ssaoMaterial = new ShaderMaterial( {
-		defines: Object.assign( {}, SSAOShader.defines ),
-		uniforms: UniformsUtils.clone( SSAOShader.uniforms ),
-		vertexShader: SSAOShader.vertexShader,
-		fragmentShader: SSAOShader.fragmentShader,
-		blending: NoBlending
-	} );
-
-	this.ssaoMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
-	this.ssaoMaterial.uniforms[ 'tNormal' ].value = this.normalRenderTarget.texture;
-	this.ssaoMaterial.uniforms[ 'tDepth' ].value = this.normalRenderTarget.depthTexture;
-	this.ssaoMaterial.uniforms[ 'tNoise' ].value = this.noiseTexture;
-	this.ssaoMaterial.uniforms[ 'kernel' ].value = this.kernel;
-	this.ssaoMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
-	this.ssaoMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
-	this.ssaoMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height );
-	this.ssaoMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
-	this.ssaoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
-
-	// normal material
-
-	this.normalMaterial = new MeshNormalMaterial();
-	this.normalMaterial.blending = NoBlending;
-
-	// blur material
-
-	this.blurMaterial = new ShaderMaterial( {
-		defines: Object.assign( {}, SSAOBlurShader.defines ),
-		uniforms: UniformsUtils.clone( SSAOBlurShader.uniforms ),
-		vertexShader: SSAOBlurShader.vertexShader,
-		fragmentShader: SSAOBlurShader.fragmentShader
-	} );
-	this.blurMaterial.uniforms[ 'tDiffuse' ].value = this.ssaoRenderTarget.texture;
-	this.blurMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height );
-
-	// material for rendering the depth
-
-	this.depthRenderMaterial = new ShaderMaterial( {
-		defines: Object.assign( {}, SSAODepthShader.defines ),
-		uniforms: UniformsUtils.clone( SSAODepthShader.uniforms ),
-		vertexShader: SSAODepthShader.vertexShader,
-		fragmentShader: SSAODepthShader.fragmentShader,
-		blending: NoBlending
-	} );
-	this.depthRenderMaterial.uniforms[ 'tDepth' ].value = this.normalRenderTarget.depthTexture;
-	this.depthRenderMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
-	this.depthRenderMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
-
-	// material for rendering the content of a render target
-
-	this.copyMaterial = new ShaderMaterial( {
-		uniforms: UniformsUtils.clone( CopyShader.uniforms ),
-		vertexShader: CopyShader.vertexShader,
-		fragmentShader: CopyShader.fragmentShader,
-		transparent: true,
-		depthTest: false,
-		depthWrite: false,
-		blendSrc: DstColorFactor,
-		blendDst: ZeroFactor,
-		blendEquation: AddEquation,
-		blendSrcAlpha: DstAlphaFactor,
-		blendDstAlpha: ZeroFactor,
-		blendEquationAlpha: AddEquation
-	} );
-
-	this.fsQuad = new Pass.FullScreenQuad( null );
-
-	this.originalClearColor = new Color();
+		}
 
 
-};
+		this.ssaoMaterial = new ShaderMaterial( {
+			defines: Object.assign( {}, SSAOShader.defines ),
+			uniforms: UniformsUtils.clone( SSAOShader.uniforms ),
+			vertexShader: SSAOShader.vertexShader,
+			fragmentShader: SSAOShader.fragmentShader,
+			blending: NoBlending
+		} );
 
 
-SSAOPass.prototype = Object.assign( Object.create( Pass.prototype ), {
+		this.ssaoMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
+		this.ssaoMaterial.uniforms[ 'tNormal' ].value = this.normalRenderTarget.texture;
+		this.ssaoMaterial.uniforms[ 'tDepth' ].value = this.normalRenderTarget.depthTexture;
+		this.ssaoMaterial.uniforms[ 'tNoise' ].value = this.noiseTexture;
+		this.ssaoMaterial.uniforms[ 'kernel' ].value = this.kernel;
+		this.ssaoMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
+		this.ssaoMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
+		this.ssaoMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height );
+		this.ssaoMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
+		this.ssaoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
+
+		// normal material
 
 
-	constructor: SSAOPass,
+		this.normalMaterial = new MeshNormalMaterial();
+		this.normalMaterial.blending = NoBlending;
 
 
-	dispose: function () {
+		// blur material
+
+		this.blurMaterial = new ShaderMaterial( {
+			defines: Object.assign( {}, SSAOBlurShader.defines ),
+			uniforms: UniformsUtils.clone( SSAOBlurShader.uniforms ),
+			vertexShader: SSAOBlurShader.vertexShader,
+			fragmentShader: SSAOBlurShader.fragmentShader
+		} );
+		this.blurMaterial.uniforms[ 'tDiffuse' ].value = this.ssaoRenderTarget.texture;
+		this.blurMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height );
+
+		// material for rendering the depth
+
+		this.depthRenderMaterial = new ShaderMaterial( {
+			defines: Object.assign( {}, SSAODepthShader.defines ),
+			uniforms: UniformsUtils.clone( SSAODepthShader.uniforms ),
+			vertexShader: SSAODepthShader.vertexShader,
+			fragmentShader: SSAODepthShader.fragmentShader,
+			blending: NoBlending
+		} );
+		this.depthRenderMaterial.uniforms[ 'tDepth' ].value = this.normalRenderTarget.depthTexture;
+		this.depthRenderMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
+		this.depthRenderMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
+
+		// material for rendering the content of a render target
+
+		this.copyMaterial = new ShaderMaterial( {
+			uniforms: UniformsUtils.clone( CopyShader.uniforms ),
+			vertexShader: CopyShader.vertexShader,
+			fragmentShader: CopyShader.fragmentShader,
+			transparent: true,
+			depthTest: false,
+			depthWrite: false,
+			blendSrc: DstColorFactor,
+			blendDst: ZeroFactor,
+			blendEquation: AddEquation,
+			blendSrcAlpha: DstAlphaFactor,
+			blendDstAlpha: ZeroFactor,
+			blendEquationAlpha: AddEquation
+		} );
+
+		this.fsQuad = new FullScreenQuad( null );
+
+		this.originalClearColor = new Color();
+
+	}
+
+	dispose() {
 
 
 		// dispose render targets
 		// dispose render targets
 
 
@@ -189,9 +187,9 @@ SSAOPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		this.fsQuad.dispose();
 		this.fsQuad.dispose();
 
 
-	},
+	}
 
 
-	render: function ( renderer, writeBuffer /*, readBuffer, deltaTime, maskActive */ ) {
+	render( renderer, writeBuffer /*, readBuffer, deltaTime, maskActive */ ) {
 
 
 		// render beauty
 		// render beauty
 
 
@@ -275,14 +273,14 @@ SSAOPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		}
 		}
 
 
-	},
+	}
 
 
-	renderPass: function ( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
+	renderPass( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
 		// save original state
 		// save original state
 		renderer.getClearColor( this.originalClearColor );
 		renderer.getClearColor( this.originalClearColor );
-		var originalClearAlpha = renderer.getClearAlpha();
-		var originalAutoClear = renderer.autoClear;
+		const originalClearAlpha = renderer.getClearAlpha();
+		const originalAutoClear = renderer.autoClear;
 
 
 		renderer.setRenderTarget( renderTarget );
 		renderer.setRenderTarget( renderTarget );
 
 
@@ -304,13 +302,13 @@ SSAOPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 		renderer.setClearColor( this.originalClearColor );
 		renderer.setClearColor( this.originalClearColor );
 		renderer.setClearAlpha( originalClearAlpha );
 		renderer.setClearAlpha( originalClearAlpha );
 
 
-	},
+	}
 
 
-	renderOverride: function ( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
+	renderOverride( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
 		renderer.getClearColor( this.originalClearColor );
 		renderer.getClearColor( this.originalClearColor );
-		var originalClearAlpha = renderer.getClearAlpha();
-		var originalAutoClear = renderer.autoClear;
+		const originalClearAlpha = renderer.getClearAlpha();
+		const originalAutoClear = renderer.autoClear;
 
 
 		renderer.setRenderTarget( renderTarget );
 		renderer.setRenderTarget( renderTarget );
 		renderer.autoClear = false;
 		renderer.autoClear = false;
@@ -336,9 +334,9 @@ SSAOPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 		renderer.setClearColor( this.originalClearColor );
 		renderer.setClearColor( this.originalClearColor );
 		renderer.setClearAlpha( originalClearAlpha );
 		renderer.setClearAlpha( originalClearAlpha );
 
 
-	},
+	}
 
 
-	setSize: function ( width, height ) {
+	setSize( width, height ) {
 
 
 		this.width = width;
 		this.width = width;
 		this.height = height;
 		this.height = height;
@@ -354,23 +352,23 @@ SSAOPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		this.blurMaterial.uniforms[ 'resolution' ].value.set( width, height );
 		this.blurMaterial.uniforms[ 'resolution' ].value.set( width, height );
 
 
-	},
+	}
 
 
-	generateSampleKernel: function () {
+	generateSampleKernel() {
 
 
-		var kernelSize = this.kernelSize;
-		var kernel = this.kernel;
+		const kernelSize = this.kernelSize;
+		const kernel = this.kernel;
 
 
-		for ( var i = 0; i < kernelSize; i ++ ) {
+		for ( let i = 0; i < kernelSize; i ++ ) {
 
 
-			var sample = new Vector3();
+			const sample = new Vector3();
 			sample.x = ( Math.random() * 2 ) - 1;
 			sample.x = ( Math.random() * 2 ) - 1;
 			sample.y = ( Math.random() * 2 ) - 1;
 			sample.y = ( Math.random() * 2 ) - 1;
 			sample.z = Math.random();
 			sample.z = Math.random();
 
 
 			sample.normalize();
 			sample.normalize();
 
 
-			var scale = i / kernelSize;
+			let scale = i / kernelSize;
 			scale = MathUtils.lerp( 0.1, 1, scale * scale );
 			scale = MathUtils.lerp( 0.1, 1, scale * scale );
 			sample.multiplyScalar( scale );
 			sample.multiplyScalar( scale );
 
 
@@ -378,11 +376,11 @@ SSAOPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		}
 		}
 
 
-	},
+	}
 
 
-	generateRandomKernelRotations: function () {
+	generateRandomKernelRotations() {
 
 
-		var width = 4, height = 4;
+		const width = 4, height = 4;
 
 
 		if ( SimplexNoise === undefined ) {
 		if ( SimplexNoise === undefined ) {
 
 
@@ -390,20 +388,20 @@ SSAOPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		}
 		}
 
 
-		var simplex = new SimplexNoise();
+		const simplex = new SimplexNoise();
 
 
-		var size = width * height;
-		var data = new Float32Array( size * 4 );
+		const size = width * height;
+		const data = new Float32Array( size * 4 );
 
 
-		for ( var i = 0; i < size; i ++ ) {
+		for ( let i = 0; i < size; i ++ ) {
 
 
-			var stride = i * 4;
+			const stride = i * 4;
 
 
-			var x = ( Math.random() * 2 ) - 1;
-			var y = ( Math.random() * 2 ) - 1;
-			var z = 0;
+			const x = ( Math.random() * 2 ) - 1;
+			const y = ( Math.random() * 2 ) - 1;
+			const z = 0;
 
 
-			var noise = simplex.noise3d( x, y, z );
+			const noise = simplex.noise3d( x, y, z );
 
 
 			data[ stride ] = noise;
 			data[ stride ] = noise;
 			data[ stride + 1 ] = noise;
 			data[ stride + 1 ] = noise;
@@ -416,12 +414,12 @@ SSAOPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 		this.noiseTexture.wrapS = RepeatWrapping;
 		this.noiseTexture.wrapS = RepeatWrapping;
 		this.noiseTexture.wrapT = RepeatWrapping;
 		this.noiseTexture.wrapT = RepeatWrapping;
 
 
-	},
+	}
 
 
-	overrideVisibility: function () {
+	overrideVisibility() {
 
 
-		var scene = this.scene;
-		var cache = this._visibilityCache;
+		const scene = this.scene;
+		const cache = this._visibilityCache;
 
 
 		scene.traverse( function ( object ) {
 		scene.traverse( function ( object ) {
 
 
@@ -431,16 +429,16 @@ SSAOPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		} );
 		} );
 
 
-	},
+	}
 
 
-	restoreVisibility: function () {
+	restoreVisibility() {
 
 
-		var scene = this.scene;
-		var cache = this._visibilityCache;
+		const scene = this.scene;
+		const cache = this._visibilityCache;
 
 
 		scene.traverse( function ( object ) {
 		scene.traverse( function ( object ) {
 
 
-			var visible = cache.get( object );
+			const visible = cache.get( object );
 			object.visible = visible;
 			object.visible = visible;
 
 
 		} );
 		} );
@@ -449,7 +447,7 @@ SSAOPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 	}
 	}
 
 
-} );
+}
 
 
 SSAOPass.OUTPUT = {
 SSAOPass.OUTPUT = {
 	'Default': 0,
 	'Default': 0,

+ 258 - 260
examples/jsm/postprocessing/SSRPass.js

@@ -17,320 +17,318 @@ import {
 	WebGLRenderTarget,
 	WebGLRenderTarget,
 	HalfFloatType,
 	HalfFloatType,
 } from '../../../build/three.module.js';
 } from '../../../build/three.module.js';
-import { Pass } from '../postprocessing/Pass.js';
+import { Pass, FullScreenQuad } from '../postprocessing/Pass.js';
 import { SSRShader } from '../shaders/SSRShader.js';
 import { SSRShader } from '../shaders/SSRShader.js';
 import { SSRBlurShader } from '../shaders/SSRShader.js';
 import { SSRBlurShader } from '../shaders/SSRShader.js';
 import { SSRDepthShader } from '../shaders/SSRShader.js';
 import { SSRDepthShader } from '../shaders/SSRShader.js';
 import { CopyShader } from '../shaders/CopyShader.js';
 import { CopyShader } from '../shaders/CopyShader.js';
 
 
-var SSRPass = function ( { renderer, scene, camera, width, height, selects, encoding, bouncing = false, morphTargets = false, groundReflector } ) {
+class SSRPass extends Pass {
 
 
-	Pass.call( this );
+	constructor( { renderer, scene, camera, width, height, selects, encoding, bouncing = false, morphTargets = false, groundReflector } ) {
 
 
-	this.width = ( width !== undefined ) ? width : 512;
-	this.height = ( height !== undefined ) ? height : 512;
+		super();
 
 
-	this.clear = true;
+		this.width = ( width !== undefined ) ? width : 512;
+		this.height = ( height !== undefined ) ? height : 512;
 
 
-	this.renderer = renderer;
-	this.scene = scene;
-	this.camera = camera;
-	this.groundReflector = groundReflector;
+		this.clear = true;
 
 
-	this.opacity = SSRShader.uniforms.opacity.value;
-	this.output = 0;
+		this.renderer = renderer;
+		this.scene = scene;
+		this.camera = camera;
+		this.groundReflector = groundReflector;
 
 
-	this.maxDistance = SSRShader.uniforms.maxDistance.value;
-	this.surfDist = SSRShader.uniforms.surfDist.value;
+		this.opacity = SSRShader.uniforms.opacity.value;
+		this.output = 0;
 
 
-	this.encoding = encoding;
+		this.maxDistance = SSRShader.uniforms.maxDistance.value;
+		this.surfDist = SSRShader.uniforms.surfDist.value;
 
 
-	this.tempColor = new Color();
+		this.encoding = encoding;
 
 
-	this._selects = selects;
-	this.selective = Array.isArray( this._selects );
-	Object.defineProperty( this, 'selects', {
-		get() {
+		this.tempColor = new Color();
 
 
-			return this._selects;
+		this._selects = selects;
+		this.selective = Array.isArray( this._selects );
+		Object.defineProperty( this, 'selects', {
+			get() {
 
 
-		},
-		set( val ) {
+				return this._selects;
 
 
-			if ( this._selects === val ) return;
-			this._selects = val;
-			if ( Array.isArray( val ) ) {
+			},
+			set( val ) {
 
 
-				this.selective = true;
-				this.ssrMaterial.defines.SELECTIVE = true;
-				this.ssrMaterial.needsUpdate = true;
+				if ( this._selects === val ) return;
+				this._selects = val;
+				if ( Array.isArray( val ) ) {
 
 
-			} else {
+					this.selective = true;
+					this.ssrMaterial.defines.SELECTIVE = true;
+					this.ssrMaterial.needsUpdate = true;
 
 
-				this.selective = false;
-				this.ssrMaterial.defines.SELECTIVE = false;
-				this.ssrMaterial.needsUpdate = true;
+				} else {
+
+					this.selective = false;
+					this.ssrMaterial.defines.SELECTIVE = false;
+					this.ssrMaterial.needsUpdate = true;
+
+				}
 
 
 			}
 			}
+		} );
 
 
-		}
-	} );
+		this._bouncing = bouncing;
+		Object.defineProperty( this, 'bouncing', {
+			get() {
 
 
-	this._bouncing = bouncing;
-	Object.defineProperty( this, 'bouncing', {
-		get() {
+				return this._bouncing;
 
 
-			return this._bouncing;
+			},
+			set( val ) {
 
 
-		},
-		set( val ) {
+				if ( this._bouncing === val ) return;
+				this._bouncing = val;
+				if ( val ) {
 
 
-			if ( this._bouncing === val ) return;
-			this._bouncing = val;
-			if ( val ) {
+					this.ssrMaterial.uniforms[ 'tDiffuse' ].value = this.prevRenderTarget.texture;
 
 
-				this.ssrMaterial.uniforms[ 'tDiffuse' ].value = this.prevRenderTarget.texture;
+				} else {
 
 
-			} else {
+					this.ssrMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
 
 
-				this.ssrMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
+				}
 
 
 			}
 			}
+		} );
 
 
-		}
-	} );
+		this.blur = true;
 
 
-	this.blur = true;
+		this._distanceAttenuation = SSRShader.defines.DISTANCE_ATTENUATION;
+		Object.defineProperty( this, 'distanceAttenuation', {
+			get() {
 
 
-	this._distanceAttenuation = SSRShader.defines.DISTANCE_ATTENUATION;
-	Object.defineProperty( this, 'distanceAttenuation', {
-		get() {
+				return this._distanceAttenuation;
 
 
-			return this._distanceAttenuation;
+			},
+			set( val ) {
 
 
-		},
-		set( val ) {
+				if ( this._distanceAttenuation === val ) return;
+				this._distanceAttenuation = val;
+				this.ssrMaterial.defines.DISTANCE_ATTENUATION = val;
+				this.ssrMaterial.needsUpdate = true;
 
 
-			if ( this._distanceAttenuation === val ) return;
-			this._distanceAttenuation = val;
-			this.ssrMaterial.defines.DISTANCE_ATTENUATION = val;
-			this.ssrMaterial.needsUpdate = true;
+			}
+		} );
 
 
-		}
-	} );
 
 
+		this._fresnel = SSRShader.defines.FRESNEL;
+		Object.defineProperty( this, 'fresnel', {
+			get() {
 
 
-	this._fresnel = SSRShader.defines.FRESNEL;
-	Object.defineProperty( this, 'fresnel', {
-		get() {
+				return this._fresnel;
 
 
-			return this._fresnel;
+			},
+			set( val ) {
 
 
-		},
-		set( val ) {
+				if ( this._fresnel === val ) return;
+				this._fresnel = val;
+				this.ssrMaterial.defines.FRESNEL = val;
+				this.ssrMaterial.needsUpdate = true;
 
 
-			if ( this._fresnel === val ) return;
-			this._fresnel = val;
-			this.ssrMaterial.defines.FRESNEL = val;
-			this.ssrMaterial.needsUpdate = true;
+			}
+		} );
 
 
-		}
-	} );
+		this._infiniteThick = SSRShader.defines.INFINITE_THICK;
+		Object.defineProperty( this, 'infiniteThick', {
+			get() {
 
 
-	this._infiniteThick = SSRShader.defines.INFINITE_THICK;
-	Object.defineProperty( this, 'infiniteThick', {
-		get() {
+				return this._infiniteThick;
 
 
-			return this._infiniteThick;
+			},
+			set( val ) {
 
 
-		},
-		set( val ) {
+				if ( this._infiniteThick === val ) return;
+				this._infiniteThick = val;
+				this.ssrMaterial.defines.INFINITE_THICK = val;
+				this.ssrMaterial.needsUpdate = true;
 
 
-			if ( this._infiniteThick === val ) return;
-			this._infiniteThick = val;
-			this.ssrMaterial.defines.INFINITE_THICK = val;
-			this.ssrMaterial.needsUpdate = true;
+			}
+		} );
+		this.thickTolerance = SSRShader.uniforms.thickTolerance.value;
 
 
-		}
-	} );
-	this.thickTolerance = SSRShader.uniforms.thickTolerance.value;
+		// beauty render target with depth buffer
+
+		const depthTexture = new DepthTexture();
+		depthTexture.type = UnsignedShortType;
+		depthTexture.minFilter = NearestFilter;
+		depthTexture.magFilter = NearestFilter;
+
+		this.beautyRenderTarget = new WebGLRenderTarget( this.width, this.height, {
+			minFilter: LinearFilter,
+			magFilter: LinearFilter,
+			format: RGBAFormat,
+			depthTexture: depthTexture,
+			depthBuffer: true
+		} );
+
+		//for bouncing
+		this.prevRenderTarget = new WebGLRenderTarget( this.width, this.height, {
+			minFilter: LinearFilter,
+			magFilter: LinearFilter,
+			format: RGBAFormat,
+		} );
 
 
-	// beauty render target with depth buffer
+		// normal render target
 
 
-	var depthTexture = new DepthTexture();
-	depthTexture.type = UnsignedShortType;
-	depthTexture.minFilter = NearestFilter;
-	depthTexture.magFilter = NearestFilter;
+		this.normalRenderTarget = new WebGLRenderTarget( this.width, this.height, {
+			minFilter: NearestFilter,
+			magFilter: NearestFilter,
+			format: RGBAFormat,
+			type: HalfFloatType,
+		} );
+
+		// metalness render target
+
+		this.metalnessRenderTarget = new WebGLRenderTarget( this.width, this.height, {
+			minFilter: NearestFilter,
+			magFilter: NearestFilter,
+			format: RGBAFormat
+		} );
 
 
-	this.beautyRenderTarget = new WebGLRenderTarget( this.width, this.height, {
-		minFilter: LinearFilter,
-		magFilter: LinearFilter,
-		format: RGBAFormat,
-		depthTexture: depthTexture,
-		depthBuffer: true
-	} );
 
 
-	//for bouncing
-	this.prevRenderTarget = new WebGLRenderTarget( this.width, this.height, {
-		minFilter: LinearFilter,
-		magFilter: LinearFilter,
-		format: RGBAFormat,
-	} );
 
 
-	// normal render target
+		// ssr render target
 
 
-	this.normalRenderTarget = new WebGLRenderTarget( this.width, this.height, {
-		minFilter: NearestFilter,
-		magFilter: NearestFilter,
-		format: RGBAFormat,
-		type: HalfFloatType,
-	} );
+		this.ssrRenderTarget = new WebGLRenderTarget( this.width, this.height, {
+			minFilter: LinearFilter,
+			magFilter: LinearFilter,
+			format: RGBAFormat
+		} );
 
 
-	// metalness render target
+		this.blurRenderTarget = this.ssrRenderTarget.clone();
+		this.blurRenderTarget2 = this.ssrRenderTarget.clone();
+		// this.blurRenderTarget3 = this.ssrRenderTarget.clone();
 
 
-	this.metalnessRenderTarget = new WebGLRenderTarget( this.width, this.height, {
-		minFilter: NearestFilter,
-		magFilter: NearestFilter,
-		format: RGBAFormat
-	} );
+		// ssr material
 
 
+		if ( SSRShader === undefined ) {
 
 
+			console.error( 'THREE.SSRPass: The pass relies on SSRShader.' );
 
 
-	// ssr render target
+		}
 
 
-	this.ssrRenderTarget = new WebGLRenderTarget( this.width, this.height, {
-		minFilter: LinearFilter,
-		magFilter: LinearFilter,
-		format: RGBAFormat
-	} );
+		this.ssrMaterial = new ShaderMaterial( {
+			defines: Object.assign( {}, SSRShader.defines, {
+				MAX_STEP: Math.sqrt( this.width * this.width + this.height * this.height )
+			} ),
+			uniforms: UniformsUtils.clone( SSRShader.uniforms ),
+			vertexShader: SSRShader.vertexShader,
+			fragmentShader: SSRShader.fragmentShader,
+			blending: NoBlending
+		} );
 
 
-	this.blurRenderTarget = this.ssrRenderTarget.clone();
-	this.blurRenderTarget2 = this.ssrRenderTarget.clone();
-	// this.blurRenderTarget3 = this.ssrRenderTarget.clone();
+		this.ssrMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
+		this.ssrMaterial.uniforms[ 'tNormal' ].value = this.normalRenderTarget.texture;
+		this.ssrMaterial.defines.SELECTIVE = this.selective;
+		this.ssrMaterial.needsUpdate = true;
+		this.ssrMaterial.uniforms[ 'tMetalness' ].value = this.metalnessRenderTarget.texture;
+		this.ssrMaterial.uniforms[ 'tDepth' ].value = this.beautyRenderTarget.depthTexture;
+		this.ssrMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
+		this.ssrMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
+		this.ssrMaterial.uniforms[ 'surfDist' ].value = this.surfDist;
+		this.ssrMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height );
+		this.ssrMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
+		this.ssrMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
 
 
-	// ssr material
+		// normal material
 
 
-	if ( SSRShader === undefined ) {
+		this.normalMaterial = new MeshNormalMaterial( { morphTargets } );
+		this.normalMaterial.blending = NoBlending;
 
 
-		console.error( 'THREE.SSRPass: The pass relies on SSRShader.' );
+		// metalnessOn material
 
 
-	}
+		this.metalnessOnMaterial = new MeshBasicMaterial( {
+			color: 'white'
+		} );
 
 
-	this.ssrMaterial = new ShaderMaterial( {
-		defines: Object.assign( {}, SSRShader.defines, {
-			MAX_STEP: Math.sqrt( this.width * this.width + this.height * this.height )
-		} ),
-		uniforms: UniformsUtils.clone( SSRShader.uniforms ),
-		vertexShader: SSRShader.vertexShader,
-		fragmentShader: SSRShader.fragmentShader,
-		blending: NoBlending
-	} );
-
-	this.ssrMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
-	this.ssrMaterial.uniforms[ 'tNormal' ].value = this.normalRenderTarget.texture;
-	this.ssrMaterial.defines.SELECTIVE = this.selective;
-	this.ssrMaterial.needsUpdate = true;
-	this.ssrMaterial.uniforms[ 'tMetalness' ].value = this.metalnessRenderTarget.texture;
-	this.ssrMaterial.uniforms[ 'tDepth' ].value = this.beautyRenderTarget.depthTexture;
-	this.ssrMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
-	this.ssrMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
-	this.ssrMaterial.uniforms[ 'surfDist' ].value = this.surfDist;
-	this.ssrMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height );
-	this.ssrMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
-	this.ssrMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
-
-	// normal material
-
-	this.normalMaterial = new MeshNormalMaterial( { morphTargets } );
-	this.normalMaterial.blending = NoBlending;
-
-	// metalnessOn material
-
-	this.metalnessOnMaterial = new MeshBasicMaterial( {
-		color: 'white'
-	} );
-
-	// metalnessOff material
-
-	this.metalnessOffMaterial = new MeshBasicMaterial( {
-		color: 'black'
-	} );
-
-	// blur material
-
-	this.blurMaterial = new ShaderMaterial( {
-		defines: Object.assign( {}, SSRBlurShader.defines ),
-		uniforms: UniformsUtils.clone( SSRBlurShader.uniforms ),
-		vertexShader: SSRBlurShader.vertexShader,
-		fragmentShader: SSRBlurShader.fragmentShader
-	} );
-	this.blurMaterial.uniforms[ 'tDiffuse' ].value = this.ssrRenderTarget.texture;
-	this.blurMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height );
-
-	// blur material 2
-
-	this.blurMaterial2 = new ShaderMaterial( {
-		defines: Object.assign( {}, SSRBlurShader.defines ),
-		uniforms: UniformsUtils.clone( SSRBlurShader.uniforms ),
-		vertexShader: SSRBlurShader.vertexShader,
-		fragmentShader: SSRBlurShader.fragmentShader
-	} );
-	this.blurMaterial2.uniforms[ 'tDiffuse' ].value = this.blurRenderTarget.texture;
-	this.blurMaterial2.uniforms[ 'resolution' ].value.set( this.width, this.height );
-
-	// // blur material 3
-
-	// this.blurMaterial3 = new ShaderMaterial({
-	//   defines: Object.assign({}, SSRBlurShader.defines),
-	//   uniforms: UniformsUtils.clone(SSRBlurShader.uniforms),
-	//   vertexShader: SSRBlurShader.vertexShader,
-	//   fragmentShader: SSRBlurShader.fragmentShader
-	// });
-	// this.blurMaterial3.uniforms['tDiffuse'].value = this.blurRenderTarget2.texture;
-	// this.blurMaterial3.uniforms['resolution'].value.set(this.width, this.height);
-
-	// material for rendering the depth
-
-	this.depthRenderMaterial = new ShaderMaterial( {
-		defines: Object.assign( {}, SSRDepthShader.defines ),
-		uniforms: UniformsUtils.clone( SSRDepthShader.uniforms ),
-		vertexShader: SSRDepthShader.vertexShader,
-		fragmentShader: SSRDepthShader.fragmentShader,
-		blending: NoBlending
-	} );
-	this.depthRenderMaterial.uniforms[ 'tDepth' ].value = this.beautyRenderTarget.depthTexture;
-	this.depthRenderMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
-	this.depthRenderMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
-
-	// material for rendering the content of a render target
-
-	this.copyMaterial = new ShaderMaterial( {
-		uniforms: UniformsUtils.clone( CopyShader.uniforms ),
-		vertexShader: CopyShader.vertexShader,
-		fragmentShader: CopyShader.fragmentShader,
-		transparent: true,
-		depthTest: false,
-		depthWrite: false,
-		blendSrc: SrcAlphaFactor,
-		blendDst: OneMinusSrcAlphaFactor,
-		blendEquation: AddEquation,
-		blendSrcAlpha: SrcAlphaFactor,
-		blendDstAlpha: OneMinusSrcAlphaFactor,
-		blendEquationAlpha: AddEquation,
-		// premultipliedAlpha:true,
-	} );
-
-	this.fsQuad = new Pass.FullScreenQuad( null );
-
-	this.originalClearColor = new Color();
+		// metalnessOff material
 
 
-};
+		this.metalnessOffMaterial = new MeshBasicMaterial( {
+			color: 'black'
+		} );
 
 
-SSRPass.prototype = Object.assign( Object.create( Pass.prototype ), {
+		// blur material
 
 
-	constructor: SSRPass,
+		this.blurMaterial = new ShaderMaterial( {
+			defines: Object.assign( {}, SSRBlurShader.defines ),
+			uniforms: UniformsUtils.clone( SSRBlurShader.uniforms ),
+			vertexShader: SSRBlurShader.vertexShader,
+			fragmentShader: SSRBlurShader.fragmentShader
+		} );
+		this.blurMaterial.uniforms[ 'tDiffuse' ].value = this.ssrRenderTarget.texture;
+		this.blurMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height );
 
 
-	dispose: function () {
+		// blur material 2
+
+		this.blurMaterial2 = new ShaderMaterial( {
+			defines: Object.assign( {}, SSRBlurShader.defines ),
+			uniforms: UniformsUtils.clone( SSRBlurShader.uniforms ),
+			vertexShader: SSRBlurShader.vertexShader,
+			fragmentShader: SSRBlurShader.fragmentShader
+		} );
+		this.blurMaterial2.uniforms[ 'tDiffuse' ].value = this.blurRenderTarget.texture;
+		this.blurMaterial2.uniforms[ 'resolution' ].value.set( this.width, this.height );
+
+		// // blur material 3
+
+		// this.blurMaterial3 = new ShaderMaterial({
+		//   defines: Object.assign({}, SSRBlurShader.defines),
+		//   uniforms: UniformsUtils.clone(SSRBlurShader.uniforms),
+		//   vertexShader: SSRBlurShader.vertexShader,
+		//   fragmentShader: SSRBlurShader.fragmentShader
+		// });
+		// this.blurMaterial3.uniforms['tDiffuse'].value = this.blurRenderTarget2.texture;
+		// this.blurMaterial3.uniforms['resolution'].value.set(this.width, this.height);
+
+		// material for rendering the depth
+
+		this.depthRenderMaterial = new ShaderMaterial( {
+			defines: Object.assign( {}, SSRDepthShader.defines ),
+			uniforms: UniformsUtils.clone( SSRDepthShader.uniforms ),
+			vertexShader: SSRDepthShader.vertexShader,
+			fragmentShader: SSRDepthShader.fragmentShader,
+			blending: NoBlending
+		} );
+		this.depthRenderMaterial.uniforms[ 'tDepth' ].value = this.beautyRenderTarget.depthTexture;
+		this.depthRenderMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
+		this.depthRenderMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
+
+		// material for rendering the content of a render target
+
+		this.copyMaterial = new ShaderMaterial( {
+			uniforms: UniformsUtils.clone( CopyShader.uniforms ),
+			vertexShader: CopyShader.vertexShader,
+			fragmentShader: CopyShader.fragmentShader,
+			transparent: true,
+			depthTest: false,
+			depthWrite: false,
+			blendSrc: SrcAlphaFactor,
+			blendDst: OneMinusSrcAlphaFactor,
+			blendEquation: AddEquation,
+			blendSrcAlpha: SrcAlphaFactor,
+			blendDstAlpha: OneMinusSrcAlphaFactor,
+			blendEquationAlpha: AddEquation,
+			// premultipliedAlpha:true,
+		} );
+
+		this.fsQuad = new FullScreenQuad( null );
+
+		this.originalClearColor = new Color();
+
+	}
+
+	dispose() {
 
 
 		// dispose render targets
 		// dispose render targets
 
 
@@ -357,9 +355,9 @@ SSRPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		this.fsQuad.dispose();
 		this.fsQuad.dispose();
 
 
-	},
+	}
 
 
-	render: function ( renderer, writeBuffer /*, readBuffer, deltaTime, maskActive */ ) {
+	render( renderer, writeBuffer /*, readBuffer, deltaTime, maskActive */ ) {
 
 
 		// render beauty and depth
 		// render beauty and depth
 
 
@@ -508,14 +506,14 @@ SSRPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		}
 		}
 
 
-	},
+	}
 
 
-	renderPass: function ( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
+	renderPass( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
 		// save original state
 		// save original state
 		this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
 		this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
-		var originalClearAlpha = renderer.getClearAlpha( this.tempColor );
-		var originalAutoClear = renderer.autoClear;
+		const originalClearAlpha = renderer.getClearAlpha( this.tempColor );
+		const originalAutoClear = renderer.autoClear;
 
 
 		renderer.setRenderTarget( renderTarget );
 		renderer.setRenderTarget( renderTarget );
 
 
@@ -537,13 +535,13 @@ SSRPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 		renderer.setClearColor( this.originalClearColor );
 		renderer.setClearColor( this.originalClearColor );
 		renderer.setClearAlpha( originalClearAlpha );
 		renderer.setClearAlpha( originalClearAlpha );
 
 
-	},
+	}
 
 
-	renderOverride: function ( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
+	renderOverride( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
 		this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
 		this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
-		var originalClearAlpha = renderer.getClearAlpha( this.tempColor );
-		var originalAutoClear = renderer.autoClear;
+		const originalClearAlpha = renderer.getClearAlpha( this.tempColor );
+		const originalAutoClear = renderer.autoClear;
 
 
 		renderer.setRenderTarget( renderTarget );
 		renderer.setRenderTarget( renderTarget );
 		renderer.autoClear = false;
 		renderer.autoClear = false;
@@ -569,13 +567,13 @@ SSRPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 		renderer.setClearColor( this.originalClearColor );
 		renderer.setClearColor( this.originalClearColor );
 		renderer.setClearAlpha( originalClearAlpha );
 		renderer.setClearAlpha( originalClearAlpha );
 
 
-	},
+	}
 
 
-	renderMetalness: function ( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
+	renderMetalness( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
 		this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
 		this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
-		var originalClearAlpha = renderer.getClearAlpha( this.tempColor );
-		var originalAutoClear = renderer.autoClear;
+		const originalClearAlpha = renderer.getClearAlpha( this.tempColor );
+		const originalAutoClear = renderer.autoClear;
 
 
 		renderer.setRenderTarget( renderTarget );
 		renderer.setRenderTarget( renderTarget );
 		renderer.autoClear = false;
 		renderer.autoClear = false;
@@ -618,9 +616,9 @@ SSRPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 		renderer.setClearColor( this.originalClearColor );
 		renderer.setClearColor( this.originalClearColor );
 		renderer.setClearAlpha( originalClearAlpha );
 		renderer.setClearAlpha( originalClearAlpha );
 
 
-	},
+	}
 
 
-	setSize: function ( width, height ) {
+	setSize( width, height ) {
 
 
 		this.width = width;
 		this.width = width;
 		this.height = height;
 		this.height = height;
@@ -643,9 +641,9 @@ SSRPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 		this.blurMaterial.uniforms[ 'resolution' ].value.set( width, height );
 		this.blurMaterial.uniforms[ 'resolution' ].value.set( width, height );
 		this.blurMaterial2.uniforms[ 'resolution' ].value.set( width, height );
 		this.blurMaterial2.uniforms[ 'resolution' ].value.set( width, height );
 
 
-	},
+	}
 
 
-} );
+}
 
 
 SSRPass.OUTPUT = {
 SSRPass.OUTPUT = {
 	'Default': 0,
 	'Default': 0,

+ 200 - 203
examples/jsm/postprocessing/SSRrPass.js

@@ -17,238 +17,236 @@ import {
 	HalfFloatType,
 	HalfFloatType,
 	MeshStandardMaterial
 	MeshStandardMaterial
 } from '../../../build/three.module.js';
 } from '../../../build/three.module.js';
-import { Pass } from '../postprocessing/Pass.js';
+import { Pass, FullScreenQuad } from '../postprocessing/Pass.js';
 import { SSRrShader } from '../shaders/SSRrShader.js';
 import { SSRrShader } from '../shaders/SSRrShader.js';
 import { SSRrDepthShader } from '../shaders/SSRrShader.js';
 import { SSRrDepthShader } from '../shaders/SSRrShader.js';
 import { CopyShader } from '../shaders/CopyShader.js';
 import { CopyShader } from '../shaders/CopyShader.js';
 
 
-var SSRrPass = function ( { renderer, scene, camera, width, height, selects, encoding, morphTargets = false } ) {
+class SSRrPass extends Pass {
 
 
-	Pass.call( this );
+	constructor( { renderer, scene, camera, width, height, selects, encoding, morphTargets = false } ) {
 
 
-	this.width = ( width !== undefined ) ? width : 512;
-	this.height = ( height !== undefined ) ? height : 512;
+		super();
 
 
-	this.clear = true;
+		this.width = ( width !== undefined ) ? width : 512;
+		this.height = ( height !== undefined ) ? height : 512;
 
 
-	this.renderer = renderer;
-	this.scene = scene;
-	this.camera = camera;
+		this.clear = true;
 
 
-	this.output = 0;
-	// this.output = 1;
+		this.renderer = renderer;
+		this.scene = scene;
+		this.camera = camera;
 
 
-	this.ior = SSRrShader.uniforms.ior.value;
-	this.maxDistance = SSRrShader.uniforms.maxDistance.value;
-	this.surfDist = SSRrShader.uniforms.surfDist.value;
+		this.output = 0;
+		// this.output = 1;
 
 
-	this.encoding = encoding;
+		this.ior = SSRrShader.uniforms.ior.value;
+		this.maxDistance = SSRrShader.uniforms.maxDistance.value;
+		this.surfDist = SSRrShader.uniforms.surfDist.value;
 
 
-	this.tempColor = new Color();
+		this.encoding = encoding;
 
 
-	this.selects = selects;
+		this.tempColor = new Color();
 
 
-	this._specular = SSRrShader.defines.SPECULAR;
-	Object.defineProperty( this, 'specular', {
-		get() {
+		this.selects = selects;
 
 
-			return this._specular;
+		this._specular = SSRrShader.defines.SPECULAR;
+		Object.defineProperty( this, 'specular', {
+			get() {
 
 
-		},
-		set( val ) {
+				return this._specular;
 
 
-			if ( this._specular === val ) return;
-			this._specular = val;
-			this.ssrrMaterial.defines.SPECULAR = val;
-			this.ssrrMaterial.needsUpdate = true;
+			},
+			set( val ) {
 
 
-		}
-	} );
+				if ( this._specular === val ) return;
+				this._specular = val;
+				this.ssrrMaterial.defines.SPECULAR = val;
+				this.ssrrMaterial.needsUpdate = true;
 
 
-	this._fillHole = SSRrShader.defines.FILL_HOLE;
-	Object.defineProperty( this, 'fillHole', {
-		get() {
+			}
+		} );
 
 
-			return this._fillHole;
+		this._fillHole = SSRrShader.defines.FILL_HOLE;
+		Object.defineProperty( this, 'fillHole', {
+			get() {
 
 
-		},
-		set( val ) {
+				return this._fillHole;
 
 
-			if ( this._fillHole === val ) return;
-			this._fillHole = val;
-			this.ssrrMaterial.defines.FILL_HOLE = val;
-			this.ssrrMaterial.needsUpdate = true;
+			},
+			set( val ) {
 
 
-		}
-	} );
+				if ( this._fillHole === val ) return;
+				this._fillHole = val;
+				this.ssrrMaterial.defines.FILL_HOLE = val;
+				this.ssrrMaterial.needsUpdate = true;
 
 
-	this._infiniteThick = SSRrShader.defines.INFINITE_THICK;
-	Object.defineProperty( this, 'infiniteThick', {
-		get() {
+			}
+		} );
 
 
-			return this._infiniteThick;
+		this._infiniteThick = SSRrShader.defines.INFINITE_THICK;
+		Object.defineProperty( this, 'infiniteThick', {
+			get() {
 
 
-		},
-		set( val ) {
+				return this._infiniteThick;
 
 
-			if ( this._infiniteThick === val ) return;
-			this._infiniteThick = val;
-			this.ssrrMaterial.defines.INFINITE_THICK = val;
-			this.ssrrMaterial.needsUpdate = true;
+			},
+			set( val ) {
 
 
-		}
-	} );
+				if ( this._infiniteThick === val ) return;
+				this._infiniteThick = val;
+				this.ssrrMaterial.defines.INFINITE_THICK = val;
+				this.ssrrMaterial.needsUpdate = true;
 
 
-	// beauty render target with depth buffer
+			}
+		} );
 
 
-	var depthTexture = new DepthTexture();
-	depthTexture.type = UnsignedShortType;
-	depthTexture.minFilter = NearestFilter;
-	depthTexture.magFilter = NearestFilter;
+		// beauty render target with depth buffer
 
 
-	this.beautyRenderTarget = new WebGLRenderTarget( this.width, this.height, {
-		minFilter: NearestFilter,
-		magFilter: NearestFilter,
-		format: RGBAFormat,
-		depthTexture: depthTexture,
-		depthBuffer: true
-	} );
+		const depthTexture = new DepthTexture();
+		depthTexture.type = UnsignedShortType;
+		depthTexture.minFilter = NearestFilter;
+		depthTexture.magFilter = NearestFilter;
 
 
-	this.specularRenderTarget = new WebGLRenderTarget( this.width, this.height, { // TODO: Can merge with refractiveRenderTarget?
-		minFilter: NearestFilter,
-		magFilter: NearestFilter,
-		format: RGBAFormat,
-	} );
+		this.beautyRenderTarget = new WebGLRenderTarget( this.width, this.height, {
+			minFilter: NearestFilter,
+			magFilter: NearestFilter,
+			format: RGBAFormat,
+			depthTexture: depthTexture,
+			depthBuffer: true
+		} );
 
 
-	// normalSelects render target
+		this.specularRenderTarget = new WebGLRenderTarget( this.width, this.height, { // TODO: Can merge with refractiveRenderTarget?
+			minFilter: NearestFilter,
+			magFilter: NearestFilter,
+			format: RGBAFormat,
+		} );
 
 
-	var depthTextureSelects = new DepthTexture();
-	depthTextureSelects.type = UnsignedShortType;
-	depthTextureSelects.minFilter = NearestFilter;
-	depthTextureSelects.magFilter = NearestFilter;
+		// normalSelects render target
 
 
-	this.normalSelectsRenderTarget = new WebGLRenderTarget( this.width, this.height, {
-		minFilter: NearestFilter,
-		magFilter: NearestFilter,
-		format: RGBAFormat,
-		type: HalfFloatType,
-		depthTexture: depthTextureSelects,
-		depthBuffer: true
-	} );
+		const depthTextureSelects = new DepthTexture();
+		depthTextureSelects.type = UnsignedShortType;
+		depthTextureSelects.minFilter = NearestFilter;
+		depthTextureSelects.magFilter = NearestFilter;
 
 
-	// refractive render target
+		this.normalSelectsRenderTarget = new WebGLRenderTarget( this.width, this.height, {
+			minFilter: NearestFilter,
+			magFilter: NearestFilter,
+			format: RGBAFormat,
+			type: HalfFloatType,
+			depthTexture: depthTextureSelects,
+			depthBuffer: true
+		} );
 
 
-	this.refractiveRenderTarget = new WebGLRenderTarget( this.width, this.height, {
-		minFilter: NearestFilter,
-		magFilter: NearestFilter,
-		format: RGBAFormat
-	} );
+		// refractive render target
 
 
-	// ssrr render target
+		this.refractiveRenderTarget = new WebGLRenderTarget( this.width, this.height, {
+			minFilter: NearestFilter,
+			magFilter: NearestFilter,
+			format: RGBAFormat
+		} );
 
 
-	this.ssrrRenderTarget = new WebGLRenderTarget( this.width, this.height, {
-		minFilter: NearestFilter,
-		magFilter: NearestFilter,
-		format: RGBAFormat
-	} );
+		// ssrr render target
 
 
-	// ssrr material
+		this.ssrrRenderTarget = new WebGLRenderTarget( this.width, this.height, {
+			minFilter: NearestFilter,
+			magFilter: NearestFilter,
+			format: RGBAFormat
+		} );
 
 
-	if ( SSRrShader === undefined ) {
+		// ssrr material
 
 
-		console.error( 'THREE.SSRrPass: The pass relies on SSRrShader.' );
+		if ( SSRrShader === undefined ) {
 
 
-	}
+			console.error( 'THREE.SSRrPass: The pass relies on SSRrShader.' );
 
 
-	this.ssrrMaterial = new ShaderMaterial( {
-		defines: Object.assign( {}, SSRrShader.defines, {
-			MAX_STEP: Math.sqrt( this.width * this.width + this.height * this.height )
-		} ),
-		uniforms: UniformsUtils.clone( SSRrShader.uniforms ),
-		vertexShader: SSRrShader.vertexShader,
-		fragmentShader: SSRrShader.fragmentShader,
-		blending: NoBlending
-	} );
-
-	this.ssrrMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
-	this.ssrrMaterial.uniforms[ 'tSpecular' ].value = this.specularRenderTarget.texture;
-	this.ssrrMaterial.uniforms[ 'tNormalSelects' ].value = this.normalSelectsRenderTarget.texture;
-	this.ssrrMaterial.needsUpdate = true;
-	this.ssrrMaterial.uniforms[ 'tRefractive' ].value = this.refractiveRenderTarget.texture;
-	this.ssrrMaterial.uniforms[ 'tDepth' ].value = this.beautyRenderTarget.depthTexture;
-	this.ssrrMaterial.uniforms[ 'tDepthSelects' ].value = this.normalSelectsRenderTarget.depthTexture;
-	this.ssrrMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
-	this.ssrrMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
-	this.ssrrMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height );
-	this.ssrrMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
-	this.ssrrMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
-
-	// normal material
-
-	this.normalMaterial = new MeshNormalMaterial( { morphTargets } );
-	this.normalMaterial.blending = NoBlending;
-
-	// refractiveOn material
-
-	this.refractiveOnMaterial = new MeshBasicMaterial( {
-		color: 'white'
-	} );
-
-	// refractiveOff material
-
-	this.refractiveOffMaterial = new MeshBasicMaterial( {
-		color: 'black'
-	} );
-
-	// specular material
-	this.specularMaterial = new MeshStandardMaterial( {
-		color: 'black',
-		metalness: 0,
-		roughness: .2,
-	} );
-
-	// material for rendering the depth
-
-	this.depthRenderMaterial = new ShaderMaterial( {
-		defines: Object.assign( {}, SSRrDepthShader.defines ),
-		uniforms: UniformsUtils.clone( SSRrDepthShader.uniforms ),
-		vertexShader: SSRrDepthShader.vertexShader,
-		fragmentShader: SSRrDepthShader.fragmentShader,
-		blending: NoBlending
-	} );
-	this.depthRenderMaterial.uniforms[ 'tDepth' ].value = this.beautyRenderTarget.depthTexture;
-	this.depthRenderMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
-	this.depthRenderMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
-
-	// material for rendering the content of a render target
-
-	this.copyMaterial = new ShaderMaterial( {
-		uniforms: UniformsUtils.clone( CopyShader.uniforms ),
-		vertexShader: CopyShader.vertexShader,
-		fragmentShader: CopyShader.fragmentShader,
-		transparent: true,
-		depthTest: false,
-		depthWrite: false,
-		blendSrc: SrcAlphaFactor,
-		blendDst: OneMinusSrcAlphaFactor,
-		blendEquation: AddEquation,
-		blendSrcAlpha: SrcAlphaFactor,
-		blendDstAlpha: OneMinusSrcAlphaFactor,
-		blendEquationAlpha: AddEquation,
-		// premultipliedAlpha:true,
-	} );
-
-	this.fsQuad = new Pass.FullScreenQuad( null );
-
-	this.originalClearColor = new Color();
+		}
 
 
-};
+		this.ssrrMaterial = new ShaderMaterial( {
+			defines: Object.assign( {}, SSRrShader.defines, {
+				MAX_STEP: Math.sqrt( this.width * this.width + this.height * this.height )
+			} ),
+			uniforms: UniformsUtils.clone( SSRrShader.uniforms ),
+			vertexShader: SSRrShader.vertexShader,
+			fragmentShader: SSRrShader.fragmentShader,
+			blending: NoBlending
+		} );
+
+		this.ssrrMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
+		this.ssrrMaterial.uniforms[ 'tSpecular' ].value = this.specularRenderTarget.texture;
+		this.ssrrMaterial.uniforms[ 'tNormalSelects' ].value = this.normalSelectsRenderTarget.texture;
+		this.ssrrMaterial.needsUpdate = true;
+		this.ssrrMaterial.uniforms[ 'tRefractive' ].value = this.refractiveRenderTarget.texture;
+		this.ssrrMaterial.uniforms[ 'tDepth' ].value = this.beautyRenderTarget.depthTexture;
+		this.ssrrMaterial.uniforms[ 'tDepthSelects' ].value = this.normalSelectsRenderTarget.depthTexture;
+		this.ssrrMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
+		this.ssrrMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
+		this.ssrrMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height );
+		this.ssrrMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
+		this.ssrrMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
 
 
-SSRrPass.prototype = Object.assign( Object.create( Pass.prototype ), {
+		// normal material
 
 
-	constructor: SSRrPass,
+		this.normalMaterial = new MeshNormalMaterial( { morphTargets } );
+		this.normalMaterial.blending = NoBlending;
 
 
-	dispose: function () {
+		// refractiveOn material
+
+		this.refractiveOnMaterial = new MeshBasicMaterial( {
+			color: 'white'
+		} );
+
+		// refractiveOff material
+
+		this.refractiveOffMaterial = new MeshBasicMaterial( {
+			color: 'black'
+		} );
+
+		// specular material
+		this.specularMaterial = new MeshStandardMaterial( {
+			color: 'black',
+			metalness: 0,
+			roughness: .2,
+		} );
+
+		// material for rendering the depth
+
+		this.depthRenderMaterial = new ShaderMaterial( {
+			defines: Object.assign( {}, SSRrDepthShader.defines ),
+			uniforms: UniformsUtils.clone( SSRrDepthShader.uniforms ),
+			vertexShader: SSRrDepthShader.vertexShader,
+			fragmentShader: SSRrDepthShader.fragmentShader,
+			blending: NoBlending
+		} );
+		this.depthRenderMaterial.uniforms[ 'tDepth' ].value = this.beautyRenderTarget.depthTexture;
+		this.depthRenderMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
+		this.depthRenderMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
+
+		// material for rendering the content of a render target
+
+		this.copyMaterial = new ShaderMaterial( {
+			uniforms: UniformsUtils.clone( CopyShader.uniforms ),
+			vertexShader: CopyShader.vertexShader,
+			fragmentShader: CopyShader.fragmentShader,
+			transparent: true,
+			depthTest: false,
+			depthWrite: false,
+			blendSrc: SrcAlphaFactor,
+			blendDst: OneMinusSrcAlphaFactor,
+			blendEquation: AddEquation,
+			blendSrcAlpha: SrcAlphaFactor,
+			blendDstAlpha: OneMinusSrcAlphaFactor,
+			blendEquationAlpha: AddEquation,
+			// premultipliedAlpha:true,
+		} );
+
+		this.fsQuad = new FullScreenQuad( null );
+
+		this.originalClearColor = new Color();
+
+	}
+
+	dispose() {
 
 
 		// dispose render targets
 		// dispose render targets
 
 
@@ -270,9 +268,9 @@ SSRrPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		this.fsQuad.dispose();
 		this.fsQuad.dispose();
 
 
-	},
+	}
 
 
-	render: function ( renderer, writeBuffer /*, readBuffer, deltaTime, maskActive */ ) {
+	render( renderer, writeBuffer /*, readBuffer, deltaTime, maskActive */ ) {
 
 
 		// render beauty and depth
 		// render beauty and depth
 
 
@@ -426,14 +424,14 @@ SSRrPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		}
 		}
 
 
-	},
+	}
 
 
-	renderPass: function ( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
+	renderPass( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
 		// save original state
 		// save original state
 		this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
 		this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
-		var originalClearAlpha = renderer.getClearAlpha( this.tempColor );
-		var originalAutoClear = renderer.autoClear;
+		const originalClearAlpha = renderer.getClearAlpha( this.tempColor );
+		const originalAutoClear = renderer.autoClear;
 
 
 		renderer.setRenderTarget( renderTarget );
 		renderer.setRenderTarget( renderTarget );
 
 
@@ -455,13 +453,13 @@ SSRrPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 		renderer.setClearColor( this.originalClearColor );
 		renderer.setClearColor( this.originalClearColor );
 		renderer.setClearAlpha( originalClearAlpha );
 		renderer.setClearAlpha( originalClearAlpha );
 
 
-	},
+	}
 
 
-	renderOverride: function ( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
+	renderOverride( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
 		this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
 		this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
-		var originalClearAlpha = renderer.getClearAlpha( this.tempColor );
-		var originalAutoClear = renderer.autoClear;
+		const originalClearAlpha = renderer.getClearAlpha( this.tempColor );
+		const originalAutoClear = renderer.autoClear;
 
 
 		renderer.setRenderTarget( renderTarget );
 		renderer.setRenderTarget( renderTarget );
 		renderer.autoClear = false;
 		renderer.autoClear = false;
@@ -487,14 +485,13 @@ SSRrPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 		renderer.setClearColor( this.originalClearColor );
 		renderer.setClearColor( this.originalClearColor );
 		renderer.setClearAlpha( originalClearAlpha );
 		renderer.setClearAlpha( originalClearAlpha );
 
 
-	},
-
+	}
 
 
-	renderRefractive: function ( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
+	renderRefractive( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
 
 
 		this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
 		this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
-		var originalClearAlpha = renderer.getClearAlpha( this.tempColor );
-		var originalAutoClear = renderer.autoClear;
+		const originalClearAlpha = renderer.getClearAlpha( this.tempColor );
+		const originalAutoClear = renderer.autoClear;
 
 
 		renderer.setRenderTarget( renderTarget );
 		renderer.setRenderTarget( renderTarget );
 		renderer.autoClear = false;
 		renderer.autoClear = false;
@@ -548,9 +545,9 @@ SSRrPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 		renderer.setClearColor( this.originalClearColor );
 		renderer.setClearColor( this.originalClearColor );
 		renderer.setClearAlpha( originalClearAlpha );
 		renderer.setClearAlpha( originalClearAlpha );
 
 
-	},
+	}
 
 
-	setSize: function ( width, height ) {
+	setSize( width, height ) {
 
 
 		this.width = width;
 		this.width = width;
 		this.height = height;
 		this.height = height;
@@ -567,9 +564,9 @@ SSRrPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 		this.ssrrMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
 		this.ssrrMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
 		this.ssrrMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
 		this.ssrrMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
 
 
-	},
+	}
 
 
-} );
+}
 
 
 SSRrPass.OUTPUT = {
 SSRrPass.OUTPUT = {
 	'Default': 0,
 	'Default': 0,

+ 23 - 26
examples/jsm/postprocessing/SavePass.js

@@ -5,50 +5,47 @@ import {
 	UniformsUtils,
 	UniformsUtils,
 	WebGLRenderTarget
 	WebGLRenderTarget
 } from '../../../build/three.module.js';
 } from '../../../build/three.module.js';
-import { Pass } from '../postprocessing/Pass.js';
+import { Pass, FullScreenQuad } from '../postprocessing/Pass.js';
 import { CopyShader } from '../shaders/CopyShader.js';
 import { CopyShader } from '../shaders/CopyShader.js';
 
 
-var SavePass = function ( renderTarget ) {
+class SavePass extends Pass {
 
 
-	Pass.call( this );
+	constructor( renderTarget ) {
 
 
-	if ( CopyShader === undefined )
-		console.error( 'THREE.SavePass relies on CopyShader' );
+		super();
 
 
-	var shader = CopyShader;
+		if ( CopyShader === undefined ) console.error( 'THREE.SavePass relies on CopyShader' );
 
 
-	this.textureID = 'tDiffuse';
+		const shader = CopyShader;
 
 
-	this.uniforms = UniformsUtils.clone( shader.uniforms );
+		this.textureID = 'tDiffuse';
 
 
-	this.material = new ShaderMaterial( {
+		this.uniforms = UniformsUtils.clone( shader.uniforms );
 
 
-		uniforms: this.uniforms,
-		vertexShader: shader.vertexShader,
-		fragmentShader: shader.fragmentShader
+		this.material = new ShaderMaterial( {
 
 
-	} );
+			uniforms: this.uniforms,
+			vertexShader: shader.vertexShader,
+			fragmentShader: shader.fragmentShader
 
 
-	this.renderTarget = renderTarget;
+		} );
 
 
-	if ( this.renderTarget === undefined ) {
+		this.renderTarget = renderTarget;
 
 
-		this.renderTarget = new WebGLRenderTarget( window.innerWidth, window.innerHeight, { minFilter: LinearFilter, magFilter: LinearFilter, format: RGBFormat } );
-		this.renderTarget.texture.name = 'SavePass.rt';
+		if ( this.renderTarget === undefined ) {
 
 
-	}
-
-	this.needsSwap = false;
+			this.renderTarget = new WebGLRenderTarget( window.innerWidth, window.innerHeight, { minFilter: LinearFilter, magFilter: LinearFilter, format: RGBFormat } );
+			this.renderTarget.texture.name = 'SavePass.rt';
 
 
-	this.fsQuad = new Pass.FullScreenQuad( this.material );
+		}
 
 
-};
+		this.needsSwap = false;
 
 
-SavePass.prototype = Object.assign( Object.create( Pass.prototype ), {
+		this.fsQuad = new FullScreenQuad( this.material );
 
 
-	constructor: SavePass,
+	}
 
 
-	render: function ( renderer, writeBuffer, readBuffer ) {
+	render( renderer, writeBuffer, readBuffer/*, deltaTime, maskActive */ ) {
 
 
 		if ( this.uniforms[ this.textureID ] ) {
 		if ( this.uniforms[ this.textureID ] ) {
 
 
@@ -62,6 +59,6 @@ SavePass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 	}
 	}
 
 
-} );
+}
 
 
 export { SavePass };
 export { SavePass };

+ 21 - 23
examples/jsm/postprocessing/ShaderPass.js

@@ -2,44 +2,42 @@ import {
 	ShaderMaterial,
 	ShaderMaterial,
 	UniformsUtils
 	UniformsUtils
 } from '../../../build/three.module.js';
 } from '../../../build/three.module.js';
-import { Pass } from '../postprocessing/Pass.js';
+import { Pass, FullScreenQuad } from '../postprocessing/Pass.js';
 
 
-var ShaderPass = function ( shader, textureID ) {
+class ShaderPass extends Pass {
 
 
-	Pass.call( this );
+	constructor( shader, textureID ) {
 
 
-	this.textureID = ( textureID !== undefined ) ? textureID : 'tDiffuse';
+		super();
 
 
-	if ( shader instanceof ShaderMaterial ) {
+		this.textureID = ( textureID !== undefined ) ? textureID : 'tDiffuse';
 
 
-		this.uniforms = shader.uniforms;
+		if ( shader instanceof ShaderMaterial ) {
 
 
-		this.material = shader;
+			this.uniforms = shader.uniforms;
 
 
-	} else if ( shader ) {
+			this.material = shader;
 
 
-		this.uniforms = UniformsUtils.clone( shader.uniforms );
+		} else if ( shader ) {
 
 
-		this.material = new ShaderMaterial( {
+			this.uniforms = UniformsUtils.clone( shader.uniforms );
 
 
-			defines: Object.assign( {}, shader.defines ),
-			uniforms: this.uniforms,
-			vertexShader: shader.vertexShader,
-			fragmentShader: shader.fragmentShader
+			this.material = new ShaderMaterial( {
 
 
-		} );
+				defines: Object.assign( {}, shader.defines ),
+				uniforms: this.uniforms,
+				vertexShader: shader.vertexShader,
+				fragmentShader: shader.fragmentShader
 
 
-	}
-
-	this.fsQuad = new Pass.FullScreenQuad( this.material );
+			} );
 
 
-};
+		}
 
 
-ShaderPass.prototype = Object.assign( Object.create( Pass.prototype ), {
+		this.fsQuad = new FullScreenQuad( this.material );
 
 
-	constructor: ShaderPass,
+	}
 
 
-	render: function ( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
+	render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
 
 
 		if ( this.uniforms[ this.textureID ] ) {
 		if ( this.uniforms[ this.textureID ] ) {
 
 
@@ -65,6 +63,6 @@ ShaderPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 	}
 	}
 
 
-} );
+}
 
 
 export { ShaderPass };
 export { ShaderPass };

+ 50 - 28
examples/jsm/postprocessing/TAARenderPass.js

@@ -15,39 +15,29 @@ import { SSAARenderPass } from '../postprocessing/SSAARenderPass.js';
  *
  *
  */
  */
 
 
-var TAARenderPass = function ( scene, camera, clearColor, clearAlpha ) {
+class TAARenderPass extends SSAARenderPass {
 
 
-	if ( SSAARenderPass === undefined ) {
+	constructor( scene, camera, clearColor, clearAlpha ) {
 
 
-		console.error( 'THREE.TAARenderPass relies on SSAARenderPass' );
+		super( scene, camera, clearColor, clearAlpha );
 
 
-	}
-
-	SSAARenderPass.call( this, scene, camera, clearColor, clearAlpha );
-
-	this.sampleLevel = 0;
-	this.accumulate = false;
-
-};
+		this.sampleLevel = 0;
+		this.accumulate = false;
 
 
-TAARenderPass.JitterVectors = SSAARenderPass.JitterVectors;
-
-TAARenderPass.prototype = Object.assign( Object.create( SSAARenderPass.prototype ), {
-
-	constructor: TAARenderPass,
+	}
 
 
-	render: function ( renderer, writeBuffer, readBuffer, deltaTime ) {
+	render( renderer, writeBuffer, readBuffer, deltaTime ) {
 
 
 		if ( ! this.accumulate ) {
 		if ( ! this.accumulate ) {
 
 
-			SSAARenderPass.prototype.render.call( this, renderer, writeBuffer, readBuffer, deltaTime );
+			super.render( renderer, writeBuffer, readBuffer, deltaTime );
 
 
 			this.accumulateIndex = - 1;
 			this.accumulateIndex = - 1;
 			return;
 			return;
 
 
 		}
 		}
 
 
-		var jitterOffsets = TAARenderPass.JitterVectors[ 5 ];
+		const jitterOffsets = _JitterVectors[ 5 ];
 
 
 		if ( ! this.sampleRenderTarget ) {
 		if ( ! this.sampleRenderTarget ) {
 
 
@@ -65,16 +55,16 @@ TAARenderPass.prototype = Object.assign( Object.create( SSAARenderPass.prototype
 
 
 		if ( this.accumulate && this.accumulateIndex === - 1 ) {
 		if ( this.accumulate && this.accumulateIndex === - 1 ) {
 
 
-			SSAARenderPass.prototype.render.call( this, renderer, this.holdRenderTarget, readBuffer, deltaTime );
+			super.render( renderer, this.holdRenderTarget, readBuffer, deltaTime );
 
 
 			this.accumulateIndex = 0;
 			this.accumulateIndex = 0;
 
 
 		}
 		}
 
 
-		var autoClear = renderer.autoClear;
+		const autoClear = renderer.autoClear;
 		renderer.autoClear = false;
 		renderer.autoClear = false;
 
 
-		var sampleWeight = 1.0 / ( jitterOffsets.length );
+		const sampleWeight = 1.0 / ( jitterOffsets.length );
 
 
 		if ( this.accumulateIndex >= 0 && this.accumulateIndex < jitterOffsets.length ) {
 		if ( this.accumulateIndex >= 0 && this.accumulateIndex < jitterOffsets.length ) {
 
 
@@ -82,11 +72,11 @@ TAARenderPass.prototype = Object.assign( Object.create( SSAARenderPass.prototype
 			this.copyUniforms[ 'tDiffuse' ].value = writeBuffer.texture;
 			this.copyUniforms[ 'tDiffuse' ].value = writeBuffer.texture;
 
 
 			// render the scene multiple times, each slightly jitter offset from the last and accumulate the results.
 			// render the scene multiple times, each slightly jitter offset from the last and accumulate the results.
-			var numSamplesPerFrame = Math.pow( 2, this.sampleLevel );
-			for ( var i = 0; i < numSamplesPerFrame; i ++ ) {
+			const numSamplesPerFrame = Math.pow( 2, this.sampleLevel );
+			for ( let i = 0; i < numSamplesPerFrame; i ++ ) {
 
 
-				var j = this.accumulateIndex;
-				var jitterOffset = jitterOffsets[ j ];
+				const j = this.accumulateIndex;
+				const jitterOffset = jitterOffsets[ j ];
 
 
 				if ( this.camera.setViewOffset ) {
 				if ( this.camera.setViewOffset ) {
 
 
@@ -114,7 +104,7 @@ TAARenderPass.prototype = Object.assign( Object.create( SSAARenderPass.prototype
 
 
 		}
 		}
 
 
-		var accumulationWeight = this.accumulateIndex * sampleWeight;
+		const accumulationWeight = this.accumulateIndex * sampleWeight;
 
 
 		if ( accumulationWeight > 0 ) {
 		if ( accumulationWeight > 0 ) {
 
 
@@ -140,6 +130,38 @@ TAARenderPass.prototype = Object.assign( Object.create( SSAARenderPass.prototype
 
 
 	}
 	}
 
 
-} );
+}
+
+const _JitterVectors = [
+	[
+		[ 0, 0 ]
+	],
+	[
+		[ 4, 4 ], [ - 4, - 4 ]
+	],
+	[
+		[ - 2, - 6 ], [ 6, - 2 ], [ - 6, 2 ], [ 2, 6 ]
+	],
+	[
+		[ 1, - 3 ], [ - 1, 3 ], [ 5, 1 ], [ - 3, - 5 ],
+		[ - 5, 5 ], [ - 7, - 1 ], [ 3, 7 ], [ 7, - 7 ]
+	],
+	[
+		[ 1, 1 ], [ - 1, - 3 ], [ - 3, 2 ], [ 4, - 1 ],
+		[ - 5, - 2 ], [ 2, 5 ], [ 5, 3 ], [ 3, - 5 ],
+		[ - 2, 6 ], [ 0, - 7 ], [ - 4, - 6 ], [ - 6, 4 ],
+		[ - 8, 0 ], [ 7, - 4 ], [ 6, 7 ], [ - 7, - 8 ]
+	],
+	[
+		[ - 4, - 7 ], [ - 7, - 5 ], [ - 3, - 5 ], [ - 5, - 4 ],
+		[ - 1, - 4 ], [ - 2, - 2 ], [ - 6, - 1 ], [ - 4, 0 ],
+		[ - 7, 1 ], [ - 1, 2 ], [ - 6, 3 ], [ - 3, 3 ],
+		[ - 7, 6 ], [ - 3, 6 ], [ - 5, 7 ], [ - 1, 7 ],
+		[ 5, - 7 ], [ 1, - 6 ], [ 6, - 5 ], [ 4, - 4 ],
+		[ 2, - 3 ], [ 7, - 2 ], [ 1, - 1 ], [ 4, - 1 ],
+		[ 2, 1 ], [ 6, 2 ], [ 0, 4 ], [ 4, 4 ],
+		[ 2, 5 ], [ 7, 5 ], [ 5, 6 ], [ 3, 7 ]
+	]
+];
 
 
 export { TAARenderPass };
 export { TAARenderPass };

+ 22 - 25
examples/jsm/postprocessing/TexturePass.js

@@ -2,46 +2,43 @@ import {
 	ShaderMaterial,
 	ShaderMaterial,
 	UniformsUtils
 	UniformsUtils
 } from '../../../build/three.module.js';
 } from '../../../build/three.module.js';
-import { Pass } from '../postprocessing/Pass.js';
+import { Pass, FullScreenQuad } from '../postprocessing/Pass.js';
 import { CopyShader } from '../shaders/CopyShader.js';
 import { CopyShader } from '../shaders/CopyShader.js';
 
 
-var TexturePass = function ( map, opacity ) {
+class TexturePass extends Pass {
 
 
-	Pass.call( this );
+	constructor( map, opacity ) {
 
 
-	if ( CopyShader === undefined )
-		console.error( 'THREE.TexturePass relies on CopyShader' );
+		super();
 
 
-	var shader = CopyShader;
+		if ( CopyShader === undefined ) console.error( 'THREE.TexturePass relies on CopyShader' );
 
 
-	this.map = map;
-	this.opacity = ( opacity !== undefined ) ? opacity : 1.0;
+		const shader = CopyShader;
 
 
-	this.uniforms = UniformsUtils.clone( shader.uniforms );
+		this.map = map;
+		this.opacity = ( opacity !== undefined ) ? opacity : 1.0;
 
 
-	this.material = new ShaderMaterial( {
+		this.uniforms = UniformsUtils.clone( shader.uniforms );
 
 
-		uniforms: this.uniforms,
-		vertexShader: shader.vertexShader,
-		fragmentShader: shader.fragmentShader,
-		depthTest: false,
-		depthWrite: false
+		this.material = new ShaderMaterial( {
 
 
-	} );
+			uniforms: this.uniforms,
+			vertexShader: shader.vertexShader,
+			fragmentShader: shader.fragmentShader,
+			depthTest: false,
+			depthWrite: false
 
 
-	this.needsSwap = false;
+		} );
 
 
-	this.fsQuad = new Pass.FullScreenQuad( null );
+		this.needsSwap = false;
 
 
-};
+		this.fsQuad = new FullScreenQuad( null );
 
 
-TexturePass.prototype = Object.assign( Object.create( Pass.prototype ), {
-
-	constructor: TexturePass,
+	}
 
 
-	render: function ( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
+	render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
 
 
-		var oldAutoClear = renderer.autoClear;
+		const oldAutoClear = renderer.autoClear;
 		renderer.autoClear = false;
 		renderer.autoClear = false;
 
 
 		this.fsQuad.material = this.material;
 		this.fsQuad.material = this.material;
@@ -58,6 +55,6 @@ TexturePass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 	}
 	}
 
 
-} );
+}
 
 
 export { TexturePass };
 export { TexturePass };

+ 171 - 174
examples/jsm/postprocessing/UnrealBloomPass.js

@@ -10,7 +10,7 @@ import {
 	Vector3,
 	Vector3,
 	WebGLRenderTarget
 	WebGLRenderTarget
 } from '../../../build/three.module.js';
 } from '../../../build/three.module.js';
-import { Pass } from '../postprocessing/Pass.js';
+import { Pass, FullScreenQuad } from '../postprocessing/Pass.js';
 import { CopyShader } from '../shaders/CopyShader.js';
 import { CopyShader } from '../shaders/CopyShader.js';
 import { LuminosityHighPassShader } from '../shaders/LuminosityHighPassShader.js';
 import { LuminosityHighPassShader } from '../shaders/LuminosityHighPassShader.js';
 
 
@@ -23,152 +23,149 @@ import { LuminosityHighPassShader } from '../shaders/LuminosityHighPassShader.js
  * Reference:
  * Reference:
  * - https://docs.unrealengine.com/latest/INT/Engine/Rendering/PostProcessEffects/Bloom/
  * - https://docs.unrealengine.com/latest/INT/Engine/Rendering/PostProcessEffects/Bloom/
  */
  */
-var UnrealBloomPass = function ( resolution, strength, radius, threshold ) {
+class UnrealBloomPass extends Pass {
 
 
-	Pass.call( this );
+	constructor( resolution, strength, radius, threshold ) {
 
 
-	this.strength = ( strength !== undefined ) ? strength : 1;
-	this.radius = radius;
-	this.threshold = threshold;
-	this.resolution = ( resolution !== undefined ) ? new Vector2( resolution.x, resolution.y ) : new Vector2( 256, 256 );
+		super();
 
 
-	// create color only once here, reuse it later inside the render function
-	this.clearColor = new Color( 0, 0, 0 );
+		this.strength = ( strength !== undefined ) ? strength : 1;
+		this.radius = radius;
+		this.threshold = threshold;
+		this.resolution = ( resolution !== undefined ) ? new Vector2( resolution.x, resolution.y ) : new Vector2( 256, 256 );
 
 
-	// render targets
-	var pars = { minFilter: LinearFilter, magFilter: LinearFilter, format: RGBAFormat };
-	this.renderTargetsHorizontal = [];
-	this.renderTargetsVertical = [];
-	this.nMips = 5;
-	var resx = Math.round( this.resolution.x / 2 );
-	var resy = Math.round( this.resolution.y / 2 );
+		// create color only once here, reuse it later inside the render function
+		this.clearColor = new Color( 0, 0, 0 );
 
 
-	this.renderTargetBright = new WebGLRenderTarget( resx, resy, pars );
-	this.renderTargetBright.texture.name = 'UnrealBloomPass.bright';
-	this.renderTargetBright.texture.generateMipmaps = false;
+		// render targets
+		const pars = { minFilter: LinearFilter, magFilter: LinearFilter, format: RGBAFormat };
+		this.renderTargetsHorizontal = [];
+		this.renderTargetsVertical = [];
+		this.nMips = 5;
+		let resx = Math.round( this.resolution.x / 2 );
+		let resy = Math.round( this.resolution.y / 2 );
 
 
-	for ( var i = 0; i < this.nMips; i ++ ) {
+		this.renderTargetBright = new WebGLRenderTarget( resx, resy, pars );
+		this.renderTargetBright.texture.name = 'UnrealBloomPass.bright';
+		this.renderTargetBright.texture.generateMipmaps = false;
 
 
-		var renderTargetHorizonal = new WebGLRenderTarget( resx, resy, pars );
+		for ( let i = 0; i < this.nMips; i ++ ) {
 
 
-		renderTargetHorizonal.texture.name = 'UnrealBloomPass.h' + i;
-		renderTargetHorizonal.texture.generateMipmaps = false;
+			const renderTargetHorizonal = new WebGLRenderTarget( resx, resy, pars );
 
 
-		this.renderTargetsHorizontal.push( renderTargetHorizonal );
+			renderTargetHorizonal.texture.name = 'UnrealBloomPass.h' + i;
+			renderTargetHorizonal.texture.generateMipmaps = false;
 
 
-		var renderTargetVertical = new WebGLRenderTarget( resx, resy, pars );
+			this.renderTargetsHorizontal.push( renderTargetHorizonal );
 
 
-		renderTargetVertical.texture.name = 'UnrealBloomPass.v' + i;
-		renderTargetVertical.texture.generateMipmaps = false;
+			const renderTargetVertical = new WebGLRenderTarget( resx, resy, pars );
 
 
-		this.renderTargetsVertical.push( renderTargetVertical );
+			renderTargetVertical.texture.name = 'UnrealBloomPass.v' + i;
+			renderTargetVertical.texture.generateMipmaps = false;
 
 
-		resx = Math.round( resx / 2 );
+			this.renderTargetsVertical.push( renderTargetVertical );
 
 
-		resy = Math.round( resy / 2 );
-
-	}
-
-	// luminosity high pass material
+			resx = Math.round( resx / 2 );
 
 
-	if ( LuminosityHighPassShader === undefined )
-		console.error( 'THREE.UnrealBloomPass relies on LuminosityHighPassShader' );
+			resy = Math.round( resy / 2 );
 
 
-	var highPassShader = LuminosityHighPassShader;
-	this.highPassUniforms = UniformsUtils.clone( highPassShader.uniforms );
+		}
 
 
-	this.highPassUniforms[ 'luminosityThreshold' ].value = threshold;
-	this.highPassUniforms[ 'smoothWidth' ].value = 0.01;
+		// luminosity high pass material
 
 
-	this.materialHighPassFilter = new ShaderMaterial( {
-		uniforms: this.highPassUniforms,
-		vertexShader: highPassShader.vertexShader,
-		fragmentShader: highPassShader.fragmentShader,
-		defines: {}
-	} );
+		if ( LuminosityHighPassShader === undefined )
+			console.error( 'THREE.UnrealBloomPass relies on LuminosityHighPassShader' );
 
 
-	// Gaussian Blur Materials
-	this.separableBlurMaterials = [];
-	var kernelSizeArray = [ 3, 5, 7, 9, 11 ];
-	var resx = Math.round( this.resolution.x / 2 );
-	var resy = Math.round( this.resolution.y / 2 );
+		const highPassShader = LuminosityHighPassShader;
+		this.highPassUniforms = UniformsUtils.clone( highPassShader.uniforms );
 
 
-	for ( var i = 0; i < this.nMips; i ++ ) {
+		this.highPassUniforms[ 'luminosityThreshold' ].value = threshold;
+		this.highPassUniforms[ 'smoothWidth' ].value = 0.01;
 
 
-		this.separableBlurMaterials.push( this.getSeperableBlurMaterial( kernelSizeArray[ i ] ) );
+		this.materialHighPassFilter = new ShaderMaterial( {
+			uniforms: this.highPassUniforms,
+			vertexShader: highPassShader.vertexShader,
+			fragmentShader: highPassShader.fragmentShader,
+			defines: {}
+		} );
 
 
-		this.separableBlurMaterials[ i ].uniforms[ 'texSize' ].value = new Vector2( resx, resy );
+		// Gaussian Blur Materials
+		this.separableBlurMaterials = [];
+		const kernelSizeArray = [ 3, 5, 7, 9, 11 ];
+		resx = Math.round( this.resolution.x / 2 );
+		resy = Math.round( this.resolution.y / 2 );
 
 
-		resx = Math.round( resx / 2 );
+		for ( let i = 0; i < this.nMips; i ++ ) {
 
 
-		resy = Math.round( resy / 2 );
+			this.separableBlurMaterials.push( this.getSeperableBlurMaterial( kernelSizeArray[ i ] ) );
 
 
-	}
+			this.separableBlurMaterials[ i ].uniforms[ 'texSize' ].value = new Vector2( resx, resy );
 
 
-	// Composite material
-	this.compositeMaterial = this.getCompositeMaterial( this.nMips );
-	this.compositeMaterial.uniforms[ 'blurTexture1' ].value = this.renderTargetsVertical[ 0 ].texture;
-	this.compositeMaterial.uniforms[ 'blurTexture2' ].value = this.renderTargetsVertical[ 1 ].texture;
-	this.compositeMaterial.uniforms[ 'blurTexture3' ].value = this.renderTargetsVertical[ 2 ].texture;
-	this.compositeMaterial.uniforms[ 'blurTexture4' ].value = this.renderTargetsVertical[ 3 ].texture;
-	this.compositeMaterial.uniforms[ 'blurTexture5' ].value = this.renderTargetsVertical[ 4 ].texture;
-	this.compositeMaterial.uniforms[ 'bloomStrength' ].value = strength;
-	this.compositeMaterial.uniforms[ 'bloomRadius' ].value = 0.1;
-	this.compositeMaterial.needsUpdate = true;
+			resx = Math.round( resx / 2 );
 
 
-	var bloomFactors = [ 1.0, 0.8, 0.6, 0.4, 0.2 ];
-	this.compositeMaterial.uniforms[ 'bloomFactors' ].value = bloomFactors;
-	this.bloomTintColors = [ new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ),
-							 new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ) ];
-	this.compositeMaterial.uniforms[ 'bloomTintColors' ].value = this.bloomTintColors;
+			resy = Math.round( resy / 2 );
 
 
-	// copy material
-	if ( CopyShader === undefined ) {
+		}
 
 
-		console.error( 'THREE.UnrealBloomPass relies on CopyShader' );
+		// Composite material
+		this.compositeMaterial = this.getCompositeMaterial( this.nMips );
+		this.compositeMaterial.uniforms[ 'blurTexture1' ].value = this.renderTargetsVertical[ 0 ].texture;
+		this.compositeMaterial.uniforms[ 'blurTexture2' ].value = this.renderTargetsVertical[ 1 ].texture;
+		this.compositeMaterial.uniforms[ 'blurTexture3' ].value = this.renderTargetsVertical[ 2 ].texture;
+		this.compositeMaterial.uniforms[ 'blurTexture4' ].value = this.renderTargetsVertical[ 3 ].texture;
+		this.compositeMaterial.uniforms[ 'blurTexture5' ].value = this.renderTargetsVertical[ 4 ].texture;
+		this.compositeMaterial.uniforms[ 'bloomStrength' ].value = strength;
+		this.compositeMaterial.uniforms[ 'bloomRadius' ].value = 0.1;
+		this.compositeMaterial.needsUpdate = true;
+
+		const bloomFactors = [ 1.0, 0.8, 0.6, 0.4, 0.2 ];
+		this.compositeMaterial.uniforms[ 'bloomFactors' ].value = bloomFactors;
+		this.bloomTintColors = [ new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ) ];
+		this.compositeMaterial.uniforms[ 'bloomTintColors' ].value = this.bloomTintColors;
 
 
-	}
+		// copy material
+		if ( CopyShader === undefined ) {
 
 
-	var copyShader = CopyShader;
+			console.error( 'THREE.UnrealBloomPass relies on CopyShader' );
 
 
-	this.copyUniforms = UniformsUtils.clone( copyShader.uniforms );
-	this.copyUniforms[ 'opacity' ].value = 1.0;
+		}
 
 
-	this.materialCopy = new ShaderMaterial( {
-		uniforms: this.copyUniforms,
-		vertexShader: copyShader.vertexShader,
-		fragmentShader: copyShader.fragmentShader,
-		blending: AdditiveBlending,
-		depthTest: false,
-		depthWrite: false,
-		transparent: true
-	} );
+		const copyShader = CopyShader;
 
 
-	this.enabled = true;
-	this.needsSwap = false;
+		this.copyUniforms = UniformsUtils.clone( copyShader.uniforms );
+		this.copyUniforms[ 'opacity' ].value = 1.0;
 
 
-	this._oldClearColor = new Color();
-	this.oldClearAlpha = 1;
+		this.materialCopy = new ShaderMaterial( {
+			uniforms: this.copyUniforms,
+			vertexShader: copyShader.vertexShader,
+			fragmentShader: copyShader.fragmentShader,
+			blending: AdditiveBlending,
+			depthTest: false,
+			depthWrite: false,
+			transparent: true
+		} );
 
 
-	this.basic = new MeshBasicMaterial();
+		this.enabled = true;
+		this.needsSwap = false;
 
 
-	this.fsQuad = new Pass.FullScreenQuad( null );
+		this._oldClearColor = new Color();
+		this.oldClearAlpha = 1;
 
 
-};
+		this.basic = new MeshBasicMaterial();
 
 
-UnrealBloomPass.prototype = Object.assign( Object.create( Pass.prototype ), {
+		this.fsQuad = new FullScreenQuad( null );
 
 
-	constructor: UnrealBloomPass,
+	}
 
 
-	dispose: function () {
+	dispose() {
 
 
-		for ( var i = 0; i < this.renderTargetsHorizontal.length; i ++ ) {
+		for ( let i = 0; i < this.renderTargetsHorizontal.length; i ++ ) {
 
 
 			this.renderTargetsHorizontal[ i ].dispose();
 			this.renderTargetsHorizontal[ i ].dispose();
 
 
 		}
 		}
 
 
-		for ( var i = 0; i < this.renderTargetsVertical.length; i ++ ) {
+		for ( let i = 0; i < this.renderTargetsVertical.length; i ++ ) {
 
 
 			this.renderTargetsVertical[ i ].dispose();
 			this.renderTargetsVertical[ i ].dispose();
 
 
@@ -176,16 +173,16 @@ UnrealBloomPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		this.renderTargetBright.dispose();
 		this.renderTargetBright.dispose();
 
 
-	},
+	}
 
 
-	setSize: function ( width, height ) {
+	setSize( width, height ) {
 
 
-		var resx = Math.round( width / 2 );
-		var resy = Math.round( height / 2 );
+		let resx = Math.round( width / 2 );
+		let resy = Math.round( height / 2 );
 
 
 		this.renderTargetBright.setSize( resx, resy );
 		this.renderTargetBright.setSize( resx, resy );
 
 
-		for ( var i = 0; i < this.nMips; i ++ ) {
+		for ( let i = 0; i < this.nMips; i ++ ) {
 
 
 			this.renderTargetsHorizontal[ i ].setSize( resx, resy );
 			this.renderTargetsHorizontal[ i ].setSize( resx, resy );
 			this.renderTargetsVertical[ i ].setSize( resx, resy );
 			this.renderTargetsVertical[ i ].setSize( resx, resy );
@@ -197,13 +194,13 @@ UnrealBloomPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		}
 		}
 
 
-	},
+	}
 
 
-	render: function ( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {
+	render( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {
 
 
 		renderer.getClearColor( this._oldClearColor );
 		renderer.getClearColor( this._oldClearColor );
 		this.oldClearAlpha = renderer.getClearAlpha();
 		this.oldClearAlpha = renderer.getClearAlpha();
-		var oldAutoClear = renderer.autoClear;
+		const oldAutoClear = renderer.autoClear;
 		renderer.autoClear = false;
 		renderer.autoClear = false;
 
 
 		renderer.setClearColor( this.clearColor, 0 );
 		renderer.setClearColor( this.clearColor, 0 );
@@ -235,9 +232,9 @@ UnrealBloomPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 
 
 		// 2. Blur All the mips progressively
 		// 2. Blur All the mips progressively
 
 
-		var inputRenderTarget = this.renderTargetBright;
+		let inputRenderTarget = this.renderTargetBright;
 
 
-		for ( var i = 0; i < this.nMips; i ++ ) {
+		for ( let i = 0; i < this.nMips; i ++ ) {
 
 
 			this.fsQuad.material = this.separableBlurMaterials[ i ];
 			this.fsQuad.material = this.separableBlurMaterials[ i ];
 
 
@@ -292,9 +289,9 @@ UnrealBloomPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 		renderer.setClearColor( this._oldClearColor, this.oldClearAlpha );
 		renderer.setClearColor( this._oldClearColor, this.oldClearAlpha );
 		renderer.autoClear = oldAutoClear;
 		renderer.autoClear = oldAutoClear;
 
 
-	},
+	}
 
 
-	getSeperableBlurMaterial: function ( kernelRadius ) {
+	getSeperableBlurMaterial( kernelRadius ) {
 
 
 		return new ShaderMaterial( {
 		return new ShaderMaterial( {
 
 
@@ -310,43 +307,43 @@ UnrealBloomPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 			},
 			},
 
 
 			vertexShader:
 			vertexShader:
-				'varying vec2 vUv;\n\
-				void main() {\n\
-					vUv = uv;\n\
-					gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\
-				}',
+				`varying vec2 vUv;
+				void main() {
+					vUv = uv;
+					gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+				}`,
 
 
 			fragmentShader:
 			fragmentShader:
-				'#include <common>\
-				varying vec2 vUv;\n\
-				uniform sampler2D colorTexture;\n\
-				uniform vec2 texSize;\
-				uniform vec2 direction;\
-				\
-				float gaussianPdf(in float x, in float sigma) {\
-					return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\
-				}\
-				void main() {\n\
-					vec2 invSize = 1.0 / texSize;\
-					float fSigma = float(SIGMA);\
-					float weightSum = gaussianPdf(0.0, fSigma);\
-					vec3 diffuseSum = texture2D( colorTexture, vUv).rgb * weightSum;\
-					for( int i = 1; i < KERNEL_RADIUS; i ++ ) {\
-						float x = float(i);\
-						float w = gaussianPdf(x, fSigma);\
-						vec2 uvOffset = direction * invSize * x;\
-						vec3 sample1 = texture2D( colorTexture, vUv + uvOffset).rgb;\
-						vec3 sample2 = texture2D( colorTexture, vUv - uvOffset).rgb;\
-						diffuseSum += (sample1 + sample2) * w;\
-						weightSum += 2.0 * w;\
-					}\
-					gl_FragColor = vec4(diffuseSum/weightSum, 1.0);\n\
-				}'
+				`#include <common>
+				varying vec2 vUv;
+				uniform sampler2D colorTexture;
+				uniform vec2 texSize;
+				uniform vec2 direction;
+
+				float gaussianPdf(in float x, in float sigma) {
+					return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;
+				}
+				void main() {
+					vec2 invSize = 1.0 / texSize;
+					float fSigma = float(SIGMA);
+					float weightSum = gaussianPdf(0.0, fSigma);
+					vec3 diffuseSum = texture2D( colorTexture, vUv).rgb * weightSum;
+					for( int i = 1; i < KERNEL_RADIUS; i ++ ) {
+						float x = float(i);
+						float w = gaussianPdf(x, fSigma);
+						vec2 uvOffset = direction * invSize * x;
+						vec3 sample1 = texture2D( colorTexture, vUv + uvOffset).rgb;
+						vec3 sample2 = texture2D( colorTexture, vUv - uvOffset).rgb;
+						diffuseSum += (sample1 + sample2) * w;
+						weightSum += 2.0 * w;
+					}
+					gl_FragColor = vec4(diffuseSum/weightSum, 1.0);
+				}`
 		} );
 		} );
 
 
-	},
+	}
 
 
-	getCompositeMaterial: function ( nMips ) {
+	getCompositeMaterial( nMips ) {
 
 
 		return new ShaderMaterial( {
 		return new ShaderMaterial( {
 
 
@@ -368,42 +365,42 @@ UnrealBloomPass.prototype = Object.assign( Object.create( Pass.prototype ), {
 			},
 			},
 
 
 			vertexShader:
 			vertexShader:
-				'varying vec2 vUv;\n\
-				void main() {\n\
-					vUv = uv;\n\
-					gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\
-				}',
+				`varying vec2 vUv;
+				void main() {
+					vUv = uv;
+					gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+				}`,
 
 
 			fragmentShader:
 			fragmentShader:
-				'varying vec2 vUv;\
-				uniform sampler2D blurTexture1;\
-				uniform sampler2D blurTexture2;\
-				uniform sampler2D blurTexture3;\
-				uniform sampler2D blurTexture4;\
-				uniform sampler2D blurTexture5;\
-				uniform sampler2D dirtTexture;\
-				uniform float bloomStrength;\
-				uniform float bloomRadius;\
-				uniform float bloomFactors[NUM_MIPS];\
-				uniform vec3 bloomTintColors[NUM_MIPS];\
-				\
-				float lerpBloomFactor(const in float factor) { \
-					float mirrorFactor = 1.2 - factor;\
-					return mix(factor, mirrorFactor, bloomRadius);\
-				}\
-				\
-				void main() {\
-					gl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) + \
-													 lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) + \
-													 lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) + \
-													 lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) + \
-													 lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );\
-				}'
+				`varying vec2 vUv;
+				uniform sampler2D blurTexture1;
+				uniform sampler2D blurTexture2;
+				uniform sampler2D blurTexture3;
+				uniform sampler2D blurTexture4;
+				uniform sampler2D blurTexture5;
+				uniform sampler2D dirtTexture;
+				uniform float bloomStrength;
+				uniform float bloomRadius;
+				uniform float bloomFactors[NUM_MIPS];
+				uniform vec3 bloomTintColors[NUM_MIPS];
+
+				float lerpBloomFactor(const in float factor) {
+					float mirrorFactor = 1.2 - factor;
+					return mix(factor, mirrorFactor, bloomRadius);
+				}
+
+				void main() {
+					gl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +
+						lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +
+						lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +
+						lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +
+						lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );
+				}`
 		} );
 		} );
 
 
 	}
 	}
 
 
-} );
+}
 
 
 UnrealBloomPass.BlurDirectionX = new Vector2( 1.0, 0.0 );
 UnrealBloomPass.BlurDirectionX = new Vector2( 1.0, 0.0 );
 UnrealBloomPass.BlurDirectionY = new Vector2( 0.0, 1.0 );
 UnrealBloomPass.BlurDirectionY = new Vector2( 0.0, 1.0 );

Some files were not shown because too many files changed in this diff