From 0166e6cb25c7cbb6f6f695b63ce5d4a5edfb8f27 Mon Sep 17 00:00:00 2001 From: kturkal <166247156+kturkal@users.noreply.github.com> Date: Sun, 6 Apr 2025 11:54:57 -0400 Subject: [PATCH] Created Shrink Animation (Opposite of Grow) --- src/animation/Shrink.ts | 13 +++++++++++++ src/animation/index.ts | 2 +- userScene/main.ts | 10 +++------- 3 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 src/animation/Shrink.ts diff --git a/src/animation/Shrink.ts b/src/animation/Shrink.ts new file mode 100644 index 0000000..df50f29 --- /dev/null +++ b/src/animation/Shrink.ts @@ -0,0 +1,13 @@ +import { Animation } from "./Animation.js"; +import * as THREE from "three"; + +export default class Shrink extends Animation { + constructor(object: THREE.Object3D) { + super( + (elapsedTime) => { + object.scale.set(1 - elapsedTime, 1 - elapsedTime, 1 - elapsedTime); + }, + { object, reveal: true }, + ); + } +} \ No newline at end of file diff --git a/src/animation/index.ts b/src/animation/index.ts index 0bc89c8..44dedca 100644 --- a/src/animation/index.ts +++ b/src/animation/index.ts @@ -12,7 +12,7 @@ export { default as Wait } from "./Wait.js"; export { default as Emphasize } from "./Emphasize.js"; export { default as Shake } from "./Shake.js"; export { default as Grow } from "./Grow.js"; +export { default as Shrink } from "./Shrink.js"; export { default as Stagger } from "./Stagger.js"; export { default as SetStyle } from "./SetStyle.js"; export { default as StaggerFadeIn } from "./StaggerFadeIn.js"; - diff --git a/userScene/main.ts b/userScene/main.ts index ffa462e..9a06d6a 100644 --- a/userScene/main.ts +++ b/userScene/main.ts @@ -31,13 +31,9 @@ export default class Scene implements StudioScene { this.animations = [ new Animation.Wait(), - new Animation.Animation((t, _) => { - triangle.reshape([ - new THREE.Vector3(-1, -1, 0), - new THREE.Vector3(1 + t, 1, 0), - new THREE.Vector3(1, -1, 0), - ]); - }), + new Animation.Shrink(triangle), + new Animation.Grow(triangle), + ]; } }