From 8aa59cb9b88b532f6fdc7dabb2ae3fe49884d04e Mon Sep 17 00:00:00 2001 From: Leon van Kammen Date: Thu, 6 Jun 2024 15:41:25 +0000 Subject: [PATCH] video bugfix --- src/3rd/js/three/xrf/src/video.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/3rd/js/three/xrf/src/video.js b/src/3rd/js/three/xrf/src/video.js index 6a99ed1..ad2871c 100644 --- a/src/3rd/js/three/xrf/src/video.js +++ b/src/3rd/js/three/xrf/src/video.js @@ -1,10 +1,23 @@ - let loadVideo = (mimetype) => function(url,opts){ let {mesh,src,camera} = opts const THREE = xrf.THREE let URL = xrfragment.URI.toAbsolute( xrf.navigator.URI, url ) let frag = URL.XRF + // patch VideoTexture so it doesn't upload videoframes when paused + // https://github.com/mrdoob/three.js/pull/28575 + THREE.VideoTexture.prototype.update = function(){ + const video = this.image; + const hasVideoFrameCallback = 'requestVideoFrameCallback' in video; + + if ( hasVideoFrameCallback === false && video.readyState >= video.HAVE_CURRENT_DATA && (!video.paused || !this.firstFrame) ){ + console.log("updating..") + this.needsUpdate = true; + this.firstFrame = true + } + } + + mesh.media = mesh.media || {} let video = mesh.media.video = document.createElement('video')