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

docs(cookbook): "Advanced Animations" cookbook recipe #586

Merged
merged 11 commits into from
May 28, 2024
24 changes: 23 additions & 1 deletion docs/cookbook/advanced-animations.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,26 @@ difficulty: 0

# Advanced Animations

In this guide, we are goning to use GSAP to animate our scene instead of the `useRenderLoop` composable.
In this guide, we are goning to use GSAP to animate our scene instead of the `useRenderLoop` composable.

<StackBlitzEmbed project-id="tresjs-advanced-animations" />

## Use GSAP to trigger animations on 3D Objects

We don't have to rely on `useRenderLoop` or TresJS to handle our animations. We could also leverage GSAP's `to` function for example:

```ts
import gsap from 'gsap';

const objectRef = shallowRef(null);

watchEffect(() => {
if (objectRef.value) {
gsap.to(objectRef.value.position, {
y: 2,
});
}
})
```

GSAP has been a very popular animation library and you can find a lot of help and resources online, including [these demos on codepen](https://codepen.io/GreenSock)
Loading