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
1 change: 1 addition & 0 deletions docs/.vitepress/config/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const deConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
items: [
{ text: 'Orbit-Controls', link: '/de/cookbook/orbit-controls' },
{ text: 'Einfache Animationen', link: '/de/cookbook/basic-animations' },
{ text: 'Fortgeschrittene Animationen', link: '/de/cookbook/advanced-animations' },
{ text: 'Gruppen', link: '/de/cookbook/groups' },
{ text: 'Texturen laden', link: '/de/cookbook/load-textures' },
{ text: 'Modelle laden', link: '/de/cookbook/load-models' },
Expand Down
70 changes: 37 additions & 33 deletions docs/.vitepress/config/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const enConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
items: [
{ text: 'Orbit Controls', link: '/cookbook/orbit-controls' },
{ text: 'Basic Animations', link: '/cookbook/basic-animations' },
{ text: 'Advanced Animations', link: '/cookbook/advanced-animations' },
{ text: 'Groups', link: '/cookbook/groups' },
{ text: 'Load Textures', link: '/cookbook/load-textures' },
{ text: 'Load Models', link: '/cookbook/load-models' },
Expand Down Expand Up @@ -107,39 +108,42 @@ export const enConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
{ text: 'API', link: '/api/tres-canvas' },
/* { text: 'API', link: '/api/' },
{ text: 'Config', link: '/config/' }, */
{ text: 'Resources', items: [
{ text: 'Team', link: '/team' },
{ text: 'Releases', link: 'https://github.com/Tresjs/tres/releases' },
{
text: 'Playground',
link: 'https://play.tresjs.org/',
},
{
text: 'Github',
link: 'https://github.com/Tresjs/tres/',
},
{
text: 'Issues',
link: 'https://github.com/Tresjs/tres/issues',
},
{
text: 'Ecosystem',
items: [
{
text: 'Cientos 💛',
link: 'https://cientos.tresjs.org/',
},
{
text: 'Nuxt module',
link: 'https://github.com/Tresjs/nuxt',
},
{
text: 'TresLeches 🍰',
link: 'https://tresleches.tresjs.org/',
},
],
},
] },
{
text: 'Resources',
items: [
{ text: 'Team', link: '/team' },
{ text: 'Releases', link: 'https://github.com/Tresjs/tres/releases' },
{
text: 'Playground',
link: 'https://play.tresjs.org/',
},
{
text: 'Github',
link: 'https://github.com/Tresjs/tres/',
},
{
text: 'Issues',
link: 'https://github.com/Tresjs/tres/issues',
},
{
text: 'Ecosystem',
items: [
{
text: 'Cientos 💛',
link: 'https://cientos.tresjs.org/',
},
{
text: 'Nuxt module',
link: 'https://github.com/Tresjs/nuxt',
},
{
text: 'TresLeches 🍰',
link: 'https://tresleches.tresjs.org/',
},
],
},
],
},
],
},
}
70 changes: 37 additions & 33 deletions docs/.vitepress/config/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const esConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
items: [
{ text: 'Controles de órbita', link: '/es/cookbook/orbit-controls' },
{ text: 'Animaciones básicas', link: '/es/cookbook/basic-animations' },
{ text: 'Advanced Animations', link: '/es/cookbook/advanced-animations' },
{ text: 'Grupos', link: '/es/cookbook/groups' },
{ text: 'Cargar texturas', link: '/es/cookbook/load-textures' },
{ text: 'Cargar modelos', link: '/es/cookbook/load-models' },
Expand Down Expand Up @@ -107,39 +108,42 @@ export const esConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
{ text: 'API', link: '/es/api/tres-canvas' },
/* { text: 'API', link: '/es/api/' },
{ text: 'Configuración', link: '/es/config/' }, */
{ text: 'Recursos', items: [
{ text: 'Equipo', link: '/es/team' },
{ text: 'Versiones', link: 'https://github.com/Tresjs/tres/releases' },
{
text: 'Playground',
link: 'https://play.tresjs.org/',
},
{
text: 'Github',
link: 'https://github.com/Tresjs/tres/',
},
{
text: 'Problemas',
link: 'https://github.com/Tresjs/tres/issues',
},
{
text: 'Ecosistema',
items: [
{
text: 'Cientos 💛',
link: 'https://cientos.tresjs.org/',
},
{
text: 'Módulo Nuxt',
link: 'https://github.com/Tresjs/nuxt',
},
{
text: 'TresLeches 🍰',
link: 'https://tresleches.tresjs.org/',
},
],
},
] },
{
text: 'Recursos',
items: [
{ text: 'Equipo', link: '/es/team' },
{ text: 'Versiones', link: 'https://github.com/Tresjs/tres/releases' },
{
text: 'Playground',
link: 'https://play.tresjs.org/',
},
{
text: 'Github',
link: 'https://github.com/Tresjs/tres/',
},
{
text: 'Problemas',
link: 'https://github.com/Tresjs/tres/issues',
},
{
text: 'Ecosistema',
items: [
{
text: 'Cientos 💛',
link: 'https://cientos.tresjs.org/',
},
{
text: 'Módulo Nuxt',
link: 'https://github.com/Tresjs/nuxt',
},
{
text: 'TresLeches 🍰',
link: 'https://tresleches.tresjs.org/',
},
],
},
],
},
],
search: {
provider: 'local',
Expand Down
35 changes: 35 additions & 0 deletions docs/cookbook/advanced-animations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
title: Advanced Animations
description: How to use GSAP to animate your scene
author: dennissmuda
thumbnail: /recipes/advanced-animations.png
difficulty: 0
---

# Advanced Animations

In this guide, we are going 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 is 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).

Of course there are lots of alternatives out there, and you should feel free to reach for _your_ favorite animation library!
35 changes: 35 additions & 0 deletions docs/de/cookbook/advanced-animations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
title: Fortgeschrittene Animationen
description: Wie man mit GSAP eine Szene animiert
author: dennissmuda
thumbnail: /recipes/animations.png
difficulty: 0
---

# Fortgeschrittene Animationen

In diesem Rezept werden wir GSAP verwenden um unsere Szene zu animieren, statt des `useRenderLoop`-Composables.

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

## 3D Objekte mit GSAP animieren

Wir müssen nicht unbedingt `useRenderLoop` oder gar TresJS für unsere Animationen benutzen. Zum Beispiel könnten wir auch GSAP's `to`-Method verwenden:

```ts
import gsap from 'gsap'

const objectRef = shallowRef(null)

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

GSAP ist schon seit vielen Jahren eine sehr beliebte Animations-Library im Web. Es gibt also unzählige Resourcen online wie zum Beispiel [diese Demos auf Codepen](https://codepen.io/GreenSock).

Du kannst natürlich auch _deine_ Lieblingsbibliothek nutzen, an Animations-Bibliotheken mangelt es im Web nicht!
11 changes: 11 additions & 0 deletions docs/es/cookbook/advanced-animations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: Animaciones avanzadas
description: Cómo utilizar GSAP para animar tu escena
author: dennissmuda
thumbnail: /recipes/animations.png
difficulty: 1
---

# Animaciones avanzadas

En esta guía, vamos a utilizar GSAP para animar nuestra escena en lugar del composable `useRenderLoop`.
Binary file added docs/public/recipes/advanced-animations.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading