VideoTexture with TextureLoader possible?

Hi,

Is there a way I can use a VideoTexture with a TextureLoader and LoadingManager?

I wanted to hook the loading of several videos into my LoadingManager, like I am doing with GLTF and images as textures.

I am not quite sure what the problem is, but maybe these examples are helpful.

From the Collection of examples from discourse.threejs.org

discourse.threejs.hofk.de 2018

2021-04-25 19.47.39

BeginnerExample
// … step 04: use a texture for the material (see also step 5 ropeMaterial)

// three.js docs

video:
2021-04-25 19.50.13


official example: three.js examples

Interestingly, this topic was discussed at GitHub some time ago in the following PR: Added video support to loading manager by osiriswrecks · Pull Request #14298 · mrdoob/three.js · GitHub

It was not merged since videos are something different than images. Usually, video files are so big that you don’t want to download them at once. You handle them as streams. Hence, the typical workflow of how loaders work in three.js does not work with videos. I’ve listed some more reasons that would make a VideoTextureLoader class problematic here.

However, feel free to use the code from the PR to build your own custom loader.

3 Likes

Thank you @hofk - @Mugen87 had the reply I needed.

Ah, shame that is problematic.

I was trying to hack my own things for some hrs before I asked, given that I couldn’t find anything on google, but it felt complicated at one point, and I feel my JS skills are not that of a wizard.

I appreciate the quick reply! I’ll check the code from that PR.

1 Like

Look at this code. It loads video textures and also an animated character in fbx format. I can’t share the videos or character as they’re client owned but this should give you an idea:

1 Like

Hey @markstrefford thank you. I decided to use the VideoTexture without the Loader, but I’ll take a look.

1 Like

While trying to make this work I created a useMemo that returns the VideoTexture as to cache it as long as the component is on the dom. Not sure if that works for every use case though.