Skip to content

Commit fa035e8

Browse files
authored
PassNode: Add compileAsync(). (#31501)
1 parent 3752bd2 commit fa035e8

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/nodes/display/PassNode.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,32 @@ class PassNode extends TempNode {
635635

636636
}
637637

638+
/**
639+
* Precompiles the pass.
640+
*
641+
* Note that this method must be called after the pass configuartion is complete.
642+
* So calls like `setMRT()` and `getTextureNode()` must proceed the precompilation.
643+
*
644+
* @async
645+
* @param {Renderer} renderer - The renderer.
646+
* @return {Promise} A Promise that resolves when the compile has been finished.
647+
* @see {@link Renderer#compileAsync}
648+
*/
649+
async compileAsync( renderer ) {
650+
651+
const currentRenderTarget = renderer.getRenderTarget();
652+
const currentMRT = renderer.getMRT();
653+
654+
renderer.setRenderTarget( this.renderTarget );
655+
renderer.setMRT( this._mrt );
656+
657+
await renderer.compileAsync( this.scene, this.camera );
658+
659+
renderer.setRenderTarget( currentRenderTarget );
660+
renderer.setMRT( currentMRT );
661+
662+
}
663+
638664
setup( { renderer } ) {
639665

640666
this.renderTarget.samples = this.options.samples === undefined ? renderer.samples : this.options.samples;

0 commit comments

Comments
 (0)