You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.3 KiB
55 lines
1.3 KiB
( function () {
|
|
|
|
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 = 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.FullScreenQuad( this.material );
|
|
|
|
}
|
|
|
|
render( renderer, writeBuffer, readBuffer
|
|
/*, deltaTime, maskActive */
|
|
) {
|
|
|
|
if ( this.uniforms[ this.textureID ] ) {
|
|
|
|
this.uniforms[ this.textureID ].value = readBuffer.texture;
|
|
|
|
}
|
|
|
|
renderer.setRenderTarget( this.renderTarget );
|
|
if ( this.clear ) renderer.clear();
|
|
this.fsQuad.render( renderer );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
THREE.SavePass = SavePass;
|
|
|
|
} )();
|
|
|