Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions examples/jsm/tsl/display/AfterImageNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ class AfterImageNode extends TempNode {
*/
this.textureNode = textureNode;

/**
* The texture represents the pervious frame.
*
* @type {TextureNode}
*/
this.textureNodeOld = texture( null );

/**
* How quickly the after-image fades. A higher value means the after-image
* persists longer, while a lower value means it fades faster. Should be in
Expand Down Expand Up @@ -79,6 +72,14 @@ class AfterImageNode extends TempNode {
*/
this._textureNode = passTexture( this, this._compRT.texture );

/**
* The texture represents the pervious frame.
*
* @private
* @type {TextureNode}
*/
this._textureNodeOld = texture( this._oldRT.texture );

/**
* The `updateBeforeType` is set to `NodeUpdateType.FRAME` since the node renders
* its effect once per frame in `updateBefore()`.
Expand Down Expand Up @@ -139,27 +140,27 @@ class AfterImageNode extends TempNode {

this.setSize( _size.x, _size.y );

const currentTexture = textureNode.value;
// make sure texture nodes point to correct render targets

this._textureNode.value = this._compRT.texture;
this._textureNodeOld.value = this._oldRT.texture;

this.textureNodeOld.value = this._oldRT.texture;
// composite

// comp
_quadMesh.material = this._materialComposed;
_quadMesh.name = 'AfterImage';

renderer.setRenderTarget( this._compRT );
_quadMesh.render( renderer );

// Swap the textures
// swap

const temp = this._oldRT;
this._oldRT = this._compRT;
this._compRT = temp;

//

textureNode.value = currentTexture;

RendererUtils.restoreRendererState( renderer, _rendererState );

}
Expand All @@ -173,7 +174,7 @@ class AfterImageNode extends TempNode {
setup( builder ) {

const textureNode = this.textureNode;
const textureNodeOld = this.textureNodeOld;
const textureNodeOld = this._textureNodeOld;

//

Expand Down