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

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

	this.scene = scene;
	this.camera = camera;
9

10
	this.overrideMaterial = overrideMaterial;
11

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

	this.clear = true;
16
	this.needsSwap = false;
17

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

21 22 23 24
};

THREE.RenderPass.prototype = {

25
	render: function ( renderer, writeBuffer, readBuffer, delta ) {
26

27 28
		this.scene.overrideMaterial = this.overrideMaterial;

29 30
		if ( this.clearColor ) {

31
			this.oldClearColor.copy( renderer.getClearColor() );
32 33 34
			this.oldClearAlpha = renderer.getClearAlpha();

			renderer.setClearColor( this.clearColor, this.clearAlpha );
35 36 37

		}

38
		renderer.render( this.scene, this.camera, readBuffer, this.clear );
39

40 41
		if ( this.clearColor ) {

42
			renderer.setClearColor( this.oldClearColor, this.oldClearAlpha );
43 44 45

		}

46 47
		this.scene.overrideMaterial = null;

48 49 50
	}

};