RenderPass.js 1.1 KB
Newer Older
1 2 3 4
/**
 * @author alteredq / http://alteredqualia.com/
 */

5
THREE.RenderPass = function ( scene, camera, overrideMaterial, clearColor, clearAlpha ) {
6

7 8
	THREE.Pass.call( this );

9 10
	this.scene = scene;
	this.camera = camera;
11

12
	this.overrideMaterial = overrideMaterial;
13

14
	this.clearColor = clearColor;
15
	this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 1;
16

17
	this.oldClearColor = new THREE.Color();
18
	this.oldClearAlpha = 1;
19

20 21 22
	this.clear = true;
	this.needsSwap = false;

23 24
};

25 26
THREE.RenderPass.prototype = Object.create( THREE.Pass.prototype );

27
Object.assign( THREE.RenderPass.prototype, {
28 29

	render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
30

31 32
		this.scene.overrideMaterial = this.overrideMaterial;

33 34
		if ( this.clearColor ) {

35
			this.oldClearColor.copy( renderer.getClearColor() );
36 37 38
			this.oldClearAlpha = renderer.getClearAlpha();

			renderer.setClearColor( this.clearColor, this.clearAlpha );
39 40 41

		}

42
		renderer.render( this.scene, this.camera, readBuffer, this.clear );
43

44 45
		if ( this.clearColor ) {

46
			renderer.setClearColor( this.oldClearColor, this.oldClearAlpha );
47 48 49

		}

50 51
		this.scene.overrideMaterial = null;

52 53
	}

54
} );