Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VideoTexture updates material even if video is paused. #22380

Closed
Robpayot opened this issue Aug 20, 2021 · 2 comments
Closed

VideoTexture updates material even if video is paused. #22380

Robpayot opened this issue Aug 20, 2021 · 2 comments

Comments

@Robpayot
Copy link

Robpayot commented Aug 20, 2021

Hi there,

I was using multiple VideoTexture for a project and I realize that even if all the videos were paused, I was getting a huge drops of fps.
So I did a little bit of research and I've seen that all the textures are updated with the this.needsUpdate = true; at every frames, which shouldn't be required since the videos were paused and nothing needed to be updated in my case.

I've overriden the VideoTexture.update() method by adding a condition to prevent calls if the video is paused and the fps increased to 60.

Maybe it would be nice to add an option to not call the "needsUpdate = true" if the video is paused which seems to add a lot of calculations. Something like :

VideoTexture.prototype = Object.assign( Object.create( Texture.prototype ), {

	constructor: VideoTexture,

	isVideoTexture: true,

	update: function () {

		var video = this.image;

		if ( video.readyState >= video.HAVE_CURRENT_DATA && video.currentTime > 0 && !video.paused && !video.ended) {

			this.needsUpdate = true;

		}

	}

} );

Version of three.js used: 0.113.2

I'd be happy if it could help!

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 20, 2021

This issue was already discussed in #16946.

Does #16946 (comment) not work for you?

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 23, 2021

Version of three.js used: 0.113.2

Closing. The issue should be resolved by upgrading to at least r119.

@Mugen87 Mugen87 closed this as completed Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants