Skip to content

Commit 30c1ac4

Browse files
authored
AfterImageNode: Fix swap. (#32140)
1 parent 4342d10 commit 30c1ac4

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

examples/jsm/tsl/display/AfterImageNode.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@ class AfterImageNode extends TempNode {
3737
*/
3838
this.textureNode = textureNode;
3939

40-
/**
41-
* The texture represents the pervious frame.
42-
*
43-
* @type {TextureNode}
44-
*/
45-
this.textureNodeOld = texture( null );
46-
4740
/**
4841
* How quickly the after-image fades. A higher value means the after-image
4942
* persists longer, while a lower value means it fades faster. Should be in
@@ -79,6 +72,14 @@ class AfterImageNode extends TempNode {
7972
*/
8073
this._textureNode = passTexture( this, this._compRT.texture );
8174

75+
/**
76+
* The texture represents the pervious frame.
77+
*
78+
* @private
79+
* @type {TextureNode}
80+
*/
81+
this._textureNodeOld = texture( this._oldRT.texture );
82+
8283
/**
8384
* The `updateBeforeType` is set to `NodeUpdateType.FRAME` since the node renders
8485
* its effect once per frame in `updateBefore()`.
@@ -139,27 +140,27 @@ class AfterImageNode extends TempNode {
139140

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

142-
const currentTexture = textureNode.value;
143+
// make sure texture nodes point to correct render targets
144+
145+
this._textureNode.value = this._compRT.texture;
146+
this._textureNodeOld.value = this._oldRT.texture;
143147

144-
this.textureNodeOld.value = this._oldRT.texture;
148+
// composite
145149

146-
// comp
147150
_quadMesh.material = this._materialComposed;
148151
_quadMesh.name = 'AfterImage';
149152

150153
renderer.setRenderTarget( this._compRT );
151154
_quadMesh.render( renderer );
152155

153-
// Swap the textures
156+
// swap
154157

155158
const temp = this._oldRT;
156159
this._oldRT = this._compRT;
157160
this._compRT = temp;
158161

159162
//
160163

161-
textureNode.value = currentTexture;
162-
163164
RendererUtils.restoreRendererState( renderer, _rendererState );
164165

165166
}
@@ -173,7 +174,7 @@ class AfterImageNode extends TempNode {
173174
setup( builder ) {
174175

175176
const textureNode = this.textureNode;
176-
const textureNodeOld = this.textureNodeOld;
177+
const textureNodeOld = this._textureNodeOld;
177178

178179
//
179180

0 commit comments

Comments
 (0)