Create professional demos and 3D mockups in seconds, directly in your browser
feat: enhance 3D viewer components with auto-rotation, customizable glow, and environment settings; refactor viewer controls for improved usability
CristianOlivera1150efd3bb048
diff --git a/app/components/ui/editor/VideoCanvas.tsx b/app/components/ui/editor/VideoCanvas.tsxindex 37d75dd..815264e 100644--- a/app/components/ui/editor/VideoCanvas.tsx+++ b/app/components/ui/editor/VideoCanvas.tsx@@ -25,7 +25,9 @@ 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, DEVICE_3D_DIMENSIONS } from "@/lib/phone3d.utils";+import { PHONE_H, PHONE_W, DEVICE_3D_DIMENSIONS, DEVICE_VIEWER_DEFAULTS } from "@/lib/phone3d.utils";+import { ViewerControls3D } from "@/lib/viewer-controls3d";+import { ControlsPopup } from "@/components/ui/ControlsPopup";export type { VideoCanvasHandle, VideoCanvasProps };@@ -363,6 +365,12 @@ const VideoCanvasInner = forwardRef<VideoCanvasHandle, VideoCanvasProps>(functioreturn () => observer.disconnect();}, [aspectRatio, customAspectRatio]);+ const deviceDefaults = DEVICE_VIEWER_DEFAULTS[imagePhoneDevice] ?? { environment: "studio", glow: 1.0 };+ const viewer3D = ViewerControls3D({+ defaultEnvironment: deviceDefaults.environment,+ defaultGlow: deviceDefaults.glow,+ });+useEffect(() => {if (!canvasDimensions) return;@@ -2177,6 +2185,7 @@ const VideoCanvasInner = forwardRef<VideoCanvasHandle, VideoCanvasProps>(functioclassName="absolute inset-0 pointer-events-none"style={{ zIndex: 155, overflow: "visible" }}>+ <ControlsPopup /><divclassName="absolute animate-in fade-in zoom-in-95 duration-300"style={{@@ -2262,6 +2271,10 @@ const VideoCanvasInner = forwardRef<VideoCanvasHandle, VideoCanvasProps>(functiozoom={1}shadowIntensity={imagePhoneShadow}shadowColor={imagePhoneShadowColor}+ autoRotate={viewer3D.autoRotate}+ rotationSpeed={viewer3D.rotationSpeed}+ glow={viewer3D.glow}+ environment={viewer3D.environment}/>) : activePhoneDevice === "iphone-13-pro-max" ? (<IPhone13ProMax3DViewer@@ -2280,6 +2293,10 @@ const VideoCanvasInner = forwardRef<VideoCanvasHandle, VideoCanvasProps>(functiozoom={1}shadowIntensity={imagePhoneShadow}shadowColor={imagePhoneShadowColor}+ autoRotate={viewer3D.autoRotate}+ rotationSpeed={viewer3D.rotationSpeed}+ glow={viewer3D.glow}+ environment={viewer3D.environment}/>) : activePhoneDevice === "iphone-17-pro-max" ? (<IPhone17ProMax3DViewer@@ -2298,6 +2315,10 @@ const VideoCanvasInner = forwardRef<VideoCanvasHandle, VideoCanvasProps>(functiozoom={1}shadowIntensity={imagePhoneShadow}shadowColor={imagePhoneShadowColor}+ autoRotate={viewer3D.autoRotate}+ rotationSpeed={viewer3D.rotationSpeed}+ glow={viewer3D.glow}+ environment={viewer3D.environment}/>) : activePhoneDevice === "double_iphone_13_pro" ? (<DoubleIPhone3DViewer@@ -2312,10 +2333,13 @@ const VideoCanvasInner = forwardRef<VideoCanvasHandle, VideoCanvasProps>(functioonRotationChange={handlePhoneRotationChange}onMount={handlePhoneMount}onApi={handlePhoneApi}- scale={1}zoom={1}shadowIntensity={imagePhoneShadow}shadowColor={imagePhoneShadowColor}+ autoRotate={viewer3D.autoRotate}+ rotationSpeed={viewer3D.rotationSpeed}+ glow={viewer3D.glow}+ environment={viewer3D.environment}/>) : (<Phone3DViewer@@ -2335,6 +2359,10 @@ const VideoCanvasInner = forwardRef<VideoCanvasHandle, VideoCanvasProps>(functioonRotationChange={handlePhoneRotationChange}onMount={handlePhoneMount}onApi={handlePhoneApi}+ autoRotate={viewer3D.autoRotate}+ rotationSpeed={viewer3D.rotationSpeed}+ glow={viewer3D.glow}+ environment={viewer3D.environment}/>)}</div>diff --git a/app/components/ui/editor/mockups-3d/DoubleIPhone3DViewer.tsx b/app/components/ui/editor/mockups-3d/DoubleIPhone3DViewer.tsxindex b3c88b6..23d4669 100644--- a/app/components/ui/editor/mockups-3d/DoubleIPhone3DViewer.tsx+++ b/app/components/ui/editor/mockups-3d/DoubleIPhone3DViewer.tsx@@ -13,8 +13,7 @@ import {parseShadowColor,} 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";+import { EnvironmentPreset } from "@/lib/viewer-controls3d";export interface DoubleIPhone3DApi {renderAt: (width: number, height: number) => void;@@ -32,11 +31,14 @@ interface Props {onRotationChange?: (rx: number, ry: number) => void;onMount?: (canvas: HTMLCanvasElement) => void;onApi?: (api: DoubleIPhone3DApi | null) => void;- scale?: number;zoom?: number;shadowIntensity?: number;shadowColor?: string;videoElement?: HTMLVideoElement | null;+ autoRotate?: boolean;+ rotationSpeed?: number;+ glow?: number;+ environment?: EnvironmentPreset;}const DEG = Math.PI / 180;@@ -61,6 +63,10 @@ function ModelScene({onApi,onLoaded,videoElement,+ autoRotate = false,+ rotationSpeed = 3.5,+ glow = 3.0,+ environment = "studio",}: Props & {rootRef: React.MutableRefObject<THREE.Group | null>;cameraRef: React.MutableRefObject<THREE.PerspectiveCamera | null>;@@ -71,7 +77,7 @@ function ModelScene({const orbitRef = useRef<OrbitControlsType | null>(null);const screenMatRef = useRef<THREE.MeshBasicMaterial | null>(null);const videoTextureRef = useRef<THREE.VideoTexture | null>(null);- const [modelGroup, setModelGroup] = useState<THREE.Group | null>(null);+ const modelContainerRef = useRef<THREE.Group>(null!);const lastLoadedUrlRef = useRef<string | null>(null);const lastLoadedCropKeyRef = useRef<string | null>(null);const onApiRef = useRef(onApi);@@ -80,11 +86,6 @@ function ModelScene({onApiRef.current = onApi;});- const { autoRotate, rotationSpeed, glow, environment } = ViewerControls3D({- defaultEnvironment: "studio",- defaultGlow: 3.0,- });-useFrame(() => {if (videoElement && videoTextureRef.current) {videoTextureRef.current.needsUpdate = true;@@ -127,7 +128,11 @@ function ModelScene({gl.setPixelRatio(window.devicePixelRatio > 1 ? 2 : 1);gl.setSize(freshW, freshH, false);},- hasBuiltInShadow: true,+ // Este viewer no tiene ContactShadows real en la escena — su sombra es+ // puramente CSS (drop-shadow del wrapper) y NO se captura en renderAt().+ // Si se deja en `true`, VideoCanvas.drawFrame omite el fallback 2D y el+ // export queda sin sombra.+ hasBuiltInShadow: false,};capturedOnApi?.(api);@@ -222,7 +227,7 @@ function ModelScene({}const tex = new THREE.VideoTexture(videoElement);- tex.flipY = false;+ tex.flipY = true;tex.colorSpace = THREE.SRGBColorSpace;tex.generateMipmaps = true;tex.minFilter = THREE.LinearMipmapLinearFilter;@@ -289,7 +294,11 @@ function ModelScene({}});- setModelGroup(group);+ const container = modelContainerRef.current;+ if (container) {+ container.clear();+ container.add(group);+ }setTimeout(() => {if (!isMounted) return;@@ -377,7 +386,7 @@ function ModelScene({<directionalLight position={[-4, -2, 3]} intensity={0.25} color="#c8d8ff" /><directionalLight position={[0, -5, 5]} intensity={0.35} /><group ref={rootRef} rotation={[0, initialRotationZ * DEG, 0]}>- {modelGroup && <primitive object={modelGroup} />}+ <group ref={modelContainerRef} /></group></>);@@ -431,7 +440,7 @@ function CanvasWithLoader(}export function DoubleIPhone3DViewer(props: Props) {- const { scale = 1, 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);const [grabbing, setGrabbing] = useState(false);@@ -447,7 +456,6 @@ export function DoubleIPhone3DViewer(props: Props) {return (<>- <ControlsPopup /><divstyle={{display: "inline-block",diff --git a/app/components/ui/editor/mockups-3d/IPhone13ProMax3DViewer.tsx b/app/components/ui/editor/mockups-3d/IPhone13ProMax3DViewer.tsxindex d09a4c1..14d0f10 100644--- a/app/components/ui/editor/mockups-3d/IPhone13ProMax3DViewer.tsx+++ b/app/components/ui/editor/mockups-3d/IPhone13ProMax3DViewer.tsx@@ -6,8 +6,7 @@ import { useEffect, useRef, useState, Suspense, useLayoutEffect } from "react";import * as THREE from "three";import { createCoverScreenCanvas, applyCropToImage, 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";+import { EnvironmentPreset } from "@/lib/viewer-controls3d";export interface IPhone13ProMax3DApi {renderAt: (width: number, height: number) => void;@@ -30,6 +29,10 @@ interface Props {shadowIntensity?: number;shadowColor?: string;videoElement?: HTMLVideoElement | null;+ autoRotate?: boolean;+ rotationSpeed?: number;+ glow?: number;+ environment?: EnvironmentPreset;}const TEX_W = 1284 * 2;@@ -111,6 +114,10 @@ function ModelScene({videoElement,shadowIntensity = 0,shadowColor = "#000000",+ autoRotate = false,+ rotationSpeed = 3.5,+ glow = 2.0,+ environment = "sunset",}: {imageUrl: string | null;imageMaskConfig: ImageMaskConfigLike | null;@@ -127,6 +134,10 @@ function ModelScene({videoElement?: HTMLVideoElement | null;shadowIntensity?: number;shadowColor?: string;+ autoRotate?: boolean;+ rotationSpeed?: number;+ glow?: number;+ environment?: EnvironmentPreset;}) {const { gl, scene, camera, invalidate } = useThree();const gltf = useGLTF("/models/apple_iphone_13_pro_max.glb", DRACO_URL) as unknown as {@@ -141,12 +152,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({- defaultEnvironment: "sunset",- defaultGlow: 2.0,- });-const onApiRef = useRef(onApi);useLayoutEffect(() => {@@ -481,6 +486,10 @@ function CanvasWithLoader({videoElement,shadowIntensity,shadowColor,+ autoRotate,+ rotationSpeed,+ glow,+ environment,}: {imageUrl: string | null;imageMaskConfig: ImageMaskConfigLike | null;@@ -497,6 +506,10 @@ function CanvasWithLoader({videoElement?: HTMLVideoElement | null;shadowIntensity?: number;shadowColor?: string;+ autoRotate?: boolean;+ rotationSpeed?: number;+ glow?: number;+ environment?: EnvironmentPreset;}) {const [loaded, setLoaded] = useState(false);@@ -539,6 +552,10 @@ function CanvasWithLoader({videoElement={videoElement}shadowIntensity={shadowIntensity}shadowColor={shadowColor}+ autoRotate={autoRotate}+ rotationSpeed={rotationSpeed}+ glow={glow}+ environment={environment}/></Suspense></Canvas>@@ -564,11 +581,14 @@ export function IPhone13ProMax3DViewer({onRotationChange,onMount,onApi,- scale = 1,zoom = 1,shadowIntensity = 0,shadowColor = "#000000",videoElement = null,+ autoRotate,+ rotationSpeed,+ glow,+ environment}: Props) {const rootRef = useRef<THREE.Group | null>(null);const cameraRef = useRef<THREE.PerspectiveCamera | null>(null);@@ -585,7 +605,6 @@ export function IPhone13ProMax3DViewer({return (<>- <ControlsPopup /><divstyle={{display: "inline-block",@@ -647,6 +666,10 @@ export function IPhone13ProMax3DViewer({videoElement={videoElement}shadowIntensity={shadowIntensity}shadowColor={shadowColor}+ autoRotate={autoRotate}+ rotationSpeed={rotationSpeed}+ glow={glow}+ environment={environment}/></div></div>diff --git a/app/components/ui/editor/mockups-3d/IPhone17ProMax3DViewer.tsx b/app/components/ui/editor/mockups-3d/IPhone17ProMax3DViewer.tsxindex 1901e5b..d6dd2f6 100644--- a/app/components/ui/editor/mockups-3d/IPhone17ProMax3DViewer.tsx+++ b/app/components/ui/editor/mockups-3d/IPhone17ProMax3DViewer.tsx@@ -6,8 +6,7 @@ import { useEffect, useRef, useState, Suspense, useLayoutEffect, useMemo, useCalimport * as THREE from "three";import { createCoverScreenCanvas, applyCropToImage, 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";+import { EnvironmentPreset } from "@/lib/viewer-controls3d";export interface IPhone17ProMax3DApi {renderAt: (width: number, height: number) => void;@@ -30,6 +29,10 @@ interface Props {shadowIntensity?: number;shadowColor?: string;videoElement?: HTMLVideoElement | null;+ autoRotate?: boolean;+ rotationSpeed?: number;+ glow?: number;+ environment?: EnvironmentPreset;}const TEX_W = 1284 * 2;@@ -56,6 +59,10 @@ function ModelScene({videoElement,shadowIntensity = 0,shadowColor = "#000000",+ autoRotate = false,+ rotationSpeed = 3.5,+ glow = 1.0,+ environment = "studio",}: {imageUrl: string | null;imageMaskConfig: ImageMaskConfigLike | null;@@ -72,12 +79,16 @@ function ModelScene({videoElement?: HTMLVideoElement | null;shadowIntensity?: number;shadowColor?: string;+ autoRotate?: boolean;+ rotationSpeed?: number;+ glow?: number;+ environment?: EnvironmentPreset;}) {const { gl, scene, camera, invalidate } = useThree();const gltf = useGLTF("/models/iphone-17-pro-max.glb", DRACO_URL);-+const clonedScene = useMemo(() => gltf.scene.clone(true), [gltf.scene]);-+const orbitRef = useRef<OrbitControlsType | null>(null);const lastLoadedImageUrlRef = useRef<string | null>(null);const lastLoadedMaskKeyRef = useRef<string | null>(null);@@ -85,11 +96,6 @@ function ModelScene({const wallpaperMatRef = useRef<THREE.MeshPhysicalMaterial | null>(null);const videoTextureRef = useRef<THREE.VideoTexture | null>(null);- const { autoRotate, rotationSpeed, glow, environment } = ViewerControls3D({- defaultEnvironment: "studio",- defaultGlow: 1.0,- });-const onApiRef = useRef(onApi);useLayoutEffect(() => {onApiRef.current = onApi;@@ -106,17 +112,17 @@ function ModelScene({if (child instanceof THREE.Mesh) {if (child.name.includes("HkNSnYzBPABcqwM")) {const targetMat = (child.material as THREE.MeshPhysicalMaterial).clone();-- targetMat.normalMap = null;++ targetMat.normalMap = null;targetMat.roughnessMap = null;targetMat.metalnessMap = null;targetMat.clearcoatMap = null;targetMat.emissiveMap = null;- targetMat.emissive = new THREE.Color(0x000000);+ targetMat.emissive = new THREE.Color(0x000000);targetMat.roughness = 0.8;targetMat.metalness = 0.1;- targetMat.envMapIntensity = 0.1;-+ targetMat.envMapIntensity = 0.1;+child.material = targetMat;wallpaperMatRef.current = targetMat;}@@ -173,19 +179,19 @@ function ModelScene({return;}const tex = new THREE.VideoTexture(videoElement);-+tex.flipY = false;-+tex.colorSpace = THREE.SRGBColorSpace;tex.generateMipmaps = true;tex.minFilter = THREE.LinearMipmapLinearFilter;tex.magFilter = THREE.LinearFilter;-+if (videoTextureRef.current) {videoTextureRef.current.dispose();}videoTextureRef.current = tex;-+const applyVideoTex = () => {const mat = wallpaperMatRef.current;if (!mat) return;@@ -198,9 +204,9 @@ function ModelScene({if (mat.map) mat.map.needsUpdate = true;invalidate();};-+applyVideoTex();-+return () => {if (videoTextureRef.current === tex) {videoTextureRef.current = null;@@ -212,7 +218,7 @@ function ModelScene({useEffect(() => {const mat = wallpaperMatRef.current;if (!mat) return;-+if (videoElement) return;const maskKey = imageMaskConfig ? JSON.stringify(imageMaskConfig) : null;@@ -231,19 +237,19 @@ function ModelScene({mat.map = null;}const tex = new THREE.CanvasTexture(cover);-+tex.flipY = false;-+tex.colorSpace = THREE.SRGBColorSpace;tex.generateMipmaps = true;tex.minFilter = THREE.LinearMipmapLinearFilter;tex.magFilter = THREE.LinearFilter;tex.anisotropy = gl.capabilities.getMaxAnisotropy();-+mat.map = tex;mat.color.set(0xffffff);mat.needsUpdate = true;-+lastLoadedImageUrlRef.current = placeholderKey;lastLoadedMaskKeyRef.current = null;lastLoadedCropKeyRef.current = null;@@ -279,21 +285,21 @@ function ModelScene({mat.map = null;}const tex = new THREE.CanvasTexture(cover);-+tex.flipY = false;-+tex.colorSpace = THREE.SRGBColorSpace;tex.generateMipmaps = true;tex.minFilter = THREE.LinearMipmapLinearFilter;tex.magFilter = THREE.LinearFilter;tex.anisotropy = gl.capabilities.getMaxAnisotropy();-+mat.map = tex;mat.color.set(0xffffff);mat.needsUpdate = true;-+invalidate();-+lastLoadedImageUrlRef.current = imageUrl;lastLoadedMaskKeyRef.current = maskKey;lastLoadedCropKeyRef.current = cropKey;@@ -358,7 +364,7 @@ function ModelScene({{showContactShadow && (<ContactShadows position={[0, -0.55, 0]} opacity={contactOpacity} scale={3} blur={contactBlur} far={4} color={shadowColor} resolution={512} />)}-+<group ref={rootRef} rotation={[0, 0, 0]} scale={1} dispose={null}><primitive object={clonedScene} scale={5} rotation={[0, 0, 0]} castShadow receiveShadow /></group>@@ -382,6 +388,10 @@ function CanvasWithLoader({videoElement,shadowIntensity,shadowColor,+ autoRotate,+ rotationSpeed,+ glow,+ environment,}: {imageUrl: string | null;imageMaskConfig: ImageMaskConfigLike | null;@@ -398,10 +408,14 @@ function CanvasWithLoader({videoElement?: HTMLVideoElement | null;shadowIntensity?: number;shadowColor?: string;+ autoRotate?: boolean;+ rotationSpeed?: number;+ glow?: number;+ environment?: EnvironmentPreset;}) {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" }} dpr={3} frameloop={videoElement ? "always" : "demand"} resize={{ scroll: false, debounce: { scroll: 0, resize: 0 } }} onCreated={({ gl, scene }) => {@@ -412,7 +426,27 @@ function CanvasWithLoader({onMount?.(gl.domElement);}} ><Suspense fallback={null}>- <ModelScene imageUrl={imageUrl} imageMaskConfig={imageMaskConfig} cropArea={cropArea} initialRotationX={initialRotationX} initialRotationY={initialRotationY} initialRotationZ={initialRotationZ} onRotationChange={onRotationChange} rootRef={rootRef} cameraRef={cameraRef} zoom={zoom} onApi={onApi} onLoaded={handleLoaded} videoElement={videoElement} shadowIntensity={shadowIntensity} shadowColor={shadowColor} />+ <ModelScene+ imageUrl={imageUrl}+ imageMaskConfig={imageMaskConfig}+ cropArea={cropArea}+ initialRotationX={initialRotationX}+ initialRotationY={initialRotationY}+ initialRotationZ={initialRotationZ}+ onRotationChange={onRotationChange}+ rootRef={rootRef}+ cameraRef={cameraRef}+ zoom={zoom}+ onApi={onApi}+ onLoaded={handleLoaded}+ videoElement={videoElement}+ shadowIntensity={shadowIntensity}+ shadowColor={shadowColor}+ autoRotate={autoRotate}+ rotationSpeed={rotationSpeed}+ glow={glow}+ environment={environment}+ /></Suspense></Canvas>{!loaded && (@@ -438,28 +472,51 @@ export function IPhone17ProMax3DViewer({shadowIntensity = 0,shadowColor = "#000000",videoElement = null,+ autoRotate,+ rotationSpeed,+ glow,+ environment,}: 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: 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 style={{ position: "absolute", inset: "-400px", 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} videoElement={videoElement} shadowIntensity={shadowIntensity} shadowColor={shadowColor} />+ <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}+ videoElement={videoElement}+ shadowIntensity={shadowIntensity}+ shadowColor={shadowColor}+ autoRotate={autoRotate}+ rotationSpeed={rotationSpeed}+ glow={glow}+ environment={environment}+ /></div></div></div>diff --git a/app/components/ui/editor/mockups-3d/Laptop3DViewer.tsx b/app/components/ui/editor/mockups-3d/Laptop3DViewer.tsxindex 8ee4a2c..fc52004 100644--- a/app/components/ui/editor/mockups-3d/Laptop3DViewer.tsx+++ b/app/components/ui/editor/mockups-3d/Laptop3DViewer.tsx@@ -12,8 +12,7 @@ import {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";+import { EnvironmentPreset } from "@/lib/viewer-controls3d";THREE.Cache.enabled = true;@@ -54,6 +53,10 @@ interface Props {shadowIntensity?: number;shadowColor?: string;videoElement?: HTMLVideoElement | null;+ autoRotate?: boolean;+ rotationSpeed?: number;+ glow?: number;+ environment?: EnvironmentPreset;}let gltfCachePromise: Promise<THREE.Group> | null = null;@@ -87,6 +90,10 @@ function ModelScene({onApi,onLoaded,videoElement,+ autoRotate = false,+ rotationSpeed = 3.5,+ glow = 1.0,+ environment = "forest",}: Props & {rootRef: React.MutableRefObject<THREE.Group | null>;cameraRef: React.MutableRefObject<THREE.PerspectiveCamera | null>;@@ -106,10 +113,6 @@ function ModelScene({onApiRef.current = onApi;});- const { autoRotate, rotationSpeed, glow, environment } = ViewerControls3D({- defaultEnvironment: "forest",- });-useFrame(() => {if (videoElement && videoTextureRef.current) {videoTextureRef.current.needsUpdate = true;@@ -344,7 +347,7 @@ 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) => {tex.anisotropy = gl.capabilities.getMaxAnisotropy();keyboardMaterial.alphaMap = tex;@@ -558,7 +561,6 @@ export function Laptop3DViewer(props: Props) {return (<>- <ControlsPopup /><divstyle={{display: "inline-block",diff --git a/app/components/ui/editor/mockups-3d/Phone3DViewer.tsx b/app/components/ui/editor/mockups-3d/Phone3DViewer.tsxindex e6242da..991798a 100644--- a/app/components/ui/editor/mockups-3d/Phone3DViewer.tsx+++ b/app/components/ui/editor/mockups-3d/Phone3DViewer.tsx@@ -18,8 +18,7 @@ import {parseShadowColor,} 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";+import { EnvironmentPreset } from "@/lib/viewer-controls3d";THREE.Cache.enabled = true;@@ -45,6 +44,10 @@ interface Props {shadowIntensity?: number;shadowColor?: string;videoElement?: HTMLVideoElement | null;+ autoRotate?: boolean;+ rotationSpeed?: number;+ glow?: number;+ environment?: EnvironmentPreset;}const DEG = Math.PI / 180;@@ -105,6 +108,10 @@ function ModelScene({onApi,onLoaded,videoElement,+ autoRotate = false,+ rotationSpeed = 3.5,+ glow = 1.0,+ environment = "studio",}: Props & {rootRef: React.MutableRefObject<THREE.Group | null>;cameraRef: React.MutableRefObject<THREE.PerspectiveCamera | null>;@@ -125,8 +132,6 @@ function ModelScene({onApiRef.current = onApi;});- const { autoRotate, rotationSpeed, glow, environment } = ViewerControls3D();-useFrame(() => {if (videoElement && videoTextureRef.current) {videoTextureRef.current.needsUpdate = true;@@ -655,7 +660,7 @@ function CanvasWithLoader(}export function Phone3DViewer(props: Props) {- const { scale = 1, 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);const [grabbing, setGrabbing] = useState(false);@@ -671,7 +676,6 @@ export function Phone3DViewer(props: Props) {return (<>- <ControlsPopup /><divstyle={{display: "inline-block",diff --git a/lib/phone3d.utils.ts b/lib/phone3d.utils.tsindex 57257de..f907459 100644--- a/lib/phone3d.utils.ts+++ b/lib/phone3d.utils.ts@@ -1,5 +1,6 @@import * as THREE from "three";import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";+import { EnvironmentPreset } from "./viewer-controls3d";export interface DeviceConfig {modelUrl: string | null;@@ -65,6 +66,15 @@ export const deviceConfigs: Record<DeviceKey, DeviceConfig> = {},};+export const DEVICE_VIEWER_DEFAULTS: Record<string, { environment: EnvironmentPreset; glow: number }> = {+ double_iphone_13_pro: { environment: "studio", glow: 3.0 },+ "iphone-13-pro-max": { environment: "sunset", glow: 2.0 },+ "iphone-17-pro-max": { environment: "studio", glow: 1.0 },+ laptop: { environment: "forest", glow: 1.0 },+ phone: { environment: "studio", glow: 2.0 },+ iphone: { environment: "studio", glow: 2.0 },+};+export function getDeviceFromModelUrl(modelUrl: string | undefined): DeviceKey {if (!modelUrl) return "phone";if (modelUrl.includes("iphone")) return "iphone";diff --git a/lib/viewer-controls3d.ts b/lib/viewer-controls3d.tsindex d6afdf0..2f26cac 100644--- a/lib/viewer-controls3d.ts+++ b/lib/viewer-controls3d.ts@@ -8,13 +8,25 @@ interface ViewerControlsOptions {defaultGlow?: number;}-export function ViewerControls3D({ defaultEnvironment = "studio", defaultGlow = 1.0 }: ViewerControlsOptions = {}) {+const ENVIRONMENT_OPTIONS = [+ 'sunset', 'dawn', 'night', 'warehouse', 'forest',+ 'apartment', 'studio', 'city', 'park', 'lobby',+] as const;++ interface Viewer3DControls {+ autoRotate: boolean;+ rotationSpeed: number;+ glow: number;+ environment: EnvironmentPreset;+ }++export function ViewerControls3D({ defaultEnvironment = "studio", defaultGlow = 1.0 }: ViewerControlsOptions = {}): Viewer3DControls {const [controls, set] = useControls("Configuration 3D", () => ({autoRotate: false,rotationSpeed: { value: 3.5, min: 0.1, max: 10, step: 0.1 },glow: { value: defaultGlow, min: 0.0, max: 5.0, step: 0.1 },environment: {- options: ['sunset', 'dawn', 'night', 'warehouse', 'forest', 'apartment', 'studio', 'city', 'park', 'lobby'],+ options: ENVIRONMENT_OPTIONS,value: defaultEnvironment}}));@@ -23,5 +35,5 @@ export function ViewerControls3D({ defaultEnvironment = "studio", defaultGlow =set({ environment: defaultEnvironment, glow: defaultGlow });}, [defaultEnvironment, defaultGlow, set]);- return controls;+ return controls as Viewer3DControls;}\ No newline at end of file