tres
tres copied to clipboard
Control GLTF animation based on a value or scroll.
Description
I have a model which is animated in blender and I am able to play it in Tres. But I want to control the timeline based on the window scroll or any value in the app. How can I achieve this? I went through the docs completely but didn't find anything..
Suggested solution
A function to control the animation like setTime or setFrame.
Alternative
No response
Reproduction Repository
https://github.com/AnupamKris/threeBugFix
Validations
- [X] I agree to follow this project's Code of Conduct
- [X] Read the Contributing Guidelines.
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Hi @AnupamKris do you mean creating an AnimationMixer
? If so you can do it with this composable available on cientos
package https://cientos.tresjs.org/guide/abstractions/use-animations.html#useanimations
If you are looking for a way to take control of the whole renderer loop, you will need to wait for future releases, we are working on it atm, see #633 for more info
I want to know if I could bind the animations timeline or seek to a value in vue. I saw the mixer.setTime()
and mixer.update()
functions, but nothing seems to be affecting the animation. When I tried it. I took the mixer object from the useAnimations()
Can you add a minimal reproduction of your use-case so we can help you?
Sorry I saw this message late, Ill put a stackblitz to explain my usecase asap tomorrow. I want to achieve something similar to the box moving effect on scroll on TresJS Home page but with animations inside GLTF file..
Hi, I've added the repo to reproduce.. So I have an GLTF with an animation I want to control the timeline of the animation with the range slider that I have in the script.
I was playing with this. https://app.screencastify.com/v3/watch/5cDL9JzkTyrbhG5exoOW
That is what you're looking for?
The scroll is controling the animations of the model
https://stackblitz.com/edit/stackblitz-starters-xqaza7?file=src%2Fcomponents%2FTheModel.vue,src%2Fcomponents%2FTheExperience.vue
I'm going to close this due to inactivity. Feel free to open it again if needed @AnupamKris
@JaimeTorrealba yes that was exactly what I was trying to do. When I tried to do something similar I had a lot of errors and the setTime didn't work. So maybe an update fixed it.