Skip to content

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

feat: enhance 3D viewer components with shadow support and improve layout in home page

CristianOlivera1f1a892ff9ae6
diff --git a/app/[locale]/(home)/page.tsx b/app/[locale]/(home)/page.tsx
index d0ba3d0..e15a230 100644
--- a/app/[locale]/(home)/page.tsx
+++ b/app/[locale]/(home)/page.tsx
@@ -7,6 +7,7 @@ import DonationCard from "@/app/components/ui/home/DonationCard";
import EditorPreview from "@/app/components/ui/home/EditorPreview";
import VideoHero from "@/app/components/ui/home/VideoHero";
import BannerCTA from "@/app/components/ui/home/BannerCTA";
+import FeaturesGrid from "@/app/components/ui/home/Featuresgrid";
type Props = {
params: Promise<{ locale: string }>;
@@ -85,16 +86,17 @@ export default async function Home({ params }: Props) {
</div>
<section className="w-full py-10 sm:py-16" aria-label="How it works">
- <div className="max-w-6xl mx-auto px-6 xl:px-0">
+ <div className="max-w-7xl mx-auto px-6 xl:px-0">
<InteractiveRecordingSteps />
</div>
</section>
- <div className="relative overflow-hidden bg-gradient-radial-primary w-full sm:pt-24">
+ <div className="relative overflow-hidden bg-gradient-radial-primary w-full">
<div className="absolute top-0 left-1/2 -translate-x-1/2 w-250 h-[150%] rounded-[100%] blur-xl pointer-events-none" aria-hidden="true"></div>
<section className="w-full" aria-label="Editor features and demos">
- <div className="w-full mx-auto bg-[url('/images/pages/dots.svg')] bg-no-repeat bg-[size:68%] bg-center">
- <EditorPreview />
+ <div className="w-full mx-auto">
+ {/* <EditorPreview /> */}
+ <FeaturesGrid />
</div>
<CarouselDemos />
<section className="pt-4 pb-10 sm:py-2 w-full mb-0 sm:mb-42" aria-label="Support the project">
diff --git a/app/components/ui/ExportImageDropdown.tsx b/app/components/ui/ExportImageDropdown.tsx
index 84059d5..823a2ad 100644
--- a/app/components/ui/ExportImageDropdown.tsx
+++ b/app/components/ui/ExportImageDropdown.tsx
@@ -190,7 +190,7 @@ export function ExportImageDropdown({
<PopoverContent
align="end"
- className="w-80 bg-black border-white/15 text-white shadow-2xl p-0 rounded-xl overflow-hidden"
+ className="w-80 bg-black border-white/15 text-white shadow-2xl p-0 rounded-xl overflow-hidden z-999999"
>
<div className="px-6 py-4 border-b border-white/10 flex justify-between items-center bg-white/3">
<span className="text-[10px] font-medium uppercase tracking-[0.15em] text-white/50">
diff --git a/app/components/ui/editor/IPhone13ProMax3DViewer.tsx b/app/components/ui/editor/IPhone13ProMax3DViewer.tsx
index 002e7b8..31ef412 100644
--- a/app/components/ui/editor/IPhone13ProMax3DViewer.tsx
+++ b/app/components/ui/editor/IPhone13ProMax3DViewer.tsx
@@ -1,7 +1,7 @@
"use client";
import { Canvas, useThree, useFrame } from "@react-three/fiber";
-import { PerspectiveCamera, useGLTF, Environment, OrbitControls } from "@react-three/drei";
+import { PerspectiveCamera, useGLTF, Environment, OrbitControls, ContactShadows } from "@react-three/drei";
import { useEffect, useRef, useState, Suspense } from "react";
import * as THREE from "three";
import {
@@ -17,6 +17,8 @@ import { EnvironmentPreset, ViewerControls3D } from "@/lib/viewer-controls3d";
export interface IPhone13ProMax3DApi {
renderAt: (width: number, height: number) => void;
+ restorePreview: () => void;
+ hasBuiltInShadow: boolean;
}
interface Props {
@@ -110,6 +112,8 @@ function ModelScene({
onApi,
onLoaded,
videoElement,
+ shadowIntensity = 0,
+ shadowColor = "#000000",
}: {
imageUrl: string | null;
imageMaskConfig: ImageMaskConfigLike | null;
@@ -124,8 +128,10 @@ function ModelScene({
onApi?: (api: IPhone13ProMax3DApi | null) => void;
onLoaded?: () => void;
videoElement?: HTMLVideoElement | null;
+ shadowIntensity?: number;
+ shadowColor?: string;
}) {
- const { gl } = useThree();
+ const { gl, scene, camera } = useThree();
const gltf = useGLTF("/models/apple_iphone_13_pro_max.glb") as unknown as {
nodes: GLTFNodes;
materials: GLTFMaterials;
@@ -138,7 +144,6 @@ function ModelScene({
const lastLoadedCropKeyRef = useRef<string | null>(null);
const wallpaperMatRef = useRef<THREE.MeshStandardMaterial | null>(null);
const videoTextureRef = useRef<THREE.VideoTexture | null>(null);
-
const { autoRotate, rotationSpeed, glow, environment } = ViewerControls3D();
useFrame(() => {
@@ -148,15 +153,35 @@ function ModelScene({
});
useEffect(() => {
+ const previewW = gl.domElement.clientWidth;
+ const previewH = gl.domElement.clientHeight;
const api: IPhone13ProMax3DApi = {
renderAt: (w, h) => {
- void w;
- void h;
+ const cam = cameraRef.current ?? camera;
+ if (!cam) return;
+ (cam as THREE.PerspectiveCamera).aspect = w / h;
+ (cam as THREE.PerspectiveCamera).updateProjectionMatrix();
+ gl.setPixelRatio(2);
+ gl.setSize(w, h, false);
+ if (videoTextureRef.current) {
+ videoTextureRef.current.needsUpdate = true;
+ }
+ gl.render(scene, cam);
+ },
+ restorePreview: () => {
+ const cam = cameraRef.current ?? camera;
+ if (!cam) return;
+ const previewAspect = previewW / previewH;
+ (cam as THREE.PerspectiveCamera).aspect = previewAspect;
+ (cam as THREE.PerspectiveCamera).updateProjectionMatrix();
+ gl.setPixelRatio(3);
+ gl.setSize(previewW, previewH, false);
},
+ hasBuiltInShadow: true,
};
onApi?.(api);
return () => onApi?.(null);
- }, [onApi]);
+ }, [gl, scene, camera, cameraRef, onApi]);
useEffect(() => {
onLoaded?.();
@@ -293,6 +318,12 @@ function ModelScene({
}
}, [initialRotationZ]);
+ // ContactShadows parameters derived from shadowIntensity
+ const shadowT = Math.max(0, Math.min(1, shadowIntensity));
+ const showContactShadow = shadowT > 0.01;
+ const contactOpacity = shadowT * 0.65;
+ const contactBlur = 1.5 + shadowT * 1.5;
+
return (
<>
<PerspectiveCamera ref={cameraRef} makeDefault fov={40} near={0.01} far={100} position={[0, 0, 1.5 / zoom]} />
@@ -324,6 +355,19 @@ function ModelScene({
<directionalLight position={[-4, -2, 3]} intensity={0.25} color="#c8d8ff" />
<directionalLight position={[0, -5, 5]} intensity={0.35} />
+ {/* Contact shadow rendered inside the WebGL scene for export fidelity */}
+ {showContactShadow && (
+ <ContactShadows
+ position={[0, -0.55, 0]}
+ opacity={contactOpacity}
+ scale={3}
+ blur={contactBlur}
+ far={4}
+ color={shadowColor}
+ resolution={512}
+ />
+ )}
+
<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} />
@@ -375,6 +419,8 @@ function CanvasWithLoader({
onApi,
onMount,
videoElement,
+ shadowIntensity,
+ shadowColor,
}: {
imageUrl: string | null;
imageMaskConfig: ImageMaskConfigLike | null;
@@ -389,6 +435,8 @@ function CanvasWithLoader({
onApi?: (api: IPhone13ProMax3DApi | null) => void;
onMount?: (canvas: HTMLCanvasElement) => void;
videoElement?: HTMLVideoElement | null;
+ shadowIntensity?: number;
+ shadowColor?: string;
}) {
const [loaded, setLoaded] = useState(false);
return (
@@ -426,6 +474,8 @@ function CanvasWithLoader({
onApi={onApi}
onLoaded={() => setLoaded(true)}
videoElement={videoElement}
+ shadowIntensity={shadowIntensity}
+ shadowColor={shadowColor}
/>
</Suspense>
</Canvas>
@@ -536,6 +586,8 @@ export function IPhone13ProMax3DViewer({
onApi={onApi}
onMount={onMount}
videoElement={videoElement}
+ shadowIntensity={shadowIntensity}
+ shadowColor={shadowColor}
/>
</div>
</div>
diff --git a/app/components/ui/editor/Laptop3DViewer.tsx b/app/components/ui/editor/Laptop3DViewer.tsx
index 586ec92..9bf3be1 100644
--- a/app/components/ui/editor/Laptop3DViewer.tsx
+++ b/app/components/ui/editor/Laptop3DViewer.tsx
@@ -35,6 +35,8 @@ const lerp = (a: number, b: number, t: number) => a + (b - a) * t;
export interface Laptop3DApi {
renderAt: (width: number, height: number) => void;
+ restorePreview: () => void;
+ hasBuiltInShadow: boolean;
}
interface Props {
@@ -111,21 +113,29 @@ function ModelScene({
});
useEffect(() => {
+ const previewW = RENDER_W;
+ const previewH = RENDER_H;
const api: Laptop3DApi = {
renderAt: (w, h) => {
if (!cameraRef.current) return;
- const oldAspect = cameraRef.current.aspect;
cameraRef.current.aspect = w / h;
cameraRef.current.updateProjectionMatrix();
+ gl.setPixelRatio(2);
gl.setSize(w, h, false);
+ if (videoTextureRef.current) {
+ videoTextureRef.current.needsUpdate = true;
+ }
gl.render(scene, cameraRef.current);
-
- cameraRef.current.aspect = oldAspect;
+ },
+ restorePreview: () => {
+ if (!cameraRef.current) return;
+ cameraRef.current.aspect = RENDER_W / RENDER_H;
cameraRef.current.updateProjectionMatrix();
-
+ gl.setPixelRatio(RENDER_MULTIPLIER);
gl.setSize(RENDER_W, RENDER_H, false);
},
+ hasBuiltInShadow: false,
};
onApi?.(api);
return () => onApi?.(null);
diff --git a/app/components/ui/editor/MockupMenu.tsx b/app/components/ui/editor/MockupMenu.tsx
index ea10e50..de7e755 100644
--- a/app/components/ui/editor/MockupMenu.tsx
+++ b/app/components/ui/editor/MockupMenu.tsx
@@ -451,7 +451,7 @@ export function MockupMenu({
<div className="space-y-2">
<div className="grid grid-cols-3 gap-2">
{[
- "glass-ui-container",
+ "none",
"macos",
"macos-glass",
"brave",
diff --git a/app/components/ui/editor/Phone3DViewer.tsx b/app/components/ui/editor/Phone3DViewer.tsx
index eefeab5..63af038 100644
--- a/app/components/ui/editor/Phone3DViewer.tsx
+++ b/app/components/ui/editor/Phone3DViewer.tsx
@@ -24,6 +24,8 @@ import { EnvironmentPreset, ViewerControls3D } from "@/lib/viewer-controls3d";
export interface Phone3DApi {
renderAt: (width: number, height: number) => void;
+ restorePreview: () => void;
+ hasBuiltInShadow: boolean;
}
interface Props {
@@ -114,18 +116,29 @@ function ModelScene({
});
useEffect(() => {
+ const previewW = gl.domElement.clientWidth || PHONE_W;
+ const previewH = gl.domElement.clientHeight || PHONE_H;
const api: Phone3DApi = {
renderAt: (w, h) => {
if (!cameraRef.current) return;
const oldAspect = cameraRef.current.aspect;
cameraRef.current.aspect = w / h;
cameraRef.current.updateProjectionMatrix();
+ gl.setPixelRatio(2);
gl.setSize(w, h, false);
+ if (videoTextureRef.current) {
+ videoTextureRef.current.needsUpdate = true;
+ }
gl.render(scene, cameraRef.current);
- cameraRef.current.aspect = oldAspect;
+ },
+ restorePreview: () => {
+ if (!cameraRef.current) return;
+ cameraRef.current.aspect = previewW / previewH;
cameraRef.current.updateProjectionMatrix();
- gl.setSize(gl.domElement.clientWidth || PHONE_W, gl.domElement.clientHeight || PHONE_H, false);
+ gl.setPixelRatio(3);
+ gl.setSize(previewW, previewH, false);
},
+ hasBuiltInShadow: false,
};
onApi?.(api);
return () => onApi?.(null);
diff --git a/app/components/ui/editor/VideoCanvas.tsx b/app/components/ui/editor/VideoCanvas.tsx
index d447d05..d50af67 100644
--- a/app/components/ui/editor/VideoCanvas.tsx
+++ b/app/components/ui/editor/VideoCanvas.tsx
@@ -25,7 +25,7 @@ import DropImage from "@/components/ui/DropImage";
import { LayersPanel } from "./LayersPanel";
import { Icon } from "@iconify/react";
import { useMockup3dContext } from "@/app/contexts/Mockup3dContext";
-import { PHONE_H, PHONE_W } from "@/lib/phone3d.utils";
+import { PHONE_H, PHONE_W, DEVICE_3D_DIMENSIONS } from "@/lib/phone3d.utils";
export type { VideoCanvasHandle, VideoCanvasProps };
@@ -122,7 +122,7 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(funct
const ctrlScrollWheelRef = useRef<((e: WheelEvent) => void) | null>(null);
// WebGL canvas from image phone Phone3DViewer, captured via onMount prop for export
const imagePhoneCanvasRef = useRef<HTMLCanvasElement | null>(null);
- const imagePhoneApiRef = useRef<{ renderAt: (w: number, h: number) => void } | null>(null);
+ const imagePhoneApiRef = useRef<{ renderAt: (w: number, h: number) => void; restorePreview: () => void; hasBuiltInShadow?: boolean } | null>(null);
const [activePhoneDevice, setActivePhoneDevice] = useState<string | null>(null);
const [phoneTransitioning, setPhoneTransitioning] = useState(false);
@@ -1152,7 +1152,11 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(funct
drawBg(ctx);
await renderCanvasElements(ctx, canvasElements, canvasWidth, canvasHeight, true);
const { containerX: cX, containerY: cY, containerWidth: cW, containerHeight: cH } = computeContainer();
- drawMockupAndMedia(ctx, cX, cY, cW, cH, image!, true);
+ // Only draw the 2D mockup + media when the 3D phone overlay is NOT active.
+ // In the preview, CSS opacity:0 hides the video layer; here we skip drawing it.
+ if (!imagePhoneActive) {
+ drawMockupAndMedia(ctx, cX, cY, cW, cH, image!, true);
+ }
await renderCanvasElements(ctx, canvasElements, canvasWidth, canvasHeight, false);
// ── Composite image phone mockup (WebGL snapshot) onto export canvas ──
if (imagePhoneActive && imagePhoneCanvasRef.current) {
@@ -1161,14 +1165,33 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(funct
const pxScale = canvasWidth / domW;
const phoneCx = canvasWidth / 2 + imagePhoneX * pxScale;
const phoneCy = canvasHeight / 2 + imagePhoneY * pxScale;
- const drawW = PHONE_W * imagePhoneScale * pxScale;
- const drawH = PHONE_H * imagePhoneScale * pxScale;
+ // Use device-specific dimensions instead of generic PHONE_W/H
+ const deviceDims = DEVICE_3D_DIMENSIONS[imagePhoneDevice] ?? { width: PHONE_W, height: PHONE_H };
+ const drawW = deviceDims.width * imagePhoneScale * pxScale;
+ const drawH = deviceDims.height * imagePhoneScale * pxScale;
+ // Paint CSS-shadow replica as a 2D radial gradient underneath the model,
+ // but only for devices whose 3D viewer doesn't already render ContactShadows.
+ const hasBuiltInShadow = imagePhoneApiRef.current?.hasBuiltInShadow ?? false;
+ if (imagePhoneShadow > 0.01 && !hasBuiltInShadow) {
+ const sT = imagePhoneShadow * imagePhoneShadow;
+ const sBlur = sT * 60;
+ const sOpacity = sT * 0.7;
+ const shadowEllipseW = drawW * (0.6 - sT * 0.1);
+ const shadowEllipseH = Math.max(4, sBlur * 0.55) * pxScale;
+ const shadowCenterY = phoneCy + drawH / 2 + sBlur * 0.2 * pxScale;
+ ctx.save();
+ ctx.globalAlpha = sOpacity;
+ ctx.filter = `blur(${Math.max(2, sBlur * 0.6) * pxScale}px)`;
+ ctx.beginPath();
+ ctx.ellipse(phoneCx, shadowCenterY, shadowEllipseW / 2, shadowEllipseH / 2, 0, 0, Math.PI * 2);
+ ctx.fillStyle = imagePhoneShadowColor;
+ ctx.fill();
+ ctx.restore();
+ }
// Re-render the WebGL canvas at the target export resolution
- // to avoid the pixelation that comes from upscaling a 595×765
- // buffer. The Phone3DViewer restores the buffer to preview size
- // after this call so the on-screen preview is unaffected.
imagePhoneApiRef.current?.renderAt(drawW, drawH);
ctx.drawImage(phoneGL, phoneCx - drawW / 2, phoneCy - drawH / 2, drawW, drawH);
+ imagePhoneApiRef.current?.restorePreview();
}
ctx.restore();
return;
@@ -1245,21 +1268,23 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(funct
await renderCanvasElements(ctx, canvasElements, canvasWidth, canvasHeight, true);
ctx.restore();
+ await drawCameraOverlay(ctx, canvasWidth, canvasHeight);
+
const { containerX, containerY, containerWidth, containerHeight } = computeContainer();
if (has3DEffect && fgCanvas && fgCtx) {
fgCtx.save();
fgCtx.translate(fgOffsetX, fgOffsetY);
- drawMockupAndMedia(fgCtx, containerX, containerY, containerWidth, containerHeight, video!, false);
- fgCtx.restore();
-
- applyPerspective3D(
- fgCanvas,
- zoomState.rotateX,
- zoomState.rotateY,
- zoomState.perspective * BLEED_FACTOR
- );
+ if (!imagePhoneActive) {
+ drawMockupAndMedia(fgCtx, containerX, containerY, containerWidth, containerHeight, video!, false);
+ }
+ // ── Phone 3D encima del video, con zoom aplicado ──
+ if (imagePhoneActive && imagePhoneCanvasRef.current) {
+ drawPhone3DCompositeWithZoom(ctx, canvasWidth, canvasHeight, frameTime, zoomState);
+ }
+ fgCtx.restore();
+ applyPerspective3D(fgCanvas, zoomState.rotateX, zoomState.rotateY, zoomState.perspective * BLEED_FACTOR);
ctx.save();
applyVideoZoom(ctx);
ctx.drawImage(fgCanvas, -fgOffsetX, -fgOffsetY, fgWidth, fgHeight);
@@ -1279,7 +1304,9 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(funct
if (vlCtx) {
vlCtx.imageSmoothingEnabled = true;
vlCtx.imageSmoothingQuality = 'high';
- drawMockupAndMedia(vlCtx, containerX, containerY, containerWidth, containerHeight, video!, false);
+ if (!imagePhoneActive) {
+ drawMockupAndMedia(vlCtx, containerX, containerY, containerWidth, containerHeight, video!, false);
+ }
vlCtx.globalCompositeOperation = 'destination-in';
const vm = videoMaskConfig!;
@@ -1339,11 +1366,26 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(funct
ctx.drawImage(videoLayer, 0, 0);
ctx.restore();
}
+ // ── Mockup 3D FUERA del zoom — overlay independiente ──
+ if (imagePhoneActive && imagePhoneCanvasRef.current) {
+ drawPhone3DCompositeWithZoom(ctx, canvasWidth, canvasHeight, frameTime, zoomState);
+
+ }
+
} else {
ctx.save();
applyVideoZoom(ctx);
- drawMockupAndMedia(ctx, containerX, containerY, containerWidth, containerHeight, video!, false);
+ if (!imagePhoneActive) {
+ drawMockupAndMedia(ctx, containerX, containerY, containerWidth, containerHeight, video!, false);
+ }
ctx.restore();
+
+ // ── Dibuja el mockup 3D SIN zoom del fragmento (es un overlay independiente) ──
+ if (imagePhoneActive && imagePhoneCanvasRef.current) {
+ // SIN ctx.save/applyVideoZoom — posición absoluta en el canvas
+ drawPhone3DCompositeWithZoom(ctx, canvasWidth, canvasHeight, frameTime, zoomState);
+
+ }
}
}
@@ -1355,6 +1397,66 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(funct
await drawCameraOverlay(ctx, canvasWidth, canvasHeight);
};
+ const drawPhone3DCompositeWithZoom = (
+ c: CanvasRenderingContext2D,
+ canvasWidth: number,
+ canvasHeight: number,
+ _frameTime: number,
+ zs: { scale: number; focusX: number; focusY: number }, // ← nuevo parámetro
+ ) => {
+ const phoneGL = imagePhoneCanvasRef.current!;
+ const domW = canvasDimensions?.width ?? canvasWidth;
+ const pxScale = canvasWidth / domW;
+
+ // Zoom del fragmento activo — recibido como parámetro, no del closure
+ const zScale = zs.scale;
+ const focusPxX = (zs.focusX / 100) * canvasWidth;
+ const focusPxY = (zs.focusY / 100) * canvasHeight;
+ const centerX = canvasWidth / 2;
+ const centerY = canvasHeight / 2;
+
+ // Posición base del mockup (sin zoom)
+ const baseCx = centerX + imagePhoneX * pxScale;
+ const baseCy = centerY + imagePhoneY * pxScale;
+
+ // Aplicar la misma transformación que applyVideoZoom:
+ // newPos = (base - focusPx) * scale + center
+ const phoneCx = (baseCx - focusPxX) * zScale + centerX;
+ const phoneCy = (baseCy - focusPxY) * zScale + centerY;
+
+ // Tamaño también escala con el zoom
+ const deviceDims = DEVICE_3D_DIMENSIONS[imagePhoneDevice] ?? { width: PHONE_W, height: PHONE_H };
+ const drawW = deviceDims.width * imagePhoneScale * pxScale * zScale;
+ const drawH = deviceDims.height * imagePhoneScale * pxScale * zScale;
+
+ // Sombra de suelo
+ const hasBuiltInShadow = imagePhoneApiRef.current?.hasBuiltInShadow ?? false;
+ if (imagePhoneShadow > 0.01 && !hasBuiltInShadow) {
+ const sT = imagePhoneShadow * imagePhoneShadow;
+ const sBlur = sT * 60;
+ const sOpacity = sT * 0.7;
+ c.save();
+ c.globalAlpha = sOpacity;
+ c.filter = `blur(${Math.max(2, sBlur * 0.6) * pxScale}px)`;
+ c.beginPath();
+ c.ellipse(
+ phoneCx,
+ phoneCy + drawH / 2 + sBlur * 0.2 * pxScale,
+ drawW * (0.6 - sT * 0.1) / 2,
+ Math.max(4, sBlur * 0.55) * pxScale / 2,
+ 0, 0, Math.PI * 2
+ );
+ c.fillStyle = imagePhoneShadowColor;
+ c.fill();
+ c.restore();
+ }
+
+ // Renderizar WebGL
+ imagePhoneApiRef.current?.renderAt(drawW, drawH);
+ c.drawImage(phoneGL, phoneCx - drawW / 2, phoneCy - drawH / 2, drawW, drawH);
+ imagePhoneApiRef.current?.restorePreview();
+ };
+
const drawCameraOverlay = async (
ctx: CanvasRenderingContext2D,
canvasWidth: number,
@@ -1466,21 +1568,6 @@ export const VideoCanvas = forwardRef<VideoCanvasHandle, VideoCanvasProps>(funct
}
}
ctx.restore();
-
- // ── 3D phone mockup overlay for video export ──
- // Composite the WebGL canvas snapshot just like image mode does.
- if (imagePhoneActive && imagePhoneCanvasRef.current) {
- const phoneGL = imagePhoneCanvasRef.current;
- const domW = canvasDimensions?.width ?? canvasWidth;
- const pxScale = canvasWidth / domW;
- const phoneCx = canvasWidth / 2 + imagePhoneX * pxScale;
- const phoneCy = canvasHeight / 2 + imagePhoneY * pxScale;
- const drawW = PHONE_W * imagePhoneScale * pxScale;
- const drawH = PHONE_H * imagePhoneScale * pxScale;
- imagePhoneApiRef.current?.renderAt(drawW, drawH);
- ctx.drawImage(phoneGL, phoneCx - drawW / 2, phoneCy - drawH / 2, drawW, drawH);
- }
-
};
useImperativeHandle(ref, () => ({
diff --git a/app/components/ui/home/RecordingSteps.tsx b/app/components/ui/home/RecordingSteps.tsx
index e1da618..6d59949 100644
--- a/app/components/ui/home/RecordingSteps.tsx
+++ b/app/components/ui/home/RecordingSteps.tsx
@@ -99,7 +99,7 @@ export default function InteractiveRecordingSteps() {
</div>
),
visual: (
- <div className="aspect-video bg-[#0A0A0A] border border-white/10 rounded-xl flex items-center justify-center relative group shadow-2xl p-1 sm:p-0">
+ <div className="aspect-video bg-[#0A0A0A]rounded-xl flex items-center justify-center relative group shadow-2xl p-1 sm:p-0">
<div className="absolute inset-0 bg-[radial-linear(#ffffff22_1px,transparent_1px)] [bg-size:16px_16px] opacity-10"></div>
<div className="bg-[#292A2D] rounded-xl w-full max-w-full shadow-2xl relative z-10 flex flex-col font-sans border border-white/5 origin-center">
<div className="flex justify-between px-2 sm:px-4 pt-2 sm:pt-3 border-b border-white/10 text-[9px] sm:text-[11px] font-medium">
@@ -297,15 +297,15 @@ export default function InteractiveRecordingSteps() {
];
return (
- <div id="docs" className="w-full max-w-7xl mx-auto px-0 py-6 sm:py-24 text-left">
- <div className="max-w-3xl mx-auto text-center mb-32">
- <h2 className="text-4xl md:text-6xl font-bold tracking-tighter text-white mb-6 leading-tight drop-shadow-[1.2px_1.2px_12px_rgba(183,203,248,0.4)]">
+ <div id="docs" className="w-full max-w-7xl mx-auto px-6 lg:px-8 py-24 text-left">
+ <div className="max-w-2xl mb-16">
+ <h2 className="text-4xl sm:text-5xl font-semibold tracking-tight text-white mb-6">
{t('title')} <br />
- <span className="bg-linear-to-r from-[#003780] to-white bg-clip-text text-transparent">
+ <span className="text-transparent bg-clip-text bg-gradient-to-r from-neutral-300 to-neutral-500">
{t('title2')}
</span>
</h2>
- <p className="text-lg md:text-xl text-neutral-400 font-light leading-relaxed mb-8">
+ <p className="text-lg text-neutral-400 font-light leading-relaxed max-w-xl">
{t('subtitle')}
</p>
</div>
diff --git a/lib/phone3d.utils.ts b/lib/phone3d.utils.ts
index 53f4b98..7794885 100644
--- a/lib/phone3d.utils.ts
+++ b/lib/phone3d.utils.ts
@@ -1,33 +1,25 @@
-/**
- * Phone3DViewer — pure helpers and constants
- *
- * Extracted from Phone3DViewer.tsx to keep the main component file focused
- * on React state, refs, and the render loop. Everything here is a pure
- * function or a module-level constant that doesn't depend on React.
- */
import * as THREE from "three";
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
-// ─── Canvas dimensions ────────────────────────────────────────────────────────
-// Based on phone-gltf.glb model dimensions:
-// Model aspect ratio (width/height): 0.479
-// Screen aspect ratio (width/height): 0.459
export const PHONE_H = 704;
-export const PHONE_W = Math.round(PHONE_H * 0.479); // matches model aspect ratio
+export const PHONE_W = Math.round(PHONE_H * 0.479);
-// Render at 4x resolution for better quality (antialiasing) AND to provide
-// enough buffer space for rotations and scaling without clipping.
-export const RENDER_MULTIPLIER = 4; // Important: quality
+export const RENDER_MULTIPLIER = 4;
export const RENDER_W = PHONE_W * RENDER_MULTIPLIER;
export const RENDER_H = PHONE_H * RENDER_MULTIPLIER;
+export const DEVICE_3D_DIMENSIONS: Record<string, { width: number; height: number }> = {
+ 'phone': { width: PHONE_W, height: PHONE_H },
+ 'iphone': { width: PHONE_W, height: PHONE_H },
+ 'iphone-13-pro-max': { width: 480, height: 1000 },
+ 'samsung': { width: PHONE_W, height: PHONE_H },
+ 'laptop': { width: 1500, height: 1035 },
+};
+
// Camera settings (based on appscreen-main reference: fov=20, position=[-3,-1,4])
export const CAM_FOV = 20;
-export const CAM_Z = 6; // Closer to model (reference uses position.z = 4)
+export const CAM_Z = 6;
-// ─── Device configs ───────────────────────────────────────────────────────────
-// For iPhone/Samsung the GLB doesn't expose a usable screen UV, so we add a
-// custom PlaneGeometry on top of the glass with the correct aspect ratio.
export type DeviceKey = "iphone" | "samsung" | "phone";
export interface DeviceConfig {
@@ -69,7 +61,6 @@ export function getDeviceFromModelUrl(modelUrl: string | undefined): DeviceKey {
return "phone";
}
-// ─── Screen canvas helper ────────────────────────────────────────────────────
export interface ImageMaskConfigLike {
enabled?: boolean;
top?: { from: number; to?: number };
@@ -157,7 +148,6 @@ export function createCoverScreenCanvas(
return canvas;
}
-// ─── GLTF URL cache ───────────────────────────────────────────────────────────
// All models (including the default phone) are now loaded as GLB files via URL.
// The old loadGltfGroup() / GLTFLoader.parse() path is gone; everything goes
// through loadGltfFromUrl() which caches by URL so each file is fetched once.
@@ -203,7 +193,6 @@ export function cloneGroup(src: THREE.Group): THREE.Group {
return cloned;
}
-// ─── Math helpers ────────────────────────────────────────────────────────────
/** Shortest arc in degrees from curRy to targetRy, result in [-180, 180] */
export function shortArc(curRy: number, targetRy: number): number {
return ((targetRy - curRy) % 360 + 540) % 360 - 180;
@@ -217,10 +206,6 @@ export function parseShadowColor(hex: string, opacity: number): string {
return `rgba(${r},${g},${b},${opacity.toFixed(3)})`;
}
-// ─── Crop helper ─────────────────────────────────────────────────────────────
-// Aplica un crop a una imagen y devuelve un HTMLCanvasElement con la región
-// recortada. El crop está en porcentajes (0-100). Si el crop cubre el 100%
-// o es null/undefined, devuelve la imagen original sin modificar.
export interface CropAreaLike {
x: number;
y: number;
@@ -244,7 +229,6 @@ export function applyCropToImage(
srcH = source.height || 1;
}
- // Si el crop está vacío o cubre el 100%, no hace nada
const isFullCrop = !cropArea
|| (cropArea.x <= 0 && cropArea.y <= 0
&& cropArea.width >= 100 && cropArea.height >= 100);
@@ -256,7 +240,6 @@ export function applyCropToImage(
return out;
}
- // Calcular región en píxeles. Clamp para no salirnos de la imagen.
const x = Math.max(0, Math.min(100, cropArea.x));
const y = Math.max(0, Math.min(100, cropArea.y));
const width = Math.max(1, Math.min(100 - x, cropArea.width));