Browse Source

vv (#28894)

ccc

create default video frame

fix quote format

Co-authored-by: aardgoose <[email protected]>
aardgoose 1 year ago
parent
commit
4cceb6c57e
1 changed files with 26 additions and 0 deletions
  1. 26 0
      src/renderers/webgpu/utils/WebGPUTextureUtils.js

+ 26 - 0
src/renderers/webgpu/utils/WebGPUTextureUtils.js

@@ -42,6 +42,7 @@ class WebGPUTextureUtils {
 
 		this.defaultTexture = {};
 		this.defaultCubeTexture = {};
+		this.defaultVideoFrame = null;
 
 		this.colorBuffer = null;
 
@@ -87,6 +88,10 @@ class WebGPUTextureUtils {
 
 			textureGPU = this._getDefaultCubeTextureGPU( format );
 
+		} else if ( texture.isVideoTexture ) {
+
+			this.backend.get( texture ).externalTexture = this._getDefaultVideoFrame();
+
 		} else {
 
 			textureGPU = this._getDefaultTextureGPU( format );
@@ -455,6 +460,27 @@ class WebGPUTextureUtils {
 
 	}
 
+	_getDefaultVideoFrame() {
+
+		let defaultVideoFrame = this.defaultVideoFrame;
+
+		if ( defaultVideoFrame === null ) {
+
+			const init = {
+				timestamp: 0,
+				codedWidth: 1,
+				codedHeight: 1,
+				format: 'RGBA',
+			};
+
+		  this.defaultVideoFrame = defaultVideoFrame = new VideoFrame( new Uint8Array( [ 0, 0, 0, 0xff ] ), init );
+
+		}
+
+		return defaultVideoFrame;
+
+	}
+
 	_copyCubeMapToTexture( images, textureGPU, textureDescriptorGPU, flipY ) {
 
 		for ( let i = 0; i < 6; i ++ ) {