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

Control GLTF animation based on a value or scroll. #648

Open
4 tasks done
AnupamKris opened this issue Apr 16, 2024 · 6 comments
Open
4 tasks done

Control GLTF animation based on a value or scroll. #648

AnupamKris opened this issue Apr 16, 2024 · 6 comments

Comments

@AnupamKris
Copy link

AnupamKris commented Apr 16, 2024

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

@alvarosabu alvarosabu added pending-triage Ticket is pending to be prioritised investigation labels Apr 17, 2024
@alvarosabu
Copy link
Member

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

@AnupamKris
Copy link
Author

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()

@alvarosabu
Copy link
Member

Can you add a minimal reproduction of your use-case so we can help you?

@AnupamKris
Copy link
Author

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..

@AnupamKris
Copy link
Author

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.

@JaimeTorrealba
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants