Sfoglia il codice sorgente

ViewportTextureNode: Improve docs and clean up. (#31599)

* ViewportTextureNode: Improve docs.

* ViewportTextureNode: Rename `getFrameBufferTexture()` to `getTextureForReference()`.
Michael Herzog 5 mesi fa
parent
commit
730c742e12

+ 16 - 4
src/nodes/display/ViewportDepthTextureNode.js

@@ -4,7 +4,7 @@ import { screenUV } from './ScreenNode.js';
 
 import { DepthTexture } from '../../textures/DepthTexture.js';
 
-let sharedDepthbuffer = null;
+let _sharedDepthbuffer = null;
 
 /**
  * Represents the depth of the current viewport as a texture. This module
@@ -29,13 +29,25 @@ class ViewportDepthTextureNode extends ViewportTextureNode {
 	 */
 	constructor( uvNode = screenUV, levelNode = null ) {
 
-		if ( sharedDepthbuffer === null ) {
+		if ( _sharedDepthbuffer === null ) {
 
-			sharedDepthbuffer = new DepthTexture();
+			_sharedDepthbuffer = new DepthTexture();
 
 		}
 
-		super( uvNode, levelNode, sharedDepthbuffer );
+		super( uvNode, levelNode, _sharedDepthbuffer );
+
+	}
+
+	/**
+	 * Overwritten so the method always returns the unique shared
+	 * depth texture.
+	 *
+	 * @return {DepthTexture} The shared depth texture.
+	 */
+	getTextureForReference() {
+
+		return _sharedDepthbuffer;
 
 	}
 

+ 7 - 1
src/nodes/display/ViewportSharedTextureNode.js

@@ -39,7 +39,13 @@ class ViewportSharedTextureNode extends ViewportTextureNode {
 
 	}
 
-	getFrameBufferTexture() {
+	/**
+	 * Overwritten so the method always returns the unique shared
+	 * framebuffer texture.
+	 *
+	 * @return {FramebufferTexture} The shared framebuffer texture.
+	 */
+	getTextureForReference() {
 
 		return _sharedFramebuffer;
 

+ 12 - 3
src/nodes/display/ViewportTextureNode.js

@@ -98,7 +98,16 @@ class ViewportTextureNode extends TextureNode {
 
 	}
 
-	getFrameBufferTexture( reference = null ) {
+	/**
+	 * This methods returns a texture for the given render target reference.
+	 *
+	 * To avoid rendering errors, `ViewportTextureNode` must use unique framebuffer textures
+	 * for different render contexts.
+	 *
+	 * @param {?RenderTarget} [reference=null] - The render target reference.
+	 * @return {Texture} The framebuffer texture.
+	 */
+	getTextureForReference( reference = null ) {
 
 		let defaultFramebuffer;
 		let cacheTextures;
@@ -137,7 +146,7 @@ class ViewportTextureNode extends TextureNode {
 
 		const renderTarget = frame.renderer.getRenderTarget();
 
-		this.value = this.getFrameBufferTexture( renderTarget );
+		this.value = this.getTextureForReference( renderTarget );
 
 		return this.value;
 
@@ -160,7 +169,7 @@ class ViewportTextureNode extends TextureNode {
 
 		//
 
-		const framebufferTexture = this.getFrameBufferTexture( renderTarget );
+		const framebufferTexture = this.getTextureForReference( renderTarget );
 
 		if ( framebufferTexture.image.width !== _size.width || framebufferTexture.image.height !== _size.height ) {
 

+ 0 - 3
src/textures/VideoTexture.js

@@ -108,9 +108,6 @@ class VideoTexture extends Texture {
 
 	}
 
-	/**
-	 * @override
-	 */
 	dispose() {
 
 		if ( this._requestVideoFrameCallbackId !== 0 ) {

粤ICP备19079148号