Skip to content

Commit 730c742

Browse files
authored
ViewportTextureNode: Improve docs and clean up. (#31599)
* ViewportTextureNode: Improve docs. * ViewportTextureNode: Rename `getFrameBufferTexture()` to `getTextureForReference()`.
1 parent 950dbb5 commit 730c742

File tree

4 files changed

+35
-11
lines changed

4 files changed

+35
-11
lines changed

src/nodes/display/ViewportDepthTextureNode.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { screenUV } from './ScreenNode.js';
44

55
import { DepthTexture } from '../../textures/DepthTexture.js';
66

7-
let sharedDepthbuffer = null;
7+
let _sharedDepthbuffer = null;
88

99
/**
1010
* Represents the depth of the current viewport as a texture. This module
@@ -29,13 +29,25 @@ class ViewportDepthTextureNode extends ViewportTextureNode {
2929
*/
3030
constructor( uvNode = screenUV, levelNode = null ) {
3131

32-
if ( sharedDepthbuffer === null ) {
32+
if ( _sharedDepthbuffer === null ) {
3333

34-
sharedDepthbuffer = new DepthTexture();
34+
_sharedDepthbuffer = new DepthTexture();
3535

3636
}
3737

38-
super( uvNode, levelNode, sharedDepthbuffer );
38+
super( uvNode, levelNode, _sharedDepthbuffer );
39+
40+
}
41+
42+
/**
43+
* Overwritten so the method always returns the unique shared
44+
* depth texture.
45+
*
46+
* @return {DepthTexture} The shared depth texture.
47+
*/
48+
getTextureForReference() {
49+
50+
return _sharedDepthbuffer;
3951

4052
}
4153

src/nodes/display/ViewportSharedTextureNode.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ class ViewportSharedTextureNode extends ViewportTextureNode {
3939

4040
}
4141

42-
getFrameBufferTexture() {
42+
/**
43+
* Overwritten so the method always returns the unique shared
44+
* framebuffer texture.
45+
*
46+
* @return {FramebufferTexture} The shared framebuffer texture.
47+
*/
48+
getTextureForReference() {
4349

4450
return _sharedFramebuffer;
4551

src/nodes/display/ViewportTextureNode.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,16 @@ class ViewportTextureNode extends TextureNode {
9898

9999
}
100100

101-
getFrameBufferTexture( reference = null ) {
101+
/**
102+
* This methods returns a texture for the given render target reference.
103+
*
104+
* To avoid rendering errors, `ViewportTextureNode` must use unique framebuffer textures
105+
* for different render contexts.
106+
*
107+
* @param {?RenderTarget} [reference=null] - The render target reference.
108+
* @return {Texture} The framebuffer texture.
109+
*/
110+
getTextureForReference( reference = null ) {
102111

103112
let defaultFramebuffer;
104113
let cacheTextures;
@@ -137,7 +146,7 @@ class ViewportTextureNode extends TextureNode {
137146

138147
const renderTarget = frame.renderer.getRenderTarget();
139148

140-
this.value = this.getFrameBufferTexture( renderTarget );
149+
this.value = this.getTextureForReference( renderTarget );
141150

142151
return this.value;
143152

@@ -160,7 +169,7 @@ class ViewportTextureNode extends TextureNode {
160169

161170
//
162171

163-
const framebufferTexture = this.getFrameBufferTexture( renderTarget );
172+
const framebufferTexture = this.getTextureForReference( renderTarget );
164173

165174
if ( framebufferTexture.image.width !== _size.width || framebufferTexture.image.height !== _size.height ) {
166175

src/textures/VideoTexture.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,6 @@ class VideoTexture extends Texture {
108108

109109
}
110110

111-
/**
112-
* @override
113-
*/
114111
dispose() {
115112

116113
if ( this._requestVideoFrameCallbackId !== 0 ) {

0 commit comments

Comments
 (0)