Create professional demos and 3D mockups in seconds, directly in your browser
feat: add animation motion
CristianOlivera1831e41369243
diff --git a/lib/animation-core.ts b/lib/animation-core.tsnew file mode 100644index 0000000..0e62d22--- /dev/null+++ b/lib/animation-core.ts@@ -0,0 +1,30 @@+import { MotionStyle, ScriptFn } from "@/types/motion.types";+import gsap from "gsap";++// ─── Neutral resting position (slight 3-D tilt for depth) ────────────────────+export const NRX = 12;+export const NRY = -22;++// ─── Style → easing / amplitude config ───────────────────────────────────────+export const STYLE_CFG: Record<MotionStyle, {+ amp: number;+ e1: string;+ e2: string;+ e3: string;+}> = {+ smooth: { amp: 0.65, e1: "power1.inOut", e2: "power2.out", e3: "sine.inOut" },+ normal: { amp: 1.00, e1: "power2.inOut", e2: "power3.out", e3: "power2.inOut" },+ cinematic: { amp: 1.35, e1: "expo.inOut", e2: "power4.out", e3: "expo.inOut" },+};++// ─── Idle: gentle ambient float used when no template script is defined ───────+export const idleScript: ScriptFn = (av, intensity, _dur, style, onUpdate) => {+ const { amp, e1 } = STYLE_CFG[style];+ const a = intensity * amp;+ return gsap.timeline({ repeat: -1, defaults: { ease: e1, onUpdate } })+ .to(av, { rx: NRX + 10 * a, ry: NRY - 28 * a, tx: 22 * a, ty: -14 * a, sc: 1.00, duration: 4.0 })+ .to(av, { rx: NRX + 20 * a, ry: NRY - 58 * a, tx: -18 * a, ty: 10 * a, sc: 0.97, duration: 4.5 })+ .to(av, { rx: NRX + 6 * a, ry: NRY - 80 * a, tx: 12 * a, ty: -20 * a, sc: 1.00, duration: 3.8 })+ .to(av, { rx: NRX + 24 * a, ry: NRY - 50 * a, tx: -28 * a, ty: 16 * a, sc: 0.98, duration: 4.2 })+ .to(av, { rx: NRX + 10 * a, ry: NRY - 28 * a, tx: 0, ty: 0, sc: 1.00, duration: 3.5 });+};\ No newline at end of filediff --git a/lib/canvas-elements.config.ts b/lib/canvas-elements.config.tsindex 151e8fa..85f16ae 100644--- a/lib/canvas-elements.config.ts+++ b/lib/canvas-elements.config.ts@@ -61,7 +61,13 @@ export const PINNED_IMAGE_ITEMS = [{ id: "sticker-60", name: "Sticker 60", imagePath: "/elements/images/stickers/sticker-60.webp" },{ id: "sticker-61", name: "Sticker 61", imagePath: "/elements/images/stickers/sticker-61.webp" },{ id: "sticker-62", name: "Sticker 62", imagePath: "/elements/images/stickers/sticker-62.webp" },+ { id: "sticker-63", name: "Sticker 63", imagePath: "/elements/images/stickers/sticker-63.webp" },{ id: "sticker-69", name: "Sticker 69", imagePath: "/elements/images/stickers/sticker-69.webp" },+ { id: "sticker-70", name: "Sticker 70", imagePath: "/elements/images/stickers/sticker-70.webp" },+ { id: "sticker-71", name: "Sticker 71", imagePath: "/elements/images/stickers/sticker-71.webp" },+ { id: "sticker-72", name: "Sticker 72", imagePath: "/elements/images/stickers/sticker-72.webp" },+ { id: "sticker-73", name: "Sticker 73", imagePath: "/elements/images/stickers/sticker-73.webp" },+ { id: "sticker-74", name: "Sticker 74", imagePath: "/elements/images/stickers/sticker-74.webp" },];export const SVG_CATEGORIES: SvgCategory[] = [diff --git a/lib/template-registry.ts b/lib/template-registry.tsnew file mode 100644index 0000000..0548c4d--- /dev/null+++ b/lib/template-registry.ts@@ -0,0 +1,21 @@+import { phoneTemplate } from "@/app/components/ui/editor/templates-motion/Phone";+import { MotionTemplate } from "@/types/motion.types";++// ─── "No phone" option (no script, no EditorPanel, just deactivates the overlay)+const soloVideoTemplate: MotionTemplate = {+ id: "none",+ title: "Solo video",+ description: "Muestra el video sin mockup de dispositivo",+ accentColor: "#71717a",+ icon: "ph:video-bold",+ tags: ["Video"],+ defaultDuration: 0,+ showPhone: false,+};++export const TEMPLATES: MotionTemplate[] = [+ soloVideoTemplate,+ phoneTemplate,+];++export { soloVideoTemplate };\ No newline at end of filediff --git a/lib/video-upload-cache.ts b/lib/video-upload-cache.tsindex 36bf1d3..b991136 100644--- a/lib/video-upload-cache.ts+++ b/lib/video-upload-cache.ts@@ -60,7 +60,6 @@ async function openDB(): Promise<IDBDatabase> {});}-function calculateAspectRatio(width: number, height: number): string {if (!width || !height) return "auto";const gcd = (a: number, b: number): number => (b === 0 ? a : gcd(b, a % b));