File tree Expand file tree Collapse file tree 4 files changed +35
-11
lines changed
Expand file tree Collapse file tree 4 files changed +35
-11
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { screenUV } from './ScreenNode.js';
44
55import { 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
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 ) {
You can’t perform that action at this time.
0 commit comments