-
-
Notifications
You must be signed in to change notification settings - Fork 35.2k
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: Allow changing image source #25724
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
I think that this check should be in something like class VideoTexture extends Texture {
...
set video( video = null ) {
if ( ( video !== undefined ) && ( video !== null ) && ( video.requestVideoFrameCallback !== undefined ) ) {
video.requestVideoFrameCallback( updateVideo );
}
}
...
} Because it could be added implicitly. |
I think this should be changed in another PR. |
Can you please explain why the additional check is now necessary? I'm afraid it is not clear from the comment you have linked in your first post. |
With this PR something like |
It seems the PR does not work so far. When I use your version of |
Updated with @sunag's suggestion that fixes this. |
Can you please verify what happens when you replace a video after the initial use of a texture? Is |
video
is null
or undefined
Updated. I also moved |
|
||
video.requestVideoFrameCallback( updateVideo ); | ||
this._videoFrameCallback(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line sets needsUpdate
to true
when the video changes, which is correct behaviour, I think. (It has a side effect that it sets it after first created, but I think this shouldn't break anything?)
I have the feeling it is better to make the video to a mandatory parameter. In this case, we can avoid the additional code and keep the class more simple. |
One of the use cases for using three.js/examples/jsm/renderers/webgpu/WebGPUTextures.js Lines 59 to 61 in 03e4e05
Also, all other textures support ommiting image parameter (and all parameters).
|
The resulting complexity isn't satisfying. I think it's best to keep the code as it is. |
Well... But the original version of this PR wasn't that complex and you've requested to make it a bit more? But I don't think even the final version is so much more complex than it was originally... |
Also, I think multiple users (at least one issue linked in the original post and you can count me too) has requested in the past the possibility to change the VideoTexture source, which this PR also addresses (and which you've also requested above). @Mugen87 So may the decision to close this PR be reconsidered, please? I still think having this possibility would be better. |
Related issue: #25530 (comment) #24757 #24769
Description
Don't throw if
video
isnull
orundefined
. Also allow changing image source.