Skip to content

Create professional demos and 3D mockups in seconds, directly in your browser

fix: upload preview and leva implementation

CristianOlivera116ab07f6377b
diff --git a/app/components/ui/editor/IPhone13ProMax3DViewer.tsx b/app/components/ui/editor/IPhone13ProMax3DViewer.tsx
index b17cb50..5d0d741 100644
--- a/app/components/ui/editor/IPhone13ProMax3DViewer.tsx
+++ b/app/components/ui/editor/IPhone13ProMax3DViewer.tsx
@@ -1,12 +1,7 @@
"use client";
import { Canvas, useThree } from "@react-three/fiber";
-import {
- PerspectiveCamera,
- useGLTF,
- Environment,
- OrbitControls,
-} from "@react-three/drei";
+import { PerspectiveCamera, useGLTF, Environment, OrbitControls } from "@react-three/drei";
import { useEffect, useRef, useState, Suspense } from "react";
import * as THREE from "three";
import {
@@ -15,6 +10,10 @@ import {
parseShadowColor,
type ImageMaskConfigLike,
} from "@/lib/phone3d.utils";
+import type { OrbitControls as OrbitControlsType } from 'three-stdlib';
+
+import { ControlsPopup } from "@/components/ui/ControlsPopup";
+import { EnvironmentPreset, ViewerControls3D } from "@/lib/viewer-controls3d";
export interface IPhone13ProMax3DApi {
renderAt: (width: number, height: number) => void;
@@ -36,13 +35,11 @@ interface Props {
shadowColor?: string;
}
-// ─── Textura de pantalla ─────────────────────────────────────────────────────
const TEX_W = 1284 * 2;
const TEX_H = 2778 * 2;
useGLTF.preload("/models/apple_iphone_13_pro_max.glb");
-// ─── Tipos del GLB ──────────────────────────────────────────────────────────
interface GLTFNodes {
Frame_Frame_0: THREE.Mesh;
Frame_Frame2_0: THREE.Mesh;
@@ -98,7 +95,6 @@ interface GLTFMaterials {
"Material.002": THREE.Material;
}
-// ─── Escena 3D ──────────────────────────────────────────────────────────────
function ModelScene({
imageUrl,
imageMaskConfig,
@@ -126,29 +122,32 @@ function ModelScene({
onApi?: (api: IPhone13ProMax3DApi | null) => void;
onLoaded?: () => void;
}) {
- const { gl } = useThree(); // Usamos useThree para obtener el contexto de WebGL y sus capabilities
+ const { gl } = useThree();
const gltf = useGLTF("/models/apple_iphone_13_pro_max.glb") as unknown as {
nodes: GLTFNodes;
materials: GLTFMaterials;
};
const { nodes, materials } = gltf;
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- const orbitRef = useRef<any>(null);
+ const orbitRef = useRef<OrbitControlsType | null>(null);
const lastLoadedImageUrlRef = useRef<string | null>(null);
const lastLoadedMaskKeyRef = useRef<string | null>(null);
const lastLoadedCropKeyRef = useRef<string | null>(null);
const wallpaperMatRef = useRef<THREE.MeshStandardMaterial | null>(null);
+ const { autoRotate, rotationSpeed, glow, environment } = ViewerControls3D();
+
useEffect(() => {
const api: IPhone13ProMax3DApi = {
- renderAt: (w, h) => { void w; void h; },
+ renderAt: (w, h) => {
+ void w;
+ void h;
+ },
};
onApi?.(api);
return () => onApi?.(null);
}, [onApi]);
- // Notificar que el modelo base cargó (independiente de la imagen)
useEffect(() => {
onLoaded?.();
}, [onLoaded]);
@@ -167,7 +166,11 @@ function ModelScene({
const cropKey = cropArea ? JSON.stringify(cropArea) : null;
if (!imageUrl) {
- if (mat.map) { mat.map.dispose(); mat.map = null; mat.needsUpdate = true; }
+ if (mat.map) {
+ mat.map.dispose();
+ mat.map = null;
+ mat.needsUpdate = true;
+ }
lastLoadedImageUrlRef.current = null;
lastLoadedMaskKeyRef.current = null;
lastLoadedCropKeyRef.current = null;
@@ -178,15 +181,19 @@ function ModelScene({
lastLoadedImageUrlRef.current === imageUrl &&
lastLoadedMaskKeyRef.current === maskKey &&
lastLoadedCropKeyRef.current === cropKey
- ) return;
+ )
+ return;
const img = new Image();
img.crossOrigin = "anonymous";
img.onload = () => {
- // Se aplica el recorte a la imagen si cropArea está presente
const sourceImage = cropArea ? applyCropToImage(img, cropArea) : img;
const cover = createCoverScreenCanvas(sourceImage, TEX_W, TEX_H, 0, imageMaskConfig);
- if (mat.map) { mat.map.dispose(); mat.map = null; }
+
+ if (mat.map) {
+ mat.map.dispose();
+ mat.map = null;
+ }
const tex = new THREE.CanvasTexture(cover);
tex.flipY = true;
@@ -196,10 +203,7 @@ function ModelScene({
tex.magFilter = THREE.LinearFilter;
tex.wrapS = THREE.ClampToEdgeWrapping;
tex.wrapT = THREE.ClampToEdgeWrapping;
-
- // EL SECRETO PARA LOS ÁNGULOS: Filtro Anisotrópico al máximo
tex.anisotropy = gl.capabilities.getMaxAnisotropy();
-
mat.map = tex;
mat.needsUpdate = true;
@@ -233,21 +237,21 @@ function ModelScene({
return (
<>
- <PerspectiveCamera
- ref={cameraRef}
- makeDefault
- fov={40}
- near={0.01}
- far={100}
- position={[0, 0, 1.5 / zoom]}
+ <PerspectiveCamera ref={cameraRef} makeDefault fov={40} near={0.01} far={100} position={[0, 0, 1.5 / zoom]} />
+
+ <Environment
+ preset={environment as EnvironmentPreset}
+ environmentIntensity={glow}
/>
-
+
<OrbitControls
ref={orbitRef}
enableZoom={false}
enablePan={false}
enableDamping
dampingFactor={0.08}
+ autoRotate={autoRotate}
+ autoRotateSpeed={rotationSpeed}
onEnd={() => {
const orbit = orbitRef.current;
if (!orbit || !onRotationChange) return;
@@ -256,13 +260,12 @@ function ModelScene({
onRotationChange(rx, ry);
}}
/>
-
- <Environment preset="studio" background={false} />
+
<ambientLight intensity={0.3} />
<directionalLight position={[3, 6, 5]} intensity={0.6} />
<directionalLight position={[-4, -2, 3]} intensity={0.25} color="#c8d8ff" />
<directionalLight position={[0, -5, 5]} intensity={0.35} />
-
+
<group ref={rootRef} rotation={[0, Math.PI, 0]} scale={0.01} dispose={null}>
<group scale={100}>
<mesh castShadow receiveShadow geometry={nodes.Frame_Frame_0.geometry} material={materials.Frame} />
@@ -300,7 +303,6 @@ function ModelScene({
);
}
-// ─── CanvasWithLoader ────────────────────────────────────────────────────────
function CanvasWithLoader({
imageUrl,
imageMaskConfig,
@@ -329,7 +331,6 @@ function CanvasWithLoader({
onMount?: (canvas: HTMLCanvasElement) => void;
}) {
const [loaded, setLoaded] = useState(false);
-
return (
<>
<Canvas
@@ -350,7 +351,6 @@ function CanvasWithLoader({
onMount?.(gl.domElement);
}}
>
- {/* Suspense es OBLIGATORIO cuando se usa useGLTF para evitar crashes */}
<Suspense fallback={null}>
<ModelScene
imageUrl={imageUrl}
@@ -368,7 +368,6 @@ function CanvasWithLoader({
/>
</Suspense>
</Canvas>
-
{!loaded && (
<div
className="absolute inset-0 flex items-center justify-center pointer-events-none"
@@ -381,7 +380,6 @@ function CanvasWithLoader({
);
}
-// ─── Componente público ──────────────────────────────────────────────────────
export function IPhone13ProMax3DViewer({
imageUrl = null,
imageMaskConfig = null,
@@ -409,71 +407,77 @@ export function IPhone13ProMax3DViewer({
const shadowRgba = shadowColor.startsWith("#")
? parseShadowColor(shadowColor, computedOpacity)
: shadowColor;
+
const hasShadow = t > 0.01;
return (
- <div
- style={{
- display: "inline-block",
- transformOrigin: "top center",
- width: 480,
- height: 1000 + (hasShadow ? computedBlur * 0.8 : 0),
- marginTop: "200px",
- marginLeft: "170px"
- }}
- >
- <div style={{ position: "relative", width: 480, height: 1000 }}>
- {hasShadow && (
+ <>
+ {/* 3. Renderizamos el panel extraído exactamente igual que en el otro componente */}
+ <ControlsPopup />
+
+ <div
+ style={{
+ display: "inline-block",
+ transformOrigin: "top center",
+ width: 480,
+ height: 1000 + (hasShadow ? computedBlur * 0.8 : 0),
+ marginTop: "200px",
+ marginLeft: "170px"
+ }}
+ >
+ <div style={{ position: "relative", width: 480, height: 1000 }}>
+ {hasShadow && (
+ <div
+ aria-hidden
+ style={{
+ position: "absolute",
+ bottom: -(computedBlur * 0.5),
+ left: `${20 + tEased * 5}%`,
+ width: `${60 - tEased * 10}%`,
+ height: Math.max(4, computedBlur * 0.55),
+ borderRadius: "50%",
+ background: shadowRgba,
+ filter: `blur(${Math.max(2, computedBlur * 0.6)}px)`,
+ zIndex: 0,
+ pointerEvents: "none",
+ }}
+ />
+ )}
+
<div
- aria-hidden
style={{
position: "absolute",
- bottom: -(computedBlur * 0.5),
- left: `${20 + tEased * 5}%`,
- width: `${60 - tEased * 10}%`,
- height: Math.max(4, computedBlur * 0.55),
- borderRadius: "50%",
- background: shadowRgba,
- filter: `blur(${Math.max(2, computedBlur * 0.6)}px)`,
- zIndex: 0,
- pointerEvents: "none",
+ inset: "-200px",
+ zIndex: 2,
+ overflow: "visible",
+ cursor: grabbing ? "grabbing" : "grab",
+ filter: hasShadow
+ ? `drop-shadow(0px ${(tEased * 22).toFixed(1)}px ${(tEased * 32).toFixed(1)}px ${shadowRgba})`
+ : "none",
+ transition: "filter 0.15s ease",
+ pointerEvents: "auto",
}}
- />
- )}
-
- <div
- style={{
- position: "absolute",
- inset: "-200px",
- zIndex: 2,
- overflow: "visible",
- cursor: grabbing ? "grabbing" : "grab",
- filter: hasShadow
- ? `drop-shadow(0px ${(tEased * 22).toFixed(1)}px ${(tEased * 32).toFixed(1)}px ${shadowRgba})`
- : "none",
- transition: "filter 0.15s ease",
- pointerEvents: "auto",
- }}
- onPointerDown={() => setGrabbing(true)}
- onPointerUp={() => setGrabbing(false)}
- onPointerLeave={() => setGrabbing(false)}
- >
- <CanvasWithLoader
- imageUrl={imageUrl}
- imageMaskConfig={imageMaskConfig}
- cropArea={cropArea}
- initialRotationX={initialRotationX}
- initialRotationY={initialRotationY}
- initialRotationZ={initialRotationZ}
- onRotationChange={onRotationChange}
- rootRef={rootRef}
- cameraRef={cameraRef}
- zoom={zoom}
- onApi={onApi}
- onMount={onMount}
- />
+ onPointerDown={() => setGrabbing(true)}
+ onPointerUp={() => setGrabbing(false)}
+ onPointerLeave={() => setGrabbing(false)}
+ >
+ <CanvasWithLoader
+ imageUrl={imageUrl}
+ imageMaskConfig={imageMaskConfig}
+ cropArea={cropArea}
+ initialRotationX={initialRotationX}
+ initialRotationY={initialRotationY}
+ initialRotationZ={initialRotationZ}
+ onRotationChange={onRotationChange}
+ rootRef={rootRef}
+ cameraRef={cameraRef}
+ zoom={zoom}
+ onApi={onApi}
+ onMount={onMount}
+ />
+ </div>
</div>
</div>
- </div>
+ </>
);
}
\ No newline at end of file
diff --git a/app/components/ui/editor/LabelSidebar.tsx b/app/components/ui/editor/LabelSidebar.tsx
index 7db8417..bf7bb73 100644
--- a/app/components/ui/editor/LabelSidebar.tsx
+++ b/app/components/ui/editor/LabelSidebar.tsx
@@ -11,7 +11,7 @@ export default function LabelSidebar({ audioTracksCount = 0 }: LabelSidebarProps
<span className="text-[9px] uppercase font-semibold tracking-wider text-zinc-500">Video</span>
</div>
- <div className={`flex items-center px-3 border-t border-white/5 transition-all duration-300 ${audioTracksCount > 0 ? 'h-12' : 'h-14'
+ <div className={`flex items-center px-3 border-t border-white/5 transition-all duration-300 ${audioTracksCount > 0 ? 'h-12' : 'h-15'
}`}>
<span className="text-[9px] uppercase font-semibold tracking-wider text-zinc-500">Zoom</span>
</div>
diff --git a/app/components/ui/editor/Laptop3DViewer.tsx b/app/components/ui/editor/Laptop3DViewer.tsx
index 5a992f3..dc2ecfe 100644
--- a/app/components/ui/editor/Laptop3DViewer.tsx
+++ b/app/components/ui/editor/Laptop3DViewer.tsx
@@ -11,15 +11,22 @@ import {
parseShadowColor,
type ImageMaskConfigLike,
} from "@/lib/phone3d.utils";
+import type { OrbitControls as OrbitControlsType } from 'three-stdlib';
+
+import { ControlsPopup } from "@/components/ui/ControlsPopup";
+import { EnvironmentPreset, ViewerControls3D } from "@/lib/viewer-controls3d";
const LAPTOP_W = 1500;
const LAPTOP_H = 1035;
+
const RENDER_MULTIPLIER = 3;
const RENDER_W = LAPTOP_W * RENDER_MULTIPLIER;
const RENDER_H = LAPTOP_H * RENDER_MULTIPLIER;
+
const CAM_FOV = 40;
const CAM_RADIUS = 75;
const screenSize: [number, number] = [29.4, 20];
+
const LID_CLOSED_X = Math.PI * 0.5;
const LID_OPEN_X = -0.2 * Math.PI;
const DEG = Math.PI / 180;
@@ -82,17 +89,18 @@ function ModelScene({
onLoaded?: () => void;
}) {
const { gl, scene, camera } = useThree();
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- const orbitRef = useRef<any>(null);
+ const orbitRef = useRef<OrbitControlsType | null>(null);
const [modelGroup, setModelGroup] = useState<THREE.Group | null>(null);
const lidGroupRef = useRef<THREE.Group | null>(null);
const screenMatRef = useRef<THREE.MeshBasicMaterial | null>(null);
-
const lastLoadedUrlRef = useRef<string | null>(null);
const lastLoadedCropKeyRef = useRef<string | null>(null);
- // 1. API Render Estático
+ const { autoRotate, rotationSpeed, glow, environment } = ViewerControls3D({
+ defaultEnvironment: "forest"
+ });
+
useEffect(() => {
const api: Laptop3DApi = {
renderAt: (w, h) => {
@@ -100,10 +108,13 @@ function ModelScene({
const oldAspect = cameraRef.current.aspect;
cameraRef.current.aspect = w / h;
cameraRef.current.updateProjectionMatrix();
+
gl.setSize(w, h, false);
gl.render(scene, cameraRef.current);
+
cameraRef.current.aspect = oldAspect;
cameraRef.current.updateProjectionMatrix();
+
gl.setSize(RENDER_W, RENDER_H, false);
},
};
@@ -111,7 +122,6 @@ function ModelScene({
return () => onApi?.(null);
}, [onApi, gl, scene, cameraRef]);
- // 2. Lógica de Texturas Asegurada
const applyTexture = useCallback(() => {
const mat = screenMatRef.current;
if (!mat) return;
@@ -143,7 +153,6 @@ function ModelScene({
const currentMat = screenMatRef.current;
if (!currentMat) return;
- // Usamos una resolución alta para evitar pixelación
const TEX_W = RENDER_W;
const TEX_H = RENDER_H;
@@ -163,7 +172,6 @@ function ModelScene({
tex.repeat.y = ((cover.width / cover.height) / screenSize[0]) * screenSize[1];
}
- // MEJORA DE CALIDAD: Filtrado anisotrópico al máximo soportado por la GPU
tex.generateMipmaps = true;
tex.minFilter = THREE.LinearMipmapLinearFilter;
tex.magFilter = THREE.LinearFilter;
@@ -194,7 +202,6 @@ function ModelScene({
applyTexture();
}, [applyTexture]);
- // 3. Cargar GLB del Laptop y Ensamblar Materiales
useEffect(() => {
let isMounted = true;
@@ -205,7 +212,6 @@ function ModelScene({
const tStart = Math.max(0, Math.min(1, openingProgress));
- // MEJORA DE CALIDAD: toneMapped: false evita que los colores de la captura se vean grises/oscuros
const screenMaterial = new THREE.MeshBasicMaterial({
map: null,
transparent: true,
@@ -219,7 +225,6 @@ function ModelScene({
const textLoader = new THREE.TextureLoader();
const keyboardMaterial = new THREE.MeshBasicMaterial({ color: 0xffffff, transparent: true, toneMapped: false });
textLoader.load("/images/pages/keyboard-overlay.png", (tex) => {
- // Filtrado nítido para el teclado también
tex.anisotropy = gl.capabilities.getMaxAnisotropy();
keyboardMaterial.alphaMap = tex;
keyboardMaterial.needsUpdate = true;
@@ -228,7 +233,6 @@ function ModelScene({
const finalizeSetup = (group: THREE.Group) => {
if (!isMounted) return;
setModelGroup(group);
-
setTimeout(() => {
if (!isMounted) return;
applyTextureRef.current();
@@ -289,14 +293,15 @@ function ModelScene({
console.error("Error al cargar el GLB del laptop:", err);
});
- return () => { isMounted = false; };
- // eslint-disable-next-line react-hooks/exhaustive-deps
+ return () => {
+ isMounted = false;
+ };
}, []);
- // 4. Actualizar posiciones de cámara dinámicas
useEffect(() => {
const orbit = orbitRef.current;
if (!orbit) return;
+
const radius = CAM_RADIUS / zoom;
const phi = Math.PI / 2 - initialRotationX * DEG;
const theta = initialRotationY * DEG;
@@ -304,7 +309,6 @@ function ModelScene({
orbit.update();
}, [initialRotationX, initialRotationY, zoom]);
- // 5. Animación de Apertura de Tapa y Rotación Base
useEffect(() => {
if (rootRef.current) rootRef.current.rotation.z = initialRotationZ * DEG;
}, [initialRotationZ, modelGroup]);
@@ -313,7 +317,6 @@ function ModelScene({
const lid = lidGroupRef.current;
const mat = screenMatRef.current;
if (!lid || !mat) return;
-
const t = Math.max(0, Math.min(1, openingProgress));
lid.rotation.x = lerp(LID_CLOSED_X, LID_OPEN_X, t);
mat.opacity = 0.96 * t;
@@ -329,6 +332,8 @@ function ModelScene({
enablePan={false}
enableDamping
dampingFactor={0.08}
+ autoRotate={autoRotate}
+ autoRotateSpeed={rotationSpeed}
onEnd={() => {
const orbit = orbitRef.current;
if (!orbit || !onRotationChange) return;
@@ -338,13 +343,16 @@ function ModelScene({
}}
/>
- <Environment preset="city" background={false} />
- <ambientLight intensity={3.2} />
+ <Environment
+ preset={environment as EnvironmentPreset}
+ environmentIntensity={glow}
+ background={false}
+ />
+ <ambientLight intensity={3.2} />
<group>
<pointLight position={[0, 5, 50]} intensity={0.8} color="#fff5e1" />
</group>
-
<directionalLight position={[4, 8, 7]} intensity={2.6} />
<directionalLight position={[-5, -2, 4]} intensity={0.8} color="#aabbff" />
<directionalLight position={[0, -6, 6]} intensity={1.3} />
@@ -356,10 +364,7 @@ function ModelScene({
);
}
-function CanvasWithLoader(props: Props & {
- rootRef: React.MutableRefObject<THREE.Group | null>;
- cameraRef: React.MutableRefObject<THREE.PerspectiveCamera | null>;
-}) {
+function CanvasWithLoader(props: Props & { rootRef: React.MutableRefObject<THREE.Group | null>; cameraRef: React.MutableRefObject<THREE.PerspectiveCamera | null>; }) {
const [loaded, setLoaded] = useState(false);
const handleLoaded = useCallback(() => setLoaded(true), []);
@@ -371,9 +376,8 @@ function CanvasWithLoader(props: Props & {
antialias: true,
alpha: true,
preserveDrawingBuffer: true,
- powerPreference: "high-performance" // <-- Prioriza la GPU dedicada
+ powerPreference: "high-performance"
}}
- // MEJORA DE CALIDAD: Recuperamos el supersampling (DPR * Multiplicador)
dpr={Math.min((typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1) * RENDER_MULTIPLIER, 4)}
onCreated={({ gl }) => {
gl.setClearColor(0x000000, 0);
@@ -387,7 +391,6 @@ function CanvasWithLoader(props: Props & {
<ModelScene {...props} onLoaded={handleLoaded} />
</Suspense>
</Canvas>
-
{!loaded && (
<div className="absolute inset-0 flex items-center justify-center pointer-events-none" style={{ zIndex: 4 }}>
<div className="w-6 h-6 border-2 border-white/20 border-t-white/60 rounded-full animate-spin" />
@@ -398,10 +401,7 @@ function CanvasWithLoader(props: Props & {
}
export function Laptop3DViewer(props: Props) {
- const {
- shadowIntensity = 0,
- shadowColor = "#000000",
- } = props;
+ const { shadowIntensity = 0, shadowColor = "#000000" } = props;
const rootRef = useRef<THREE.Group | null>(null);
const cameraRef = useRef<THREE.PerspectiveCamera | null>(null);
@@ -419,66 +419,68 @@ export function Laptop3DViewer(props: Props) {
const hasShadow = t > 0.01;
return (
- <div
- style={{
- display: "inline-block",
- transformOrigin: "top center",
- width: LAPTOP_W,
- height: LAPTOP_H + (hasShadow ? computedBlur * 0.8 : 0),
- marginTop: "250px",
- }}
- >
+ <>
+ <ControlsPopup />
+
<div
style={{
- position: "relative",
+ display: "inline-block",
+ transformOrigin: "top center",
width: LAPTOP_W,
- height: LAPTOP_H,
- overflow: "visible",
- willChange: "transform",
+ height: LAPTOP_H + (hasShadow ? computedBlur * 0.8 : 0),
+ marginTop: "250px",
}}
>
- {/* Sombra proyectada */}
- {hasShadow && (
- <div
- aria-hidden
- style={{
- position: "absolute",
- bottom: -(computedBlur * 0.5),
- left: `${10 + tEased * 5}%`,
- width: `${80 - tEased * 10}%`,
- height: Math.max(4, computedBlur * 0.55),
- borderRadius: "50%",
- background: shadowRgba,
- filter: `blur(${Math.max(2, computedBlur * 0.6)}px)`,
- zIndex: 0,
- pointerEvents: "none",
- }}
- />
- )}
-
- {/* Canvas WebGL Container */}
<div
style={{
- position: "absolute",
- left: 0,
- top: 0,
+ position: "relative",
width: LAPTOP_W,
height: LAPTOP_H,
overflow: "visible",
- zIndex: 2,
- cursor: grabbing ? "grabbing" : "grab",
- filter: hasShadow
- ? `drop-shadow(0px ${(tEased * 22).toFixed(1)}px ${(tEased * 32).toFixed(1)}px ${shadowRgba})`
- : "none",
- transition: "filter 0.15s ease",
+ willChange: "transform",
}}
- onPointerDown={() => setGrabbing(true)}
- onPointerUp={() => setGrabbing(false)}
- onPointerLeave={() => setGrabbing(false)}
>
- <CanvasWithLoader {...props} rootRef={rootRef} cameraRef={cameraRef} />
+ {hasShadow && (
+ <div
+ aria-hidden
+ style={{
+ position: "absolute",
+ bottom: -(computedBlur * 0.5),
+ left: `${10 + tEased * 5}%`,
+ width: `${80 - tEased * 10}%`,
+ height: Math.max(4, computedBlur * 0.55),
+ borderRadius: "50%",
+ background: shadowRgba,
+ filter: `blur(${Math.max(2, computedBlur * 0.6)}px)`,
+ zIndex: 0,
+ pointerEvents: "none",
+ }}
+ />
+ )}
+
+ <div
+ style={{
+ position: "absolute",
+ left: 0,
+ top: 0,
+ width: LAPTOP_W,
+ height: LAPTOP_H,
+ overflow: "visible",
+ zIndex: 2,
+ cursor: grabbing ? "grabbing" : "grab",
+ filter: hasShadow
+ ? `drop-shadow(0px ${(tEased * 22).toFixed(1)}px ${(tEased * 32).toFixed(1)}px ${shadowRgba})`
+ : "none",
+ transition: "filter 0.15s ease",
+ }}
+ onPointerDown={() => setGrabbing(true)}
+ onPointerUp={() => setGrabbing(false)}
+ onPointerLeave={() => setGrabbing(false)}
+ >
+ <CanvasWithLoader {...props} rootRef={rootRef} cameraRef={cameraRef} />
+ </div>
</div>
</div>
- </div>
+ </>
);
}
\ No newline at end of file
diff --git a/app/components/ui/editor/Mockup3dMenu.tsx b/app/components/ui/editor/Mockup3dMenu.tsx
index 3620816..e6cf4b4 100644
--- a/app/components/ui/editor/Mockup3dMenu.tsx
+++ b/app/components/ui/editor/Mockup3dMenu.tsx
@@ -173,8 +173,10 @@ export function Mockup3dMenu({
setImagePhoneX(0);
setImagePhoneY(0);
setImagePhoneScale(0.8);
- setImagePhoneRotX(0);
- setImagePhoneRotY(0);
+ const defaultRotX = imagePhoneDevice === "laptop" ? 43.23 : -58.23;
+ const defaultRotY = imagePhoneDevice === "laptop" ? -37.82 : -29.82;
+ setImagePhoneRotX(defaultRotX);
+ setImagePhoneRotY(defaultRotY);
if (imagePhoneDevice === "laptop") {
setImagePhoneOpening(1);
setImagePhoneShadow(0.7);
diff --git a/app/components/ui/editor/Phone3DViewer.tsx b/app/components/ui/editor/Phone3DViewer.tsx
index 0767b52..daca9b9 100644
--- a/app/components/ui/editor/Phone3DViewer.tsx
+++ b/app/components/ui/editor/Phone3DViewer.tsx
@@ -6,485 +6,463 @@ import { useEffect, useRef, useState, Suspense, useCallback } from "react";
import * as THREE from "three";
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
import {
- PHONE_W,
- PHONE_H,
- deviceConfigs,
- getDeviceFromModelUrl,
- createCoverScreenCanvas,
- applyCropToImage,
- loadGltfGroup,
- cloneGroup,
- type ImageMaskConfigLike,
- parseShadowColor,
+ PHONE_W,
+ PHONE_H,
+ deviceConfigs,
+ getDeviceFromModelUrl,
+ createCoverScreenCanvas,
+ applyCropToImage,
+ loadGltfGroup,
+ cloneGroup,
+ type ImageMaskConfigLike,
+ parseShadowColor,
} from "@/lib/phone3d.utils";
+import type { OrbitControls as OrbitControlsType } from 'three-stdlib';
+
+// 1. Importamos tu popup y el nuevo custom hook
+import { ControlsPopup } from "@/components/ui/ControlsPopup";
+import { EnvironmentPreset, ViewerControls3D } from "@/lib/viewer-controls3d";
export interface Phone3DApi {
- renderAt: (width: number, height: number) => void;
+ renderAt: (width: number, height: number) => void;
}
interface Props {
- imageUrl?: string | null;
- imageMaskConfig?: ImageMaskConfigLike | null;
- cropArea?: { x: number; y: number; width: number; height: number } | null;
- initialRotationX?: number;
- initialRotationY?: number;
- initialRotationZ?: number;
- onRotationChange?: (rx: number, ry: number) => void;
- onMount?: (canvas: HTMLCanvasElement) => void;
- onApi?: (api: Phone3DApi | null) => void;
- modelUrl?: string;
- scale?: number;
- zoom?: number;
- shadowIntensity?: number;
- shadowColor?: string;
+ imageUrl?: string | null;
+ imageMaskConfig?: ImageMaskConfigLike | null;
+ cropArea?: { x: number; y: number; width: number; height: number } | null;
+ initialRotationX?: number;
+ initialRotationY?: number;
+ initialRotationZ?: number;
+ onRotationChange?: (rx: number, ry: number) => void;
+ onMount?: (canvas: HTMLCanvasElement) => void;
+ onApi?: (api: Phone3DApi | null) => void;
+ modelUrl?: string;
+ scale?: number;
+ zoom?: number;
+ shadowIntensity?: number;
+ shadowColor?: string;
}
-// ─── Constantes y Helpers de Carga ──────────────────────────────────────────
const DEG = Math.PI / 180;
const specificGltfCache = new Map<string, Promise<THREE.Group>>();
function loadSpecificGltf(url: string): Promise<THREE.Group> {
- if (!specificGltfCache.has(url)) {
- specificGltfCache.set(
- url,
- new Promise((resolve, reject) => {
- new GLTFLoader().load(url, (gltf) => resolve(gltf.scene), undefined, reject);
- })
- );
- }
- return specificGltfCache.get(url)!;
+ if (!specificGltfCache.has(url)) {
+ specificGltfCache.set(
+ url,
+ new Promise((resolve, reject) => {
+ new GLTFLoader().load(url, (gltf) => resolve(gltf.scene), undefined, reject);
+ })
+ );
+ }
+ return specificGltfCache.get(url)!;
}
function applyMetalMaterial(m: THREE.MeshStandardMaterial, matName: string): void {
- if (matName.includes("Body")) {
- m.color.set(0x787878); m.roughness = 0.18; m.metalness = 0.85; m.envMapIntensity = 1.4;
- }
- if (matName.includes("Bezel")) {
- m.color.set(0x909090); m.roughness = 0.12; m.metalness = 0.92; m.envMapIntensity = 1.6;
- }
- if (matName.includes("Buttons")) {
- m.color.set(0x999999); m.roughness = 0.15; m.metalness = 0.88; m.envMapIntensity = 1.5;
- }
- if (matName.includes("Lenses")) {
- m.color.set(0x060608); m.roughness = 0.04; m.metalness = 0.70; m.envMapIntensity = 2.0;
- }
+ if (matName.includes("Body")) {
+ m.color.set(0x787878); m.roughness = 0.18; m.metalness = 0.85; m.envMapIntensity = 1.4;
+ }
+ if (matName.includes("Bezel")) {
+ m.color.set(0x909090); m.roughness = 0.12; m.metalness = 0.92; m.envMapIntensity = 1.6;
+ }
+ if (matName.includes("Buttons")) {
+ m.color.set(0x999999); m.roughness = 0.15; m.metalness = 0.88; m.envMapIntensity = 1.5;
+ }
+ if (matName.includes("Lenses")) {
+ m.color.set(0x060608); m.roughness = 0.04; m.metalness = 0.70; m.envMapIntensity = 2.0;
+ }
}
-// ─── Escena 3D ──────────────────────────────────────────────────────────────
function ModelScene({
- imageUrl,
- imageMaskConfig,
- cropArea,
- initialRotationX = -58.23,
- initialRotationY = -29,
- initialRotationZ = 0,
- onRotationChange,
- rootRef,
- cameraRef,
- zoom = 1,
- modelUrl,
- onApi,
- onLoaded,
+ imageUrl,
+ imageMaskConfig,
+ cropArea,
+ initialRotationX = -58.23,
+ initialRotationY = -29,
+ initialRotationZ = 0,
+ onRotationChange,
+ rootRef,
+ cameraRef,
+ zoom = 1,
+ modelUrl,
+ onApi,
+ onLoaded,
}: Props & {
- rootRef: React.MutableRefObject<THREE.Group | null>;
- cameraRef: React.MutableRefObject<THREE.PerspectiveCamera | null>;
- onLoaded?: () => void;
+ rootRef: React.MutableRefObject<THREE.Group | null>;
+ cameraRef: React.MutableRefObject<THREE.PerspectiveCamera | null>;
+ onLoaded?: () => void;
}) {
- const { gl, scene, camera } = useThree();
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- const orbitRef = useRef<any>(null);
- const screenMatRef = useRef<THREE.MeshBasicMaterial | null>(null);
- const [modelGroup, setModelGroup] = useState<THREE.Group | null>(null);
-
- const lastLoadedUrlRef = useRef<string | null>(null);
- const lastLoadedCropKeyRef = useRef<string | null>(null);
- const screenAspectRef = useRef<number>(0.459);
- const flipYRef = useRef<boolean>(false);
-
- // 1. Configurar la API para renderizados estáticos
- useEffect(() => {
- const api: Phone3DApi = {
- renderAt: (w, h) => {
- if (!cameraRef.current) return;
- const oldAspect = cameraRef.current.aspect;
- cameraRef.current.aspect = w / h;
- cameraRef.current.updateProjectionMatrix();
- gl.setSize(w, h, false);
- gl.render(scene, cameraRef.current);
- cameraRef.current.aspect = oldAspect;
- cameraRef.current.updateProjectionMatrix();
- gl.setSize(gl.domElement.clientWidth || PHONE_W, gl.domElement.clientHeight || PHONE_H, false);
- },
- };
- onApi?.(api);
- return () => onApi?.(null);
- }, [onApi, gl, scene, cameraRef]);
-
- // 2. Lógica de Texturas
- const applyTexture = useCallback(() => {
- const mat = screenMatRef.current;
- if (!mat) return;
-
- const cropKey = cropArea ? JSON.stringify(cropArea) : null;
-
- if (!imageUrl) {
- if (mat.map) {
- mat.map.dispose();
- mat.map = null;
- mat.needsUpdate = true;
- }
- lastLoadedUrlRef.current = null;
- lastLoadedCropKeyRef.current = null;
- return;
- }
-
- // CLAVE DEL FIX: No solo validamos la caché, validamos que el material ACTUAL tenga la textura.
- if (
- lastLoadedUrlRef.current === imageUrl &&
- lastLoadedCropKeyRef.current === cropKey &&
- mat.map !== null
- ) {
- return;
- }
-
- const device = getDeviceFromModelUrl(modelUrl);
- const deviceConfig = deviceConfigs[device];
- const isDefaultPhone = device === "phone";
-
- const img = new Image();
- img.crossOrigin = "anonymous";
- img.onload = () => {
- const currentMat = screenMatRef.current;
- if (!currentMat) return;
-
- let TARGET_W = 2048;
- let TARGET_H = 0;
- let cornerRadius = 0;
-
- if (isDefaultPhone) {
- TARGET_W = PHONE_W * 4;
- TARGET_H = Math.round(TARGET_W / screenAspectRef.current);
- } else {
- TARGET_H = Math.round(TARGET_W / deviceConfig.aspectRatio);
- cornerRadius = Math.round(TARGET_W * deviceConfig.cornerRadiusFactor);
- }
-
- const cropped = applyCropToImage(img, cropArea);
- const cover = createCoverScreenCanvas(
- cropped,
- TARGET_W,
- TARGET_H,
- cornerRadius,
- imageMaskConfig
- );
-
- if (currentMat.map) {
- currentMat.map.dispose();
- currentMat.map = null;
- }
-
- const tex = new THREE.CanvasTexture(cover);
- tex.flipY = flipYRef.current;
- tex.colorSpace = THREE.SRGBColorSpace;
- tex.generateMipmaps = true;
- tex.minFilter = THREE.LinearMipmapLinearFilter;
- tex.magFilter = THREE.LinearFilter;
- tex.wrapS = THREE.ClampToEdgeWrapping;
- tex.wrapT = THREE.ClampToEdgeWrapping;
- tex.anisotropy = gl.capabilities.getMaxAnisotropy();
-
- currentMat.map = tex;
- currentMat.color.set(0xffffff); // BLANCO PURO PARA REVELAR LA TEXTURA
- currentMat.needsUpdate = true;
-
- lastLoadedUrlRef.current = imageUrl;
- lastLoadedCropKeyRef.current = cropKey;
- };
-
- img.onerror = () => {
- const currentMat = screenMatRef.current;
- if (!currentMat) return;
- if (currentMat.map) {
- currentMat.map.dispose();
- currentMat.map = null;
- }
- currentMat.color.set(0x111111);
- currentMat.needsUpdate = true;
- lastLoadedUrlRef.current = imageUrl;
- lastLoadedCropKeyRef.current = cropKey;
- };
-
- img.src = imageUrl;
- }, [imageUrl, imageMaskConfig, cropArea, modelUrl, gl]);
-
- const applyTextureRef = useRef(applyTexture);
- useEffect(() => {
- applyTextureRef.current = applyTexture;
- }, [applyTexture]);
-
- useEffect(() => {
- applyTexture();
- }, [applyTexture]);
-
- // 3. Cargar el Modelo Dinámico
- useEffect(() => {
- let isMounted = true;
- const device = getDeviceFromModelUrl(modelUrl);
- const isDefaultPhone = device === "phone";
-
- const finalizeSetup = (group: THREE.Group) => {
- if (!isMounted) return;
- setModelGroup(group);
-
- // Retrasamos unos milisegundos para asegurar que Three ha inyectado el nodo
- setTimeout(() => {
- if (!isMounted) return;
- applyTextureRef.current();
- onLoaded?.();
- }, 50);
- };
-
- if (isDefaultPhone) {
- flipYRef.current = false;
- loadGltfGroup().then((cached) => {
- const group = cloneGroup(cached);
- // Usamos zoom default aquí para montar el tamaño base. El useEffect dinámico hará el resto.
- const camZ = 1.5;
- const box = new THREE.Box3().setFromObject(group);
- const center = box.getCenter(new THREE.Vector3());
- const size = box.getSize(new THREE.Vector3());
- const halfH = camZ * Math.tan((40 / 2) * DEG);
- const sf = (halfH * 2 * 0.8) / size.y;
-
- group.scale.setScalar(sf);
- group.position.copy(center).negate().multiplyScalar(sf);
-
- group.traverse((child) => {
- if (!(child instanceof THREE.Mesh)) return;
- const mat = Array.isArray(child.material) ? child.material[0] : child.material;
- const matName = (mat as THREE.Material)?.name ?? "";
- const isScreen = matName === "Screen.editable" || child.name === "Screen";
-
- if (isScreen) {
- const meshBox = new THREE.Box3().setFromObject(child);
- const meshSize = meshBox.getSize(new THREE.Vector3());
- if (meshSize.x > 0 && meshSize.y > 0) screenAspectRef.current = meshSize.x / meshSize.y;
-
- const basicMat = new THREE.MeshBasicMaterial({
- color: 0x111111, side: THREE.FrontSide, transparent: true, depthTest: false, depthWrite: false,
- });
- child.material = basicMat;
- child.renderOrder = 10;
- screenMatRef.current = basicMat;
- } else if (mat.isMeshStandardMaterial) {
- applyMetalMaterial(mat, matName);
- }
- });
-
- finalizeSetup(group);
- });
- } else {
- flipYRef.current = true;
- loadSpecificGltf(modelUrl!).then((loadedScene) => {
- const group = loadedScene.clone(true);
- const camZ = 1.5;
- const box = new THREE.Box3().setFromObject(group);
- const center = box.getCenter(new THREE.Vector3());
- const size = box.getSize(new THREE.Vector3());
- const halfH = camZ * Math.tan((40 / 2) * DEG);
- const sf = (halfH * 2 * 0.8) / size.y;
-
- group.scale.setScalar(sf);
- group.position.copy(center).negate().multiplyScalar(sf);
-
+ const { gl, scene, camera } = useThree();
+
+ const orbitRef = useRef<OrbitControlsType | null>(null);
+ const screenMatRef = useRef<THREE.MeshBasicMaterial | null>(null);
+ const [modelGroup, setModelGroup] = useState<THREE.Group | null>(null);
+ const lastLoadedUrlRef = useRef<string | null>(null);
+ const lastLoadedCropKeyRef = useRef<string | null>(null);
+ const screenAspectRef = useRef<number>(0.459);
+ const flipYRef = useRef<boolean>(false);
+
+ const { autoRotate, rotationSpeed, glow, environment } = ViewerControls3D();
+
+ useEffect(() => {
+ const api: Phone3DApi = {
+ renderAt: (w, h) => {
+ if (!cameraRef.current) return;
+ const oldAspect = cameraRef.current.aspect;
+ cameraRef.current.aspect = w / h;
+ cameraRef.current.updateProjectionMatrix();
+ gl.setSize(w, h, false);
+ gl.render(scene, cameraRef.current);
+ cameraRef.current.aspect = oldAspect;
+ cameraRef.current.updateProjectionMatrix();
+ gl.setSize(gl.domElement.clientWidth || PHONE_W, gl.domElement.clientHeight || PHONE_H, false);
+ },
+ };
+ onApi?.(api);
+ return () => onApi?.(null);
+ }, [onApi, gl, scene, cameraRef]);
+
+ const applyTexture = useCallback(() => {
+ const mat = screenMatRef.current;
+ if (!mat) return;
+ const cropKey = cropArea ? JSON.stringify(cropArea) : null;
+ if (!imageUrl) {
+ if (mat.map) {
+ mat.map.dispose();
+ mat.map = null;
+ mat.needsUpdate = true;
+ }
+ lastLoadedUrlRef.current = null;
+ lastLoadedCropKeyRef.current = null;
+ return;
+ }
+ if (
+ lastLoadedUrlRef.current === imageUrl &&
+ lastLoadedCropKeyRef.current === cropKey &&
+ mat.map !== null
+ ) {
+ return;
+ }
+ const device = getDeviceFromModelUrl(modelUrl);
const deviceConfig = deviceConfigs[device];
- const planeH = 4.3 * deviceConfig.screenHeightFactor;
- const planeW = planeH * deviceConfig.aspectRatio;
-
- const basicMat = new THREE.MeshBasicMaterial({
- color: 0x111111, side: THREE.FrontSide, transparent: true, depthTest: false, depthWrite: false,
- });
- screenMatRef.current = basicMat;
-
- const plane = new THREE.Mesh(new THREE.PlaneGeometry(planeW, planeH), basicMat);
- plane.position.set(deviceConfig.screenOffset.x, deviceConfig.screenOffset.y, deviceConfig.screenOffset.z);
- plane.renderOrder = 10;
- group.add(plane);
-
- finalizeSetup(group);
- });
- }
-
- return () => { isMounted = false; };
- // Desactivamos exhaust-deps para que NUNCA se vuelva a ejecutar este setup al hacer zoom o cambiar onLoaded
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [modelUrl]);
-
- // 4. Actualizar posiciones de cámara dinámicas (Esto es seguro de ejecutar contínuamente)
- useEffect(() => {
- const orbit = orbitRef.current;
- if (!orbit) return;
- const radius = 1.5 / zoom;
- const phi = Math.PI / 2 - initialRotationX * DEG;
- const theta = initialRotationY * DEG;
- orbit.object.position.setFromSphericalCoords(radius, phi, theta);
- orbit.update();
- }, [initialRotationX, initialRotationY, zoom]);
-
- useEffect(() => {
- if (rootRef.current) rootRef.current.rotation.z = initialRotationZ * DEG;
- }, [initialRotationZ]);
-
- return (
- <>
- <PerspectiveCamera ref={cameraRef} makeDefault fov={40} near={0.01} far={100} position={[0, 0, 1.5 / zoom]} />
-
- <OrbitControls
- ref={orbitRef}
- enableZoom={false}
- enablePan={false}
- enableDamping
- dampingFactor={0.08}
- onEnd={() => {
- const orbit = orbitRef.current;
- if (!orbit || !onRotationChange) return;
- const ry = orbit.getAzimuthalAngle() * (180 / Math.PI);
- const rx = (Math.PI / 2 - orbit.getPolarAngle()) * (180 / Math.PI);
- onRotationChange(rx, ry);
- }}
- />
-
- <Environment preset="city" background={false} />
- <ambientLight intensity={0.3} />
- <directionalLight position={[3, 6, 5]} intensity={0.6} />
- <directionalLight position={[-4, -2, 3]} intensity={0.25} color="#c8d8ff" />
- <directionalLight position={[0, -5, 5]} intensity={0.35} />
-
- <group ref={rootRef} rotation={[0, 0, initialRotationZ * DEG]}>
- {modelGroup && <primitive object={modelGroup} />}
- </group>
- </>
- );
+ const isDefaultPhone = device === "phone";
+ const img = new Image();
+ img.crossOrigin = "anonymous";
+ img.onload = () => {
+ const currentMat = screenMatRef.current;
+ if (!currentMat) return;
+ let TARGET_W = 2048;
+ let TARGET_H = 0;
+ let cornerRadius = 0;
+ if (isDefaultPhone) {
+ TARGET_W = PHONE_W * 4;
+ TARGET_H = Math.round(TARGET_W / screenAspectRef.current);
+ } else {
+ TARGET_H = Math.round(TARGET_W / deviceConfig.aspectRatio);
+ cornerRadius = Math.round(TARGET_W * deviceConfig.cornerRadiusFactor);
+ }
+ const cropped = applyCropToImage(img, cropArea);
+ const cover = createCoverScreenCanvas(
+ cropped,
+ TARGET_W,
+ TARGET_H,
+ cornerRadius,
+ imageMaskConfig
+ );
+ if (currentMat.map) {
+ currentMat.map.dispose();
+ currentMat.map = null;
+ }
+ const tex = new THREE.CanvasTexture(cover);
+ tex.flipY = flipYRef.current;
+ tex.colorSpace = THREE.SRGBColorSpace;
+ tex.generateMipmaps = true;
+ tex.minFilter = THREE.LinearMipmapLinearFilter;
+ tex.magFilter = THREE.LinearFilter;
+ tex.wrapS = THREE.ClampToEdgeWrapping;
+ tex.wrapT = THREE.ClampToEdgeWrapping;
+ tex.anisotropy = gl.capabilities.getMaxAnisotropy();
+ currentMat.map = tex;
+ currentMat.color.set(0xffffff);
+ currentMat.needsUpdate = true;
+ lastLoadedUrlRef.current = imageUrl;
+ lastLoadedCropKeyRef.current = cropKey;
+ };
+ img.onerror = () => {
+ const currentMat = screenMatRef.current;
+ if (!currentMat) return;
+ if (currentMat.map) {
+ currentMat.map.dispose();
+ currentMat.map = null;
+ }
+ currentMat.color.set(0x111111);
+ currentMat.needsUpdate = true;
+ lastLoadedUrlRef.current = imageUrl;
+ lastLoadedCropKeyRef.current = cropKey;
+ };
+ img.src = imageUrl;
+ }, [imageUrl, imageMaskConfig, cropArea, modelUrl, gl]);
+
+ const applyTextureRef = useRef(applyTexture);
+ useEffect(() => {
+ applyTextureRef.current = applyTexture;
+ }, [applyTexture]);
+
+ useEffect(() => {
+ applyTexture();
+ }, [applyTexture]);
+
+ useEffect(() => {
+ let isMounted = true;
+ const device = getDeviceFromModelUrl(modelUrl);
+ const isDefaultPhone = device === "phone";
+ const finalizeSetup = (group: THREE.Group) => {
+ if (!isMounted) return;
+ setModelGroup(group);
+ setTimeout(() => {
+ if (!isMounted) return;
+ applyTextureRef.current();
+ onLoaded?.();
+ }, 50);
+ };
+ if (isDefaultPhone) {
+ flipYRef.current = false;
+ loadGltfGroup().then((cached) => {
+ const group = cloneGroup(cached);
+ const camZ = 1.5;
+ const box = new THREE.Box3().setFromObject(group);
+ const center = box.getCenter(new THREE.Vector3());
+ const size = box.getSize(new THREE.Vector3());
+ const halfH = camZ * Math.tan((40 / 2) * DEG);
+ const sf = (halfH * 2 * 0.8) / size.y;
+ group.scale.setScalar(sf);
+ group.position.copy(center).negate().multiplyScalar(sf);
+ group.traverse((child) => {
+ if (!(child instanceof THREE.Mesh)) return;
+ const mat = Array.isArray(child.material) ? child.material[0] : child.material;
+ const matName = (mat as THREE.Material)?.name ?? "";
+ const isScreen = matName === "Screen.editable" || child.name === "Screen";
+ if (isScreen) {
+ const meshBox = new THREE.Box3().setFromObject(child);
+ const meshSize = meshBox.getSize(new THREE.Vector3());
+ if (meshSize.x > 0 && meshSize.y > 0) screenAspectRef.current = meshSize.x / meshSize.y;
+ const basicMat = new THREE.MeshBasicMaterial({
+ color: 0x111111,
+ side: THREE.FrontSide,
+ transparent: true,
+ depthTest: false,
+ depthWrite: false,
+ });
+ child.material = basicMat;
+ child.renderOrder = 10;
+ screenMatRef.current = basicMat;
+ } else if (mat.isMeshStandardMaterial) {
+ applyMetalMaterial(mat, matName);
+ }
+ });
+ finalizeSetup(group);
+ });
+ } else {
+ flipYRef.current = true;
+ loadSpecificGltf(modelUrl!).then((loadedScene) => {
+ const group = loadedScene.clone(true);
+ const camZ = 1.5;
+ const box = new THREE.Box3().setFromObject(group);
+ const center = box.getCenter(new THREE.Vector3());
+ const size = box.getSize(new THREE.Vector3());
+ const halfH = camZ * Math.tan((40 / 2) * DEG);
+ const sf = (halfH * 2 * 0.8) / size.y;
+ group.scale.setScalar(sf);
+ group.position.copy(center).negate().multiplyScalar(sf);
+ const deviceConfig = deviceConfigs[device];
+ const planeH = 4.3 * deviceConfig.screenHeightFactor;
+ const planeW = planeH * deviceConfig.aspectRatio;
+ const basicMat = new THREE.MeshBasicMaterial({
+ color: 0x111111,
+ side: THREE.FrontSide,
+ transparent: true,
+ depthTest: false,
+ depthWrite: false,
+ });
+ screenMatRef.current = basicMat;
+ const plane = new THREE.Mesh(new THREE.PlaneGeometry(planeW, planeH), basicMat);
+ plane.position.set(deviceConfig.screenOffset.x, deviceConfig.screenOffset.y, deviceConfig.screenOffset.z);
+ plane.renderOrder = 10;
+ group.add(plane);
+ finalizeSetup(group);
+ });
+ }
+ return () => {
+ isMounted = false;
+ };
+ }, [modelUrl]);
+
+ useEffect(() => {
+ const orbit = orbitRef.current;
+ if (!orbit) return;
+ const radius = 1.5 / zoom;
+ const phi = Math.PI / 2 - initialRotationX * DEG;
+ const theta = initialRotationY * DEG;
+ orbit.object.position.setFromSphericalCoords(radius, phi, theta);
+ orbit.update();
+ }, [initialRotationX, initialRotationY, zoom]);
+
+ useEffect(() => {
+ if (rootRef.current) rootRef.current.rotation.z = initialRotationZ * DEG;
+ }, [initialRotationZ]);
+
+ return (
+ <>
+ <PerspectiveCamera ref={cameraRef} makeDefault fov={40} near={0.01} far={100} position={[0, 0, 1.5 / zoom]} />
+
+ <OrbitControls
+ ref={orbitRef}
+ enableZoom={false}
+ enablePan={false}
+ enableDamping
+ dampingFactor={0.08}
+ autoRotate={autoRotate}
+ autoRotateSpeed={rotationSpeed}
+ onEnd={() => {
+ const orbit = orbitRef.current;
+ if (!orbit || !onRotationChange) return;
+ const ry = orbit.getAzimuthalAngle() * (180 / Math.PI);
+ const rx = (Math.PI / 2 - orbit.getPolarAngle()) * (180 / Math.PI);
+ onRotationChange(rx, ry);
+ }}
+ />
+
+ <Environment
+ preset={environment as EnvironmentPreset}
+ environmentIntensity={glow}
+ background={false}
+ />
+
+ <ambientLight intensity={0.3} />
+ <directionalLight position={[3, 6, 5]} intensity={0.6} />
+ <directionalLight position={[-4, -2, 3]} intensity={0.25} color="#c8d8ff" />
+ <directionalLight position={[0, -5, 5]} intensity={0.35} />
+ <group ref={rootRef} rotation={[0, 0, initialRotationZ * DEG]}>
+ {modelGroup && <primitive object={modelGroup} />}
+ </group>
+ </>
+ );
}
-// ─── CanvasWrapper con Loader ────────────────────────────────────────────────
-function CanvasWithLoader(props: Props & {
- rootRef: React.MutableRefObject<THREE.Group | null>;
- cameraRef: React.MutableRefObject<THREE.PerspectiveCamera | null>;
-}) {
- const [loaded, setLoaded] = useState(false);
-
- // CLAVE DEL FIX: onLoaded debe ser inmutable para no envenenar los hooks de la escena
- const handleLoaded = useCallback(() => setLoaded(true), []);
-
- return (
- <>
- <Canvas
- style={{ width: "100%", height: "100%", overflow: "visible" }}
- gl={{
- antialias: true,
- alpha: true,
- preserveDrawingBuffer: true,
- powerPreference: "high-performance",
- failIfMajorPerformanceCaveat: false,
- }}
- dpr={3}
- onCreated={({ gl, scene }) => {
- gl.outputColorSpace = THREE.SRGBColorSpace;
- gl.toneMapping = THREE.NeutralToneMapping;
- gl.toneMappingExposure = 1.0;
- scene.environmentIntensity = 1.6;
- props.onMount?.(gl.domElement);
- }}
- >
- <Suspense fallback={null}>
- <ModelScene {...props} onLoaded={handleLoaded} />
- </Suspense>
- </Canvas>
-
- {!loaded && (
- <div className="absolute inset-0 flex items-center justify-center pointer-events-none" style={{ zIndex: 4 }}>
- <div className="w-6 h-6 border-2 border-white/20 border-t-white/60 rounded-full animate-spin" />
- </div>
- )}
- </>
- );
+function CanvasWithLoader(props: Props & { rootRef: React.MutableRefObject<THREE.Group | null>; cameraRef: React.MutableRefObject<THREE.PerspectiveCamera | null>; }) {
+ const [loaded, setLoaded] = useState(false);
+ const handleLoaded = useCallback(() => setLoaded(true), []);
+
+ return (
+ <>
+ <Canvas
+ style={{ width: "100%", height: "100%", overflow: "visible" }}
+ gl={{
+ antialias: true,
+ alpha: true,
+ preserveDrawingBuffer: true,
+ powerPreference: "high-performance",
+ failIfMajorPerformanceCaveat: false,
+ }}
+ dpr={3}
+ onCreated={({ gl, scene }) => {
+ gl.outputColorSpace = THREE.SRGBColorSpace;
+ gl.toneMapping = THREE.NeutralToneMapping;
+ gl.toneMappingExposure = 1.0;
+ scene.environmentIntensity = 1.6;
+ props.onMount?.(gl.domElement);
+ }}
+ >
+ <Suspense fallback={null}>
+ <ModelScene {...props} onLoaded={handleLoaded} />
+ </Suspense>
+ </Canvas>
+ {!loaded && (
+ <div className="absolute inset-0 flex items-center justify-center pointer-events-none" style={{ zIndex: 4 }}>
+ <div className="w-6 h-6 border-2 border-white/20 border-t-white/60 rounded-full animate-spin" />
+ </div>
+ )}
+ </>
+ );
}
-// ─── Componente Público Principal ───────────────────────────────────────────
export function Phone3DViewer(props: Props) {
- const {
- scale = 1,
- shadowIntensity = 0,
- shadowColor = "#000000",
- } = props;
-
- const rootRef = useRef<THREE.Group | null>(null);
- const cameraRef = useRef<THREE.PerspectiveCamera | null>(null);
- const [grabbing, setGrabbing] = useState(false);
-
- const t = Math.max(0, Math.min(1, shadowIntensity));
- const tEased = t * t;
- const computedBlur = tEased * 60;
- const computedOpacity = tEased * 0.7;
-
- const shadowRgba = shadowColor.startsWith("#")
- ? parseShadowColor(shadowColor, computedOpacity)
- : shadowColor;
-
- const hasShadow = t > 0.01;
-
- return (
- <div
- style={{
- display: "inline-block",
- transformOrigin: "top center",
- width: PHONE_W,
- height: PHONE_H + (hasShadow ? computedBlur * 0.8 : 0),
- marginTop: "220px",
- marginLeft: "140px",
- }}
- >
- <div style={{ position: "relative", width: PHONE_W, height: PHONE_H }}>
-
- {hasShadow && (
- <div
- aria-hidden
- style={{
- position: "absolute",
- bottom: -(computedBlur * 0.5),
- left: `${20 + tEased * 5}%`,
- width: `${60 - tEased * 10}%`,
- height: Math.max(4, computedBlur * 0.55),
- borderRadius: "50%",
- background: shadowRgba,
- filter: `blur(${Math.max(2, computedBlur * 0.6)}px)`,
- zIndex: 0,
- pointerEvents: "none",
- }}
- />
- )}
-
- <div
- style={{
- position: "absolute",
- inset: "-200px",
- zIndex: 2,
- overflow: "visible",
- cursor: grabbing ? "grabbing" : "grab",
- filter: hasShadow
- ? `drop-shadow(0px ${(tEased * 22).toFixed(1)}px ${(tEased * 32).toFixed(1)}px ${shadowRgba})`
- : "none",
- transition: "filter 0.15s ease",
- pointerEvents: "auto",
- }}
- onPointerDown={() => setGrabbing(true)}
- onPointerUp={() => setGrabbing(false)}
- onPointerLeave={() => setGrabbing(false)}
- >
- <CanvasWithLoader {...props} rootRef={rootRef} cameraRef={cameraRef} />
- </div>
- </div>
- </div>
- );
+ const {
+ scale = 1,
+ shadowIntensity = 0,
+ shadowColor = "#000000",
+ } = props;
+
+ const rootRef = useRef<THREE.Group | null>(null);
+ const cameraRef = useRef<THREE.PerspectiveCamera | null>(null);
+ const [grabbing, setGrabbing] = useState(false);
+
+ const t = Math.max(0, Math.min(1, shadowIntensity));
+ const tEased = t * t;
+ const computedBlur = tEased * 60;
+ const computedOpacity = tEased * 0.7;
+
+ const shadowRgba = shadowColor.startsWith("#")
+ ? parseShadowColor(shadowColor, computedOpacity)
+ : shadowColor;
+
+ const hasShadow = t > 0.01;
+
+ return (
+ <>
+ <ControlsPopup />
+
+ <div
+ style={{
+ display: "inline-block",
+ transformOrigin: "top center",
+ width: PHONE_W,
+ height: PHONE_H + (hasShadow ? computedBlur * 0.8 : 0),
+ marginTop: "220px",
+ marginLeft: "140px",
+ }}
+ >
+ <div style={{ position: "relative", width: PHONE_W, height: PHONE_H }}>
+ {hasShadow && (
+ <div
+ aria-hidden
+ style={{
+ position: "absolute",
+ bottom: -(computedBlur * 0.5),
+ left: `${20 + tEased * 5}%`,
+ width: `${60 - tEased * 10}%`,
+ height: Math.max(4, computedBlur * 0.55),
+ borderRadius: "50%",
+ background: shadowRgba,
+ filter: `blur(${Math.max(2, computedBlur * 0.6)}px)`,
+ zIndex: 0,
+ pointerEvents: "none",
+ }}
+ />
+ )}
+
+ <div
+ style={{
+ position: "absolute",
+ inset: "-200px",
+ zIndex: 2,
+ overflow: "visible",
+ cursor: grabbing ? "grabbing" : "grab",
+ filter: hasShadow
+ ? `drop-shadow(0px ${(tEased * 22).toFixed(1)}px ${(tEased * 32).toFixed(1)}px ${shadowRgba})`
+ : "none",
+ transition: "filter 0.15s ease",
+ pointerEvents: "auto",
+ }}
+ onPointerDown={() => setGrabbing(true)}
+ onPointerUp={() => setGrabbing(false)}
+ onPointerLeave={() => setGrabbing(false)}
+ >
+ <CanvasWithLoader {...props} rootRef={rootRef} cameraRef={cameraRef} />
+ </div>
+ </div>
+ </div>
+ </>
+ );
}
\ No newline at end of file
diff --git a/app/components/ui/editor/PhotoEditorPlaceholder.tsx b/app/components/ui/editor/PhotoEditorPlaceholder.tsx
index 9d897ab..4498fe5 100644
--- a/app/components/ui/editor/PhotoEditorPlaceholder.tsx
+++ b/app/components/ui/editor/PhotoEditorPlaceholder.tsx
@@ -8,7 +8,6 @@ import { Button } from "@/components/ui/button";
import { AspectRatioSelect } from "@/app/components/ui/AspectRatioSelect";
import { TooltipAction } from "@/components/ui/tooltip-action";
import { ImageMaskEditor } from "./ImageMaskEditor";
-import { NRX, NRY } from "@/lib/animation-core";
import {
Popover,
PopoverTrigger,
@@ -16,9 +15,16 @@ import {
PopoverHeader,
PopoverTitle,
} from "@/components/ui/popover";
-import { PhotoEditorPlaceholderProps, Preview3DConfig, PREVIEW_CONFIGS, PREVIEW_TO_PHONE_OFFSET } from "@/types/photo.types";
+import { PhotoEditorPlaceholderProps, Preview3DConfig, PREVIEW_CONFIGS, THREEJS_PHONE_ROTATIONS, THREEJS_LAPTOP_ROTATIONS, CSS_PHONE_PREVIEW_ROTATIONS, CSS_LAPTOP_PREVIEW_ROTATIONS } from "@/types/photo.types";
import { useMockup3dContext } from "@/app/contexts/Mockup3dContext";
+const DEFAULT_PHONE_ROTATION = { rx: -58.23, ry: -29.82 };
+const DEFAULT_LAPTOP_ROTATION = { rx: 43.23, ry: -37.82 };
+
+function getDefaultRotation(device: string) {
+ return device === "laptop" ? DEFAULT_LAPTOP_ROTATION : DEFAULT_PHONE_ROTATION;
+}
+
export function PhotoEditorPlaceholder({
className = "",
canvasImageUrl,
@@ -125,10 +131,13 @@ export function PhotoEditorPlaceholder({
onSelectPreview?.(config);
if (isCustom) setIsCustomPopoverOpen(true);
if (imagePhoneActive) {
- const offset = PREVIEW_TO_PHONE_OFFSET[config.id];
- if (offset) {
- setImagePhoneRotX(offset.rx);
- setImagePhoneRotY(offset.ry);
+ const threejsMap = imagePhoneDevice === "laptop"
+ ? THREEJS_LAPTOP_ROTATIONS
+ : THREEJS_PHONE_ROTATIONS;
+ const rotation = threejsMap[config.id];
+ if (rotation) {
+ setImagePhoneRotX(rotation.rx);
+ setImagePhoneRotY(rotation.ry);
setImagePhonePresetId(config.id);
}
}
@@ -178,13 +187,15 @@ export function PhotoEditorPlaceholder({
{imagePhoneActive ? (
imagePhoneDevice === "laptop" ? (
// ── Laptop thumbnail ──
- // Uses config.rotateX/Y directly (same Euler convention as Laptop3DViewer)
<div style={{
perspective: `${Math.round((config.perspective || 600) * 0.5)}px`,
perspectiveOrigin: 'center center',
}}>
+ {(() => {
+ const cssRot = CSS_LAPTOP_PREVIEW_ROTATIONS[config.id] ?? CSS_LAPTOP_PREVIEW_ROTATIONS["front"]!;
+ return (
<div style={{
- transform: `rotateX(${config.rotateX}deg) rotateY(${config.rotateY}deg)`,
+ transform: `rotateX(${cssRot.rx}deg) rotateY(${cssRot.ry}deg)`,
transformStyle: 'preserve-3d',
transition: 'transform 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94)',
width: 88,
@@ -192,7 +203,6 @@ export function PhotoEditorPlaceholder({
position: 'relative',
filter: 'drop-shadow(0 4px 12px rgba(0,0,0,0.7))',
}}>
- {/* Pantalla / Lid */}
<div style={{
position: 'absolute',
top: 0,
@@ -214,7 +224,6 @@ export function PhotoEditorPlaceholder({
: { background: 'rgba(0,163,255,0.10)' }
),
}} />
- {/* Camara */}
<div style={{
position: 'absolute', top: 1, left: '50%',
transform: 'translateX(-50%)',
@@ -222,7 +231,6 @@ export function PhotoEditorPlaceholder({
background: 'rgba(255,255,255,0.15)',
}} />
</div>
- {/* Base / Keyboard */}
<div style={{
position: 'absolute',
bottom: 0,
@@ -233,14 +241,12 @@ export function PhotoEditorPlaceholder({
background: 'linear-gradient(180deg, #cecfd3 0%, #b4b5bb 100%)',
border: '1px solid rgba(200,200,200,0.3)',
}}>
- {/* Keyboard texture lines */}
<div style={{
position: 'absolute',
top: '30%', left: '8%', right: '8%', height: '40%',
background: 'repeating-linear-gradient(90deg, rgba(0,0,0,0.12) 0px, rgba(0,0,0,0.12) 1px, transparent 1px, transparent 5px)',
borderRadius: '1px',
}} />
- {/* Trackpad */}
<div style={{
position: 'absolute',
bottom: '12%', left: '35%', right: '35%', height: '28%',
@@ -250,13 +256,14 @@ export function PhotoEditorPlaceholder({
}} />
</div>
</div>
+ );
+ })()}
</div>
) : (
(() => {
- // Usar el offset de Three.js para que la thumbnail coincida con el canvas
- const phoneOffset = PREVIEW_TO_PHONE_OFFSET[config.id];
- const previewRx = (phoneOffset?.rx ?? 0) + NRX; // total = NRX + userOffset
- const previewRy = (phoneOffset?.ry ?? 0) + NRY; // CSS y Three.js comparten convención (+Y = left forward)
+ const cssRot = CSS_PHONE_PREVIEW_ROTATIONS[config.id] ?? CSS_PHONE_PREVIEW_ROTATIONS["front"]!;
+ const previewRx = cssRot.rx;
+ const previewRy = cssRot.ry;
return (
<div style={{
perspective: `${Math.round((config.perspective || 600) * 0.55)}px`,
@@ -274,7 +281,6 @@ export function PhotoEditorPlaceholder({
boxShadow: '0 8px 24px rgba(0,0,0,0.6)',
position: 'relative',
}}>
- {/* Pantalla */}
<div style={{
position: 'absolute', top: 5, left: 4, right: 4, bottom: 5,
borderRadius: '5px',
@@ -285,13 +291,11 @@ export function PhotoEditorPlaceholder({
: { background: 'rgba(0,163,255,0.10)' }
),
}} />
- {/* Bocina */}
<div style={{
position: 'absolute', top: 2, left: '50%',
transform: 'translateX(-50%)',
width: 12, height: 1.5, borderRadius: '1px', background: '#000'
}} />
- {/* Detalle inferior */}
<div style={{
position: 'absolute', bottom: 2, left: '50%',
transform: 'translateX(-50%)',
@@ -475,8 +479,9 @@ export function PhotoEditorPlaceholder({
setCustomConfig(resetConfig);
if (selectedPreviewId === "custom") onSelectPreview?.(resetConfig);
if (imagePhoneActive) {
- setImagePhoneRotX(0);
- setImagePhoneRotY(0);
+ const defaults = getDefaultRotation(imagePhoneDevice);
+ setImagePhoneRotX(defaults.rx);
+ setImagePhoneRotY(defaults.ry);
setImagePhoneRotZ(0);
setImagePhonePerspective(600);
setImagePhoneScale(0.9);
@@ -550,8 +555,9 @@ export function PhotoEditorPlaceholder({
};
setCustomConfig(defaultCustom);
if (imagePhoneActive) {
- setImagePhoneRotX(0);
- setImagePhoneRotY(0);
+ const defaults = getDefaultRotation(imagePhoneDevice);
+ setImagePhoneRotX(defaults.rx);
+ setImagePhoneRotY(defaults.ry);
setImagePhoneRotZ(0);
setImagePhonePerspective(600);
setImagePhoneScale(0.9);
diff --git a/app/components/ui/editor/Timeline.tsx b/app/components/ui/editor/Timeline.tsx
index 0844aaf..b8fa5ab 100644
--- a/app/components/ui/editor/Timeline.tsx
+++ b/app/components/ui/editor/Timeline.tsx
@@ -394,7 +394,7 @@ export function Timeline({
<div className="flex-1 flex flex-col" onClick={handleTrackClick}>
{/* Video track */}
- <div className="flex-1 flex items-center py-1.5 relative">
+ <div className="flex-1 flex items-center py-0.5 relative">
<div
className="h-full rounded-md flex items-center relative bg-[#0a1510] border border-white/5"
style={{ width: contentWidth > 0 ? contentWidth : '100%' }}
diff --git a/app/components/ui/editor/VideoCanvas.tsx b/app/components/ui/editor/VideoCanvas.tsx
index 24d624d..36f0886 100644
--- a/app/components/ui/editor/VideoCanvas.tsx
+++ b/app/components/ui/editor/VideoCanvas.tsx
@@ -1725,7 +1725,7 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(funct
<div className="flex items-stretch min-h-0 min-w-0 w-full h-full justify-center gap-0">
{/* Preview visual - contenedor con tamaño dinámico según aspect ratio */}
- <div ref={canvasWrapperRef} className="flex-1 flex items-center justify-center min-h-0 min-w-0 mx-4">
+ <div ref={canvasWrapperRef} className="flex-1 flex items-center justify-center min-h-0 min-w-0 mr-1">
<div
ref={previewContainerRef}
className={`relative shrink-0 transition-all duration-300 overflow-hidden ${mediaType === "image" && imageUrl
diff --git a/app/components/ui/editor/ZoomFragmentTrackItem.tsx b/app/components/ui/editor/ZoomFragmentTrackItem.tsx
index 7f90c4a..7e0a010 100644
--- a/app/components/ui/editor/ZoomFragmentTrackItem.tsx
+++ b/app/components/ui/editor/ZoomFragmentTrackItem.tsx
@@ -177,7 +177,7 @@ export function ZoomFragmentTrackItem({
return (
<motion.div
ref={containerRef}
- className={`absolute h-[80%] top-[10%] rounded-md flex items-center border transition-shadow select-none ${isSelected || isInteracting
+ className={`absolute h-[80%] top-[5%] rounded-md flex items-center border transition-shadow select-none ${isSelected || isInteracting
? 'bg-blue-500/30 border-blue-400/70 shadow-[0_0_10px_rgba(59,130,246,0.3)] z-10'
: 'bg-blue-600/20 border-blue-500/35 hover:border-blue-500/60'
} ${isDragging ? 'cursor-grabbing' : 'cursor-grab'}`}
diff --git a/app/components/ui/home/Featuresgrid.tsx b/app/components/ui/home/Featuresgrid.tsx
new file mode 100644
index 0000000..216804f
--- /dev/null
+++ b/app/components/ui/home/Featuresgrid.tsx
@@ -0,0 +1,467 @@
+"use client";
+
+export default function FeaturesGrid() {
+ return (
+ <section
+ className="w-full py-16 sm:py-24"
+ aria-label="Product features"
+ >
+ <div className="max-w-6xl mx-auto px-6 xl:px-0">
+ {/* Header */}
+ <div className="max-w-2xl mb-12 sm:mb-16">
+ <span className="inline-flex items-center gap-2 text-xs font-medium tracking-widest text-[#0EA5E9] uppercase mb-4">
+ <span className="w-4 h-px bg-[#0EA5E9]" aria-hidden="true" />
+ Capabilities
+ </span>
+ <h2 className="text-3xl sm:text-5xl font-bold tracking-tighter text-white leading-tight mb-4">
+ Everything you need to ship stunning demos
+ </h2>
+ <p className="text-base sm:text-lg text-neutral-400 font-light leading-relaxed">
+ Record, enhance, and export — cinematic results directly in your browser, no installs required.
+ </p>
+ </div>
+
+ {/* Bento Grid */}
+ <div
+ className="grid gap-3"
+ style={{
+ gridTemplateColumns: "repeat(12, 1fr)",
+ gridAutoRows: "56px",
+ }}
+ >
+ {/* ── LARGE: 3D Mockups (7 cols × 7 rows) ── */}
+ <div
+ className="rounded-2xl overflow-hidden relative bg-[#0D1117] border border-white/[0.06]"
+ style={{ gridColumn: "span 7", gridRow: "span 7" }}
+ >
+ {/* Replace this div with your actual screenshot/image */}
+ <div className="absolute inset-0 flex items-center justify-center flex-col gap-4 px-8">
+ <div className="text-[10px] text-neutral-700 font-mono tracking-wider">
+ [ REPLACE WITH YOUR IMAGE ]
+ </div>
+ <div className="flex gap-4 items-end">
+ <div
+ className="w-14 h-24 rounded-2xl border border-white/10 flex items-center justify-center"
+ style={{
+ background: "rgba(255,255,255,0.03)",
+ transform: "perspective(400px) rotateY(-12deg) rotateX(4deg)",
+ }}
+ >
+ <div className="w-9 h-16 rounded-xl border border-[#0EA5E9]/20 bg-[#0EA5E9]/5" />
+ </div>
+ <div
+ className="w-24 h-14 rounded-xl border border-white/[0.07] flex items-center justify-center"
+ style={{
+ background: "rgba(255,255,255,0.02)",
+ transform: "perspective(400px) rotateY(-8deg) rotateX(-3deg)",
+ }}
+ >
+ <div className="w-18 h-10 rounded-lg border border-[#0EA5E9]/15 bg-[#0EA5E9]/4" />
+ </div>
+ </div>
+ <div className="flex gap-2">
+ {["Safari", "Chrome", "Arc", "iPhone", "Samsung"].map((d, i) => (
+ <div
+ key={d}
+ className="text-[9px] font-medium px-2 py-1 rounded"
+ style={{
+ background: i === 0 ? "rgba(14,165,233,0.09)" : "rgba(255,255,255,0.03)",
+ border: i === 0 ? "1px solid rgba(14,165,233,0.22)" : "1px solid rgba(255,255,255,0.06)",
+ color: i === 0 ? "#38bdf8" : "#4b5563",
+ }}
+ >
+ {d}
+ </div>
+ ))}
+ </div>
+ </div>
+ {/* Gradient label overlay */}
+ <div
+ className="absolute bottom-0 left-0 right-0 p-5 pt-16"
+ style={{ background: "linear-gradient(to top, #0D1117 60%, transparent)" }}
+ >
+ <div className="text-[9px] font-semibold tracking-widest text-[#0EA5E9] uppercase mb-1.5">
+ Device frames
+ </div>
+ <div className="text-lg font-semibold text-white leading-tight">
+ 3D mockups in one click
+ </div>
+ <div className="text-sm text-neutral-500 mt-1">
+ Safari, Chrome, Arc, iPhone, Samsung — 3D transforms, perspective & masking
+ </div>
+ </div>
+ </div>
+
+ {/* ── Screen Recording (5 cols × 4 rows) ── */}
+ <div
+ className="rounded-2xl overflow-hidden relative bg-[#0D1117] border border-white/[0.06]"
+ style={{ gridColumn: "span 5", gridRow: "span 4" }}
+ >
+ <div className="absolute inset-0 p-4 pb-0 flex flex-col">
+ {/* Fake browser chrome */}
+ <div
+ className="rounded-lg px-3 py-2 flex items-center gap-2 mb-2 shrink-0"
+ style={{ background: "#161B22", border: "1px solid rgba(255,255,255,0.06)" }}
+ >
+ <div className="flex gap-1.5">
+ <div className="w-2 h-2 rounded-full bg-red-500/50" />
+ <div className="w-2 h-2 rounded-full bg-yellow-500/40" />
+ <div className="w-2 h-2 rounded-full bg-green-500/40" />
+ </div>
+ <div
+ className="flex-1 rounded text-[9px] text-neutral-600 px-2 py-0.5 font-mono"
+ style={{ background: "#0D1117" }}
+ >
+ openvid.dev/editor
+ </div>
+ <div className="flex items-center gap-1.5">
+ <div className="w-1.5 h-1.5 rounded-full bg-red-500 animate-pulse" />
+ <span className="text-[9px] text-red-400 font-mono">00:24</span>
+ </div>
+ </div>
+ {/* Fake content */}
+ <div
+ className="flex-1 rounded-lg p-3"
+ style={{ background: "#161B22", border: "1px solid rgba(255,255,255,0.04)" }}
+ >
+ <div className="space-y-1.5">
+ <div className="h-1.5 w-3/5 rounded-full bg-[#0EA5E9]/20" />
+ <div className="h-1.5 w-4/5 rounded-full bg-white/[0.06]" />
+ <div className="h-1.5 w-2/5 rounded-full bg-white/[0.06]" />
+ <div className="h-1.5 w-3/4 rounded-full bg-white/[0.04]" />
+ </div>
+ </div>
+ </div>
+ <div
+ className="absolute bottom-0 left-0 right-0 p-4 pt-12"
+ style={{ background: "linear-gradient(to top, #0D1117 65%, transparent)" }}
+ >
+ <div className="text-[9px] font-semibold tracking-widest text-[#0EA5E9] uppercase mb-1">
+ Capture
+ </div>
+ <div className="text-base font-semibold text-white">Record your screen</div>
+ <div className="text-xs text-neutral-500 mt-0.5">
+ Browser-native. Tab, window or fullscreen.
+ </div>
+ </div>
+ </div>
+
+ {/* ── Zoom & 3D Camera (5 cols × 3 rows) ── */}
+ <div
+ className="rounded-2xl overflow-hidden relative bg-[#0D1117] border border-white/[0.06]"
+ style={{ gridColumn: "span 5", gridRow: "span 3" }}
+ >
+ <div className="absolute inset-0 p-4 pb-10">
+ <div className="text-[9px] text-neutral-700 uppercase tracking-widest mb-2">Timeline</div>
+ {/* Track */}
+ <div className="relative h-1.5 rounded-full bg-white/[0.04] mb-2">
+ <div
+ className="absolute left-0 top-0 h-full rounded-full"
+ style={{ width: "38%", background: "rgba(14,165,233,0.2)" }}
+ />
+ <div
+ className="absolute top-1/2 -translate-y-1/2 w-3 h-3 rounded-full border-2 border-[#0EA5E9] bg-[#0D1117]"
+ style={{ left: "34%" }}
+ />
+ <div
+ className="absolute top-1/2 -translate-y-1/2 w-3 h-3 rounded-full border-2 border-[#0EA5E9] bg-[#0D1117]"
+ style={{ left: "64%" }}
+ />
+ </div>
+ <div className="flex gap-2 mt-3">
+ {[
+ { label: "2× zoom", color: "rgba(14,165,233,0.09)", border: "rgba(14,165,233,0.22)", text: "#38bdf8" },
+ { label: "3D tilt X/Y", color: "rgba(139,92,246,0.09)", border: "rgba(139,92,246,0.22)", text: "#a78bfa" },
+ { label: "ease-in-out", color: "rgba(14,165,233,0.09)", border: "rgba(14,165,233,0.22)", text: "#38bdf8" },
+ ].map((b) => (
+ <div
+ key={b.label}
+ className="text-[9px] font-medium px-2.5 py-1 rounded-full"
+ style={{ background: b.color, border: `1px solid ${b.border}`, color: b.text }}
+ >
+ {b.label}
+ </div>
+ ))}
+ </div>
+ </div>
+ <div
+ className="absolute bottom-0 left-0 right-0 p-4"
+ style={{ background: "linear-gradient(to top, #0D1117 80%, transparent)" }}
+ >
+ <div className="text-sm font-semibold text-white">Cinematic zoom & 3D camera</div>
+ </div>
+ </div>
+
+ {/* ── Backgrounds (4 cols × 5 rows) ── */}
+ <div
+ className="rounded-2xl overflow-hidden relative bg-[#0D1117] border border-white/[0.06]"
+ style={{ gridColumn: "span 4", gridRow: "span 5" }}
+ >
+ <div className="absolute inset-0 p-4 pb-14">
+ <div
+ className="grid gap-1.5 mb-3"
+ style={{ gridTemplateColumns: "repeat(4, 1fr)" }}
+ >
+ {[
+ { bg: "#1a1a2e", active: true },
+ { bg: "#0f3460" },
+ { bg: "linear-gradient(135deg,#667eea,#764ba2)" },
+ { bg: "linear-gradient(135deg,#f093fb,#f5576c)" },
+ { bg: "linear-gradient(135deg,#4facfe,#00f2fe)" },
+ { bg: "linear-gradient(135deg,#43e97b,#38f9d7)" },
+ { bg: "#292524" },
+ { bg: "#44403c" },
+ { bg: "linear-gradient(135deg,#fd746c,#ff9068)" },
+ { bg: "linear-gradient(135deg,#a18cd1,#fbc2eb)" },
+ { bg: "#161B22" },
+ { bg: "rgba(255,255,255,0.04)", dashed: true },
+ ].map((s, i) => (
+ <div
+ key={i}
+ className="rounded-md"
+ style={{
+ aspectRatio: "1",
+ background: s.bg,
+ border: s.active
+ ? "2px solid #0EA5E9"
+ : s.dashed
+ ? "1px dashed rgba(255,255,255,0.12)"
+ : "1px solid rgba(255,255,255,0.06)",
+ }}
+ />
+ ))}
+ </div>
+ <div className="text-[9px] text-neutral-700 uppercase tracking-widest">
+ 100+ backgrounds
+ </div>
+ </div>
+ <div
+ className="absolute bottom-0 left-0 right-0 p-4"
+ style={{ background: "linear-gradient(to top, #0D1117 70%, transparent)" }}
+ >
+ <div className="text-sm font-semibold text-white">Backgrounds</div>
+ <div className="text-xs text-neutral-500 mt-0.5">Solid, gradient, Unsplash, or your own</div>
+ </div>
+ </div>
+
+ {/* ── Export (4 cols × 5 rows) ── */}
+ <div
+ className="rounded-2xl overflow-hidden relative bg-[#0D1117] border border-white/[0.06]"
+ style={{ gridColumn: "span 4", gridRow: "span 5" }}
+ >
+ <div className="absolute inset-0 p-4 pb-14">
+ {[
+ { label: "4K", sub: "3840 × 2160", active: false },
+ { label: "2K", sub: "2560 × 1440", active: true },
+ { label: "1080p", sub: "1920 × 1080", active: false },
+ ].map((q) => (
+ <div
+ key={q.label}
+ className="flex items-center justify-between rounded-lg px-3 py-2 mb-1.5"
+ style={{
+ background: q.active ? "rgba(14,165,233,0.08)" : "rgba(255,255,255,0.02)",
+ border: q.active
+ ? "1px solid rgba(14,165,233,0.25)"
+ : "1px solid rgba(255,255,255,0.04)",
+ }}
+ >
+ <span
+ className="text-xs font-semibold"
+ style={{ color: q.active ? "#0EA5E9" : "#4b5563" }}
+ >
+ {q.label}
+ </span>
+ <span
+ className="text-[9px] font-mono"
+ style={{ color: q.active ? "#38bdf8" : "#374151" }}
+ >
+ {q.sub}
+ </span>
+ </div>
+ ))}
+ <div className="flex gap-1.5 flex-wrap mt-3">
+ {["MP4", "WebM", "GIF", "PNG", "AVIF"].map((f) => (
+ <div
+ key={f}
+ className="text-[9px] font-medium px-2 py-1 rounded"
+ style={{
+ background: "rgba(255,255,255,0.03)",
+ border: "1px solid rgba(255,255,255,0.06)",
+ color: "#4b5563",
+ }}
+ >
+ {f}
+ </div>
+ ))}
+ </div>
+ </div>
+ <div
+ className="absolute bottom-0 left-0 right-0 p-4"
+ style={{ background: "linear-gradient(to top, #0D1117 70%, transparent)" }}
+ >
+ <div className="text-sm font-semibold text-white">4K export</div>
+ <div className="text-xs text-neutral-500 mt-0.5">
+ MP4, WebM, GIF, PNG, AVIF — up to 4K 30fps
+ </div>
+ </div>
+ </div>
+
+ {/* ── Layers (4 cols × 5 rows) ── */}
+ <div
+ className="rounded-2xl overflow-hidden relative bg-[#0D1117] border border-white/[0.06]"
+ style={{ gridColumn: "span 4", gridRow: "span 5" }}
+ >
+ <div className="absolute inset-0 p-4 pb-14">
+ <div className="text-[9px] text-neutral-700 uppercase tracking-widest mb-2">Layers</div>
+ {[
+ { name: "Video", active: false },
+ { name: "Text overlay", active: true },
+ { name: "Shape", active: false },
+ { name: "SVG import", active: false },
+ ].map((layer) => (
+ <div
+ key={layer.name}
+ className="flex items-center gap-2 rounded-md px-2.5 py-1.5 mb-1"
+ style={{
+ background: layer.active ? "rgba(14,165,233,0.09)" : "rgba(255,255,255,0.02)",
+ border: layer.active
+ ? "1px solid rgba(14,165,233,0.2)"
+ : "1px solid rgba(255,255,255,0.04)",
+ }}
+ >
+ <div
+ className="w-1.5 h-1.5 rounded-full shrink-0"
+ style={{ background: layer.active ? "#0EA5E9" : "#374151" }}
+ />
+ <span
+ className="text-[10px] font-medium"
+ style={{ color: layer.active ? "#0EA5E9" : "#4b5563" }}
+ >
+ {layer.name}
+ </span>
+ </div>
+ ))}
+ </div>
+ <div
+ className="absolute bottom-0 left-0 right-0 p-4"
+ style={{ background: "linear-gradient(to top, #0D1117 70%, transparent)" }}
+ >
+ <div className="text-sm font-semibold text-white">Layers & canvas</div>
+ <div className="text-xs text-neutral-500 mt-0.5">
+ Shapes, text, SVG, images — above or below video
+ </div>
+ </div>
+ </div>
+
+ {/* ── Audio (3 cols × 3 rows) ── */}
+ <div
+ className="rounded-2xl overflow-hidden relative bg-[#0D1117] border border-white/[0.06]"
+ style={{ gridColumn: "span 3", gridRow: "span 3" }}
+ >
+ <div className="absolute inset-0 flex flex-col items-center justify-center gap-2 pb-8 px-3">
+ <div className="flex items-end gap-0.5 h-8">
+ {[4, 9, 14, 8, 20, 14, 6, 18, 11, 7, 4, 12, 8, 5, 3, 10, 7, 14, 8, 5].map(
+ (h, i) => (
+ <div
+ key={i}
+ className="w-1 rounded-sm"
+ style={{
+ height: h,
+ background: i % 3 === 0 ? "#0EA5E9" : "rgba(255,255,255,0.1)",
+ }}
+ />
+ )
+ )}
+ </div>
+ <div className="text-[8px] text-neutral-700">multi-track</div>
+ </div>
+ <div className="absolute bottom-3 left-4">
+ <div className="text-xs font-semibold text-white">Audio</div>
+ </div>
+ </div>
+
+ {/* ── Free / No watermark (3 cols × 3 rows) ── */}
+ <div
+ className="rounded-2xl overflow-hidden relative bg-[#0D1117] border border-white/[0.06]"
+ style={{ gridColumn: "span 3", gridRow: "span 3" }}
+ >
+ <div className="absolute inset-0 flex flex-col items-center justify-center gap-1 pb-8">
+ <span
+ className="text-3xl font-extrabold"
+ style={{
+ background: "linear-gradient(135deg, #0EA5E9, #38bdf8)",
+ WebkitBackgroundClip: "text",
+ WebkitTextFillColor: "transparent",
+ }}
+ >
+ Free
+ </span>
+ <div className="text-[8px] text-neutral-700">no watermark</div>
+ </div>
+ <div className="absolute bottom-3 left-4">
+ <div className="text-xs font-semibold text-white">Always free</div>
+ </div>
+ </div>
+
+ {/* ── Elements / Shapes (3 cols × 3 rows) ── */}
+ <div
+ className="rounded-2xl overflow-hidden relative bg-[#0D1117] border border-white/[0.06]"
+ style={{ gridColumn: "span 3", gridRow: "span 3" }}
+ >
+ <div className="absolute inset-0 flex flex-col items-center justify-center gap-2 pb-8">
+ <div className="flex gap-2 items-center">
+ <div
+ className="w-5 h-5 rounded-sm"
+ style={{
+ background: "rgba(14,165,233,0.2)",
+ border: "1px solid rgba(14,165,233,0.35)",
+ }}
+ />
+ <div
+ className="w-5 h-5 rounded-full"
+ style={{
+ background: "rgba(139,92,246,0.2)",
+ border: "1px solid rgba(139,92,246,0.35)",
+ }}
+ />
+ <div
+ className="w-5 h-5"
+ style={{
+ background: "rgba(249,115,22,0.2)",
+ clipPath: "polygon(50% 0%,100% 100%,0% 100%)",
+ }}
+ />
+ </div>
+ <div className="text-[8px] text-neutral-700">shapes · text · SVG</div>
+ </div>
+ <div className="absolute bottom-3 left-4">
+ <div className="text-xs font-semibold text-white">Elements</div>
+ </div>
+ </div>
+
+ {/* ── Upload video (3 cols × 3 rows) ── */}
+ <div
+ className="rounded-2xl overflow-hidden relative bg-[#0D1117] border border-white/[0.06]"
+ style={{ gridColumn: "span 3", gridRow: "span 3" }}
+ >
+ <div className="absolute inset-0 flex flex-col items-center justify-center gap-1.5 pb-8">
+ <div
+ className="w-8 h-8 rounded-lg flex items-center justify-center"
+ style={{
+ background: "rgba(14,165,233,0.07)",
+ border: "1px dashed rgba(14,165,233,0.28)",
+ }}
+ >
+ <span className="text-lg text-[#0EA5E9]">↑</span>
+ </div>
+ <div className="text-[8px] text-neutral-700">MP4 · WebM · MOV</div>
+ </div>
+ <div className="absolute bottom-3 left-4">
+ <div className="text-xs font-semibold text-white">Upload video</div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </section>
+ );
+}
\ No newline at end of file
diff --git a/components/ui/ControlsPopup.tsx b/components/ui/ControlsPopup.tsx
new file mode 100644
index 0000000..66c1cca
--- /dev/null
+++ b/components/ui/ControlsPopup.tsx
@@ -0,0 +1,34 @@
+"use client";
+
+import { useEffect, useState } from "react";
+import { createPortal } from "react-dom";
+import { Leva } from "leva";
+
+export function ControlsPopup() {
+ const [mounted, setMounted] = useState(false);
+
+ useEffect(() => {
+ const timeoutId = setTimeout(() => {
+ setMounted(true);
+ }, 0);
+ return () => clearTimeout(timeoutId);
+ }, []);
+
+ if (!mounted) return null;
+
+ return createPortal(
+ <div
+ style={{
+ position: "fixed",
+ bottom: "240px",
+ right: "325px",
+ width: "320px",
+ zIndex: 99999,
+ }}
+ onPointerDown={(e) => e.stopPropagation()}
+ >
+ <Leva fill flat />
+ </div>,
+ document.body
+ );
+}
\ No newline at end of file
diff --git a/lib/animation-core.ts b/lib/animation-core.ts
deleted file mode 100644
index 58c5cfe..0000000
--- a/lib/animation-core.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-// ─── Local types (motion.types.ts fue eliminado al consolidar MockupMenu) ─────
-type MotionStyle = "smooth" | "normal" | "cinematic";
-type ScriptFn = (
- av: { rx: number; ry: number; tx: number; ty: number; sc: number },
- intensity: number,
- duration: number,
- style: MotionStyle,
- onUpdate?: () => void
-) => gsap.core.Timeline;
-
-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 file
diff --git a/lib/viewer-controls3d.ts b/lib/viewer-controls3d.ts
new file mode 100644
index 0000000..3e53b81
--- /dev/null
+++ b/lib/viewer-controls3d.ts
@@ -0,0 +1,29 @@
+import { useControls } from "leva";
+import { useEffect } from "react";
+
+export type EnvironmentPreset = "sunset" | "dawn" | "night" | "warehouse" | "forest" | "apartment" | "studio" | "city" | "park" | "lobby";
+
+interface ViewerControlsOptions {
+ defaultEnvironment?: EnvironmentPreset;
+}
+
+export function ViewerControls3D({ defaultEnvironment = "studio" }: ViewerControlsOptions = {}) {
+ const [controls, set] = useControls("Configuration 3D", () => ({
+ autoRotate: false,
+ glow: { value: 1.0, min: 0.0, max: 5.0, step: 0.1 },
+
+ rotationSpeed: { value: 3.5, min: 0.1, max: 10, step: 0.1 },
+ environment: {
+ options: ['sunset', 'dawn', 'night', 'warehouse', 'forest', 'apartment', 'studio', 'city', 'park', 'lobby'],
+ value: defaultEnvironment
+ }
+ }));
+
+ useEffect(() => {
+ set({
+ environment: defaultEnvironment
+ });
+ }, [defaultEnvironment, set]);
+
+ return controls;
+}
\ No newline at end of file
diff --git a/types/mockup.types.ts b/types/mockup.types.ts
index 6d2a887..04e7595 100644
--- a/types/mockup.types.ts
+++ b/types/mockup.types.ts
@@ -96,40 +96,40 @@ export type MenuPage = "home" | "detail-2d" | "detail-3d";
// ─── 3D Device definitions ────────────────────────────────────────────────────
export const IMAGE_DEVICE_TEMPLATES = [
- {
- id: "iphone-13-pro-max",
- title: "iPhone 13 Pro",
- accentColor: "#7C7C85",
- icon: "simple-icons:apple",
- modelUrl: "/models/apple_iphone_13_pro_max.glb",
- },
- {
- id: "phone",
- title: "Phone",
- accentColor: "#00A3FF",
- icon: "ph:device-mobile-bold",
- modelUrl: "/models/phone-gltf.glb",
- },
- {
- id: "iphone",
- title: "iPhone 15 Pro",
- accentColor: "#A8A8B0",
- icon: "simple-icons:apple",
- modelUrl: "/models/iphone-15-pro-max.glb",
- },
- {
- id: "samsung",
- title: "Samsung S25",
- accentColor: "#1428A0",
- icon: "simple-icons:samsung",
- modelUrl: "/models/samsung-galaxy-s25-ultra.glb",
- },
- {
- id: "laptop",
- title: "macOS Laptop",
- accentColor: "#CECFD3",
- icon: "ph:laptop-bold",
- modelUrl: "/models/mac-book.glb",
- },
+ {
+ id: "iphone-13-pro-max",
+ title: "iPhone 13 Pro",
+ accentColor: "#7C7C85",
+ icon: "simple-icons:apple",
+ modelUrl: "/models/apple_iphone_13_pro_max.glb",
+ },
+ {
+ id: "iphone",
+ title: "iPhone 15 Pro",
+ accentColor: "#A8A8B0",
+ icon: "simple-icons:apple",
+ modelUrl: "/models/iphone-15-pro-max.glb",
+ },
+ {
+ id: "samsung",
+ title: "Samsung S25",
+ accentColor: "#1428A0",
+ icon: "simple-icons:samsung",
+ modelUrl: "/models/samsung-galaxy-s25-ultra.glb",
+ },
+ {
+ id: "phone",
+ title: "Phone",
+ accentColor: "#00A3FF",
+ icon: "ph:device-mobile-bold",
+ modelUrl: "/models/phone-gltf.glb",
+ },
+ {
+ id: "laptop",
+ title: "macOS Laptop",
+ accentColor: "#CECFD3",
+ icon: "ph:laptop-bold",
+ modelUrl: "/models/mac-book.glb",
+ },
] as const;
diff --git a/types/motion.types.ts b/types/motion.types.ts
deleted file mode 100644
index 78c6519..0000000
--- a/types/motion.types.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-/** Animation vector — GSAP tweens this object, Three.js reads it */
-export interface AV {
- rx: number;
- ry: number;
- tx: number;
- ty: number;
- sc: number;
-}
-
-// ─── Tipos restaurados (motion.types.ts fue modificado pero aún los usa CameraVariant) ─────
-export type MotionStyle = "smooth" | "normal" | "cinematic";
-export type AnimMode = "entry" | "exit" | "entry+exit" | "none" | "static";
-
-/** A cinematic script function — returns a repeating GSAP timeline */
-export type ScriptFn = (
- av: AV,
- intensity: number, // 0–1
- durMs: number,
- onUpdate: () => void,
-) => gsap.core.Timeline;
-
-/** What each template declares about itself */
-export interface MotionTemplate {
- id: string;
- title: string;
- description: string;
- accentColor: string;
- icon: string;
- tags: string[];
- defaultDuration: number; // ms
- /** If false, shows plain video with no phone overlay */
- showPhone: boolean;
- /** The cinematic script — only defined on templates that have one */
- script?: ScriptFn;
- /** Template-specific editor panel component (lazy-imported by the menu) */
- EditorPanel?: React.ComponentType<EditorPanelProps>;
-}
-
-/** Props every EditorPanel receives */
-export interface EditorPanelProps {
- template: MotionTemplate;
-}
-
-export interface CameraVariant {
- id: string;
- label: string;
- description: string;
- icon: string;
- /** Suggested default animMode for this variant */
- defaultAnimMode: AnimMode;
- /** Duration in ms for the entry animation */
- entryDuration: number;
- /** Duration in ms for the exit animation */
- exitDuration: number;
- /** Entry: dramatic pose → REST (NRX/NRY). Must end at REST. */
- entryScript: ScriptFn;
- /** Exit: REST (NRX/NRY) → dramatic pose. */
- exitScript: ScriptFn;
- /** Kept for backwards compat with one-shot preview */
- script: ScriptFn;
-}
\ No newline at end of file
diff --git a/types/photo.types.ts b/types/photo.types.ts
index 47aa8fa..c0fe7a0 100644
--- a/types/photo.types.ts
+++ b/types/photo.types.ts
@@ -27,6 +27,51 @@ export const PREVIEW_TO_PHONE_OFFSET: Record<string, PhoneRotationOffset> = {
"tilt-down": { rx: -15, ry: 0 },
};
+export const CSS_PHONE_PREVIEW_ROTATIONS: Record<string, PhoneRotationOffset> = {
+ "front": { rx: -30, ry: 22 },
+ "top-left-angle": { rx: -45, ry: 40 },
+ "top-right-angle": { rx: -45, ry: -15 },
+ "bottom-left-angle": { rx: -10, ry: 40 },
+ "bottom-right-angle": { rx: -10, ry: -15 },
+ "isometric": { rx: -55, ry: -40 },
+ "tilt-up": { rx: -40, ry: 22 },
+ "tilt-down": { rx: -8, ry: 22 },
+};
+
+export const CSS_LAPTOP_PREVIEW_ROTATIONS: Record<string, PhoneRotationOffset> = {
+ "front": { rx: 30, ry: -30 },
+ "top-left-angle": { rx: 50, ry: -45 },
+ "top-right-angle": { rx: 50, ry: 10 },
+ "bottom-left-angle": { rx: 15, ry: -45 },
+ "bottom-right-angle": { rx: 15, ry: 10 },
+ "isometric": { rx: 60, ry: -55 },
+ "tilt-up": { rx: 50, ry: -30 },
+ "tilt-down": { rx: 15, ry: -30 },
+};
+
+export const THREEJS_PHONE_ROTATIONS: Record<string, PhoneRotationOffset> = {
+ "front": { rx: -58.23, ry: -29.82 },
+ "top-left-angle": { rx: -72, ry: -55 },
+ "top-right-angle": { rx: -72, ry: -5 },
+ "bottom-left-angle": { rx: -42, ry: -55 },
+ "bottom-right-angle": { rx: -42, ry: -5 },
+ "isometric": { rx: -80, ry: -70 },
+ "tilt-up": { rx: -75, ry: -29.82 },
+ "tilt-down": { rx: -38, ry: -29.82 },
+};
+
+/** Three.js absolute rotation values for the laptop viewer. */
+export const THREEJS_LAPTOP_ROTATIONS: Record<string, PhoneRotationOffset> = {
+ "front": { rx: 43.23, ry: -37.82 },
+ "top-left-angle": { rx: 55, ry: -60 },
+ "top-right-angle": { rx: 55, ry: -15 },
+ "bottom-left-angle": { rx: 30, ry: -60 },
+ "bottom-right-angle": { rx: 30, ry: -15 },
+ "isometric": { rx: 65, ry: -75 },
+ "tilt-up": { rx: 60, ry: -37.82 },
+ "tilt-down": { rx: 25, ry: -37.82 },
+};
+
export const PREVIEW_CONFIGS: readonly Preview3DConfig[] = Object.freeze([
Object.freeze({ id: "front", label: "Front", rotateX: 0, rotateY: 0, rotateZ: 0, translateY: 0, scale: 0.9, perspective: 600 }),
Object.freeze({ id: "top-left-angle", label: "Top Left Angle", rotateX: 18, rotateY: 25, rotateZ: -15, translateY: -10, scale: 0.95, perspective: 500 }),