In this PG I create a video texture and then clone the material that has the video texture and the video texture freezes. In this PG I create a new material instead of cloning the old one. Is there a way to clone a material with a video texture without freezing the video?
When you do
clone.material.diffuseTexture.dispose() you dispose the video texture. Simply commenting the line make the PG work.
How does disposing of a cloned texture dispose of the source’s texture? I verified the textures have different unique ids. I dispose of the texture because I need to create a new one for the clone, i.e. the “A1” texture…
Maybe there’s some specificities with the Web Cam stream, as it seems to work with a regular texture:
cc @sebavan might know more about video texture?
They would share the same internal Texture by default for perf.
Gotcha. Is there a way to clone the material without cloning the texture? Or is the best option to not clone the material and make a new one since none of the textures will be shared.
Actually let me dig in as it should not happen they way the texture has been created.
The webcam stream is disposed during the texture dispose() you can restart it right after dispose: https://playground.babylonjs.com/#RS90XC#21
Sorry @sebavan Not working for me for some reason in production. I think our situation is a little more complicated but not sure how to replicate in a PG. Is there any value to cloning a material if I don’t want to clone the textures? If so, would you be willing to accept a PR that would make cloning textures optional when cloning material?
you could detach the texture from the material before cloning. This will be by far the easiest.