Browse Source

Textures: Fix dimensions of video frames. (#31425)

* Textures: Fix dimensions of video frames.

* Source: Fix `getSize()`.

* Source: Fix z coordinate for video-like sources.
Michael Herzog 7 months ago
parent
commit
96662caece
2 changed files with 17 additions and 1 deletions
  1. 6 0
      src/renderers/common/Textures.js
  2. 11 1
      src/textures/Source.js

+ 6 - 0
src/renderers/common/Textures.js

@@ -372,6 +372,12 @@ class Textures extends DataMap {
 				target.height = image.videoHeight || 1;
 				target.depth = 1;
 
+			} else if ( image instanceof VideoFrame ) {
+
+				target.width = image.displayWidth || 1;
+				target.height = image.displayHeight || 1;
+				target.depth = 1;
+
 			} else {
 
 				target.width = image.width || 1;

+ 11 - 1
src/textures/Source.js

@@ -73,13 +73,23 @@ class Source {
 
 	}
 
+	/**
+	 * Returns the dimensions of the source into the given target vector.
+	 *
+	 * @param {(Vector2|Vector3)} target - The target object the result is written into.
+	 * @return {(Vector2|Vector3)} The dimensions of the source.
+	 */
 	getSize( target ) {
 
 		const data = this.data;
 
 		if ( data instanceof HTMLVideoElement ) {
 
-			target.set( data.videoWidth, data.videoHeight );
+			target.set( data.videoWidth, data.videoHeight, 0 );
+
+		} else if ( data instanceof VideoFrame ) {
+
+			target.set( data.displayHeight, data.displayWidth, 0 );
 
 		} else if ( data !== null ) {
 

粤ICP备19079148号