1 | import {
|
2 | Color
|
3 | } from '../../../build/three.module.js';
|
4 | import { Pass } from '../postprocessing/Pass.js';
|
5 |
|
6 | var RenderPass = function ( scene, camera, overrideMaterial, clearColor, clearAlpha ) {
|
7 |
|
8 | Pass.call( this );
|
9 |
|
10 | this.scene = scene;
|
11 | this.camera = camera;
|
12 |
|
13 | this.overrideMaterial = overrideMaterial;
|
14 |
|
15 | this.clearColor = clearColor;
|
16 | this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0;
|
17 |
|
18 | this.clear = true;
|
19 | this.clearDepth = false;
|
20 | this.needsSwap = false;
|
21 | this._oldClearColor = new Color();
|
22 |
|
23 | };
|
24 |
|
25 | RenderPass.prototype = Object.assign( Object.create( Pass.prototype ), {
|
26 |
|
27 | constructor: RenderPass,
|
28 |
|
29 | render: function ( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
|
30 |
|
31 | var oldAutoClear = renderer.autoClear;
|
32 | renderer.autoClear = false;
|
33 |
|
34 | var oldClearAlpha, oldOverrideMaterial;
|
35 |
|
36 | if ( this.overrideMaterial !== undefined ) {
|
37 |
|
38 | oldOverrideMaterial = this.scene.overrideMaterial;
|
39 |
|
40 | this.scene.overrideMaterial = this.overrideMaterial;
|
41 |
|
42 | }
|
43 |
|
44 | if ( this.clearColor ) {
|
45 |
|
46 | renderer.getClearColor( this._oldClearColor );
|
47 | oldClearAlpha = renderer.getClearAlpha();
|
48 |
|
49 | renderer.setClearColor( this.clearColor, this.clearAlpha );
|
50 |
|
51 | }
|
52 |
|
53 | if ( this.clearDepth ) {
|
54 |
|
55 | renderer.clearDepth();
|
56 |
|
57 | }
|
58 |
|
59 | renderer.setRenderTarget( this.renderToScreen ? null : readBuffer );
|
60 |
|
61 |
|
62 | if ( this.clear ) renderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );
|
63 | renderer.render( this.scene, this.camera );
|
64 |
|
65 | if ( this.clearColor ) {
|
66 |
|
67 | renderer.setClearColor( this._oldClearColor, oldClearAlpha );
|
68 |
|
69 | }
|
70 |
|
71 | if ( this.overrideMaterial !== undefined ) {
|
72 |
|
73 | this.scene.overrideMaterial = oldOverrideMaterial;
|
74 |
|
75 | }
|
76 |
|
77 | renderer.autoClear = oldAutoClear;
|
78 |
|
79 | }
|
80 |
|
81 | } );
|
82 |
|
83 | export { RenderPass };
|