Communitygithub.com

BEKO2210/Firstbrain

Animation Three.js - animation par images clés, animation squelettique, cibles de morphing, mixage d'animations. À utiliser pour animer des objets, jouer des animations GLTF, créer du mouvement procédural ou mélanger des animations.

Qu'est-ce que Firstbrain ?

Cette compétence est un guide complet pour le système d'animation de Three.js. Elle couvre les composants essentiels : AnimationClip (conteneur de données d'images clés), AnimationMixer (lecteur d'animations) et AnimationAction (contrôle de la lecture). Elle permet d'animer des propriétés comme la position, la rotation, l'opacité et les couleurs, via des pistes d'images clés spécialisées (NumberKeyframeTrack, VectorKeyframeTrack, QuaternionKeyframeTrack, etc.). La compétence détaille le chargement et la lecture d'animations GLTF, l'animation squelettique (manipulation d'os, attachement d'objets), les cibles de morphing (transition entre formes de maillage) et le mixage d'animations (fusion pondérée, fondu enchaîné, blending additif). Elle propose des patterns d'animation procédurale (amortissement, ressorts, oscillations) et des conseils de performance, le tout accompagné d'exemples de code complets. La compétence précise que `THREE.Timer` est recommandé depuis r183 pour une gestion plus fiable du temps par rapport à `THREE.Clock`.

Compatible avec~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/BEKO2210/Firstbrain/tree/HEAD/03%20-%20Resources/Skills/threejs-animation

Demander à votre IA préférée

Ouvre une nouvelle conversation avec cette compétence d'agent déjà préchargée.

Documentation

Animation Three.js

Quand l'utiliser

  • Vous devez animer des objets, des armatures, des cibles de morphing ou des animations GLTF importées dans Three.js.
  • La tâche implique des mixeurs, des clips, des images clés, du mouvement procédural ou du mixage d'animations.
  • Vous construisez un comportement animé dans une scène Three.js plutôt qu'un rendu statique.

Démarrage rapide

import * as THREE from "three";

// Animation procédurale simple avec Timer (recommandé depuis r183)
const timer = new THREE.Timer();

renderer.setAnimationLoop(() => {
  timer.update();
  const delta = timer.getDelta();
  const elapsed = timer.getElapsed();

  mesh.rotation.y += delta;
  mesh.position.y = Math.sin(elapsed) * 0.5;

  renderer.render(scene, camera);
});

Remarque : THREE.Timer est recommandé par rapport à THREE.Clock depuis r183. Timer se met en pause lorsque la page est cachée et possède une API plus propre. THREE.Clock fonctionne toujours mais est considéré comme hérité.

Aperçu du système d'animation

Le système d'animation Three.js comprend trois composants principaux :

  1. AnimationClip - Conteneur pour les données d'images clés
  2. AnimationMixer - Joue les animations sur un objet racine
  3. AnimationAction - Contrôle la lecture d'un clip

AnimationClip

Stocke les données d'animation par images clés.

// Créer un clip d'animation
const times = [0, 1, 2]; // Temps des images clés (secondes)
const values = [0, 1, 0]; // Valeurs à chaque image clé

const track = new THREE.NumberKeyframeTrack(
  ".position[y]", // Chemin de la propriété
  times,
  values,
);

const clip = new THREE.AnimationClip("bounce", 2, [track]);

Types de KeyframeTrack

// Piste numérique (valeur unique)
new THREE.NumberKeyframeTrack(".opacity", times, [1, 0]);
new THREE.NumberKeyframeTrack(".material.opacity", times, [1, 0]);

// Piste vectorielle (position, échelle)
new THREE.VectorKeyframeTrack(".position", times, [
  0,
  0,
  0, // t=0
  1,
  2,
  0, // t=1
  0,
  0,
  0, // t=2
]);

// Piste de quaternion (rotation)
const q1 = new THREE.Quaternion().setFromEuler(new THREE.Euler(0, 0, 0));
const q2 = new THREE.Quaternion().setFromEuler(new THREE.Euler(0, Math.PI, 0));
new THREE.QuaternionKeyframeTrack(
  ".quaternion",
  [0, 1],
  [q1.x, q1.y, q1.z, q1.w, q2.x, q2.y, q2.z, q2.w],
);

// Piste de couleur
new THREE.ColorKeyframeTrack(".material.color", times, [
  1,
  0,
  0, // rouge
  0,
  1,
  0, // vert
  0,
  0,
  1, // bleu
]);

// Piste booléenne
new THREE.BooleanKeyframeTrack(".visible", [0, 0.5, 1], [true, false, true]);

// Piste de chaîne (pour les cibles de morphing)
new THREE.StringKeyframeTrack(
  ".morphTargetInfluences[smile]",
  [0, 1],
  ["0", "1"],
);

Modes d'interpolation

const track = new THREE.VectorKeyframeTrack(".position", times, values);

// Interpolation
track.setInterpolation(THREE.InterpolateLinear); // Par défaut
track.setInterpolation(THREE.InterpolateSmooth); // Spline cubique
track.setInterpolation(THREE.InterpolateDiscrete); // Fonction en escalier

BezierInterpolant (r183)

Three.js r183 ajoute THREE.BezierInterpolant pour l'interpolation par courbes de Bézier dans les pistes d'images clés, permettant des courbes d'animation plus fluides avec contrôle des tangentes.

AnimationMixer

Joue des animations sur un objet et ses descendants.

const mixer = new THREE.AnimationMixer(model);

// Créer une action à partir d'un clip
const action = mixer.clipAction(clip);
action.play();

// Mise à jour dans la boucle d'animation
function animate() {
  const delta = clock.getDelta();
  mixer.update(delta); // Obligatoire !

  requestAnimationFrame(animate);
  renderer.render(scene, camera);
}

Événements du Mixer

mixer.addEventListener("finished", (e) => {
  console.log(\

Individual skills in this repo

This repo contains 18 individual skills — each has its own dedicated page.

BEKO2210/Firstbrain

Skill for discovering and researching autonomous AI agents, tools, and ecosystems using the AgentFolio directory.

BEKO2210/Firstbrain

Advanced JavaScript animation library skill for creating complex, high-performance web animations.

BEKO2210/Firstbrain

One sentence - what this skill does and when to invoke it

BEKO2210/Firstbrain

Audit and fix animation performance issues including layout thrashing, compositor properties, scroll-linked motion, and blur effects. Use when animations stutter, transitions jank, or reviewing CSS/JS animation performance.

BEKO2210/Firstbrain

Internationalization and localization patterns. Detecting hardcoded strings, managing translations, locale files, RTL support.

BEKO2210/Firstbrain

Expert in building portfolios that actually land jobs and clients -

BEKO2210/Firstbrain

Generates high-converting Next.js/React landing pages with Tailwind CSS. Uses PAS, AIDA, and BAB frameworks for optimized copy/components (Heroes, Features, Pricing). Focuses on Core Web Vitals/SEO.

BEKO2210/Firstbrain

AI-powered animation tool for creating motion in logos, UI, icons, and social media assets.

BEKO2210/Firstbrain

Best practices for Remotion - Video creation in React

BEKO2210/Firstbrain

Generate walkthrough videos from Stitch projects using Remotion with smooth transitions, zooming, and text overlays

BEKO2210/Firstbrain

Seek and analyze video content using Memories.ai Large Visual Memory Model for persistent video intelligence

BEKO2210/Firstbrain

Writes complete, structured landing pages optimized for SEO ranking, AEO citation, and visitor conversion. Activate when the user wants to write or generate a landing page for a product, service, or offer.

BEKO2210/Firstbrain

Automate TikTok tasks via Rube MCP (Composio): upload/publish videos, post photos, manage content, and view user profiles/stats. Always search tools first for current schemas.

BEKO2210/Firstbrain

Video and audio perception, indexing, and editing. Ingest files/URLs/live streams, build visual/spoken indexes, search with timestamps, edit timelines, add overlays/subtitles, generate media, and create real-time alerts.

BEKO2210/Firstbrain

Upload, stream, search, edit, transcribe, and generate AI video and audio using the VideoDB SDK.

BEKO2210/Firstbrain

One sentence - what this skill does and when to invoke it

BEKO2210/Firstbrain

Automate YouTube tasks via Rube MCP (Composio): upload videos, manage playlists, search content, get analytics, and handle comments. Always search tools first for current schemas.

BEKO2210/Firstbrain

Extract transcripts from YouTube videos and generate comprehensive, detailed summaries using intelligent analysis frameworks

Skills associés