Hello Animation
Rotate, bounce, and scale a cube using clock.delta.
Controls
Speed
0.1
3
import * as EASEL from "easel";
const box = new EASEL.Mesh(
new EASEL.BoxGeometry(1, 1, 1),
new EASEL.LambertMaterial({ color: 0x4488ff }),
);
scene.add(box);
const clock = new EASEL.Clock();
let elapsed = 0;
function animate() {
requestAnimationFrame(animate);
const dt = clock.delta;
elapsed += dt;
// Rotation
box.rotation.y = elapsed;
// Sinusoidal bounce
box.position.y = Math.sin(elapsed * 2) * 0.5;
// Pulse scale
const s = 1 + Math.sin(elapsed * 3) * 0.15;
box.scale.set(s, s, s);
renderer.render(scene, camera);
}
animate();