Platinum sponsors

Three.js scenes

Edit Three.js objects and move them with the transform gizmo in your scene.

Animate through the adapter

Import the Three.js adapter and animate the Object3D itself, not its position or rotation objects:

import 'animejs/adapters/three';
import { animate } from 'animejs';

animate(mesh, {
  id: 'Hero mesh turn',
  rotateY: { from: 0, to: 180 },
  x: 20,
  duration: 1000,
  ease: 'inOut(3)',
});

The adapter's rotateX, rotateY and rotateZ use degrees.

Without a bundler, also map three, its addons and the adapter in the import map:

"three": "/node_modules/three/build/three.module.js",
"three/addons/": "/node_modules/three/examples/jsm/",
"animejs/adapters/three": "/node_modules/animejs/dist/modules/adapters/three/index.js"

Name your objects

The editor shows a Three.js object by its type and its name, such as Mesh.Hero mesh, in the target selector and on the timeline. An object without a name shows its Three.js id, such as Mesh.42, which changes when your scene changes. Give each object you animate a name:

mesh.name = 'Hero mesh';

Connect the camera and renderer

Pass the camera and the renderer that draw your scene to the editor, once both exist:

import { editor } from '@animatorkit/editor'; // Editor Kit without Vite: '@animatorkit/editor-kit'

editor.config({ three: { camera, renderer } });

The editor uses them to draw the transform gizmo Kit over the selected object in your scene. Keep this call and its import in development only code.

The 3D transform gizmo over the 5 of the Anime.js v5 logo, a Three.js scene

Parameters

Name Accepts
camera The Camera that renders the scene
renderer The WebGLRenderer that draws it
layer (opt) A free layer index for the gizmo, for scenes that use post processing
render (opt) A Function that draws the scene once, for scenes that render on demand
onDraggingChanged (opt) A Function called with true when a gizmo drag starts and false when it ends, for example to pause orbit controls

Rendering

Keep rendering the scene while the animation is paused, so the gizmo and your edits show up during a seek or a drag. A scene that renders only from an animation's onUpdate callback can leave the gizmo missing.

A scene that renders on demand can pass its draw call as render instead. The editor calls it each time the gizmo changes, when it shows, on hover, during a drag and when it hides:

editor.config({ three: { camera, renderer, render: () => view.render() } });

With outline, bloom or trail post processing, give the gizmo its own layer, keep that layer out of your normal camera pass, and draw it over the finished frame.

Previous
Next