Skip to content

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

feat: remove bug

CristianOlivera13bb8273b3d69
diff --git a/app/components/ui/editor/Phone3DViewer.tsx b/app/components/ui/editor/Phone3DViewer.tsx
index b8f694a..ea28a39 100644
--- a/app/components/ui/editor/Phone3DViewer.tsx
+++ b/app/components/ui/editor/Phone3DViewer.tsx
@@ -105,7 +105,6 @@ function ModelScene({
const lastLoadedCropKeyRef = useRef<string | null>(null);
const screenAspectRef = useRef<number>(0.459);
const flipYRef = useRef<boolean>(false);
- const prevRotationRef = useRef({ x: initialRotationX, y: initialRotationY });
const { autoRotate, rotationSpeed, glow, environment } = ViewerControls3D();
@@ -398,13 +397,6 @@ function ModelScene({
}, [modelUrl]);
useEffect(() => {
- // Skip if values haven't changed (e.g. OrbitControls echoed back the
- // same angles via onRotationChange → context → props round-trip).
- if (
- prevRotationRef.current.x === initialRotationX &&
- prevRotationRef.current.y === initialRotationY
- ) return;
- prevRotationRef.current = { x: initialRotationX, y: initialRotationY };
const orbit = orbitRef.current;
if (!orbit) return;
const radius = 1.5 / zoom;
@@ -519,63 +511,54 @@ export function Phone3DViewer(props: Props) {
<>
<ControlsPopup />
- {/*
- * IMPORTANT: this wrapper must NOT add any layout footprint to the
- * parent container. The parent overlay in VideoCanvas uses
- * `translate(-50%, -50%)` which is relative to the element's own
- * bounding box. By making this wrapper `position:absolute` with its
- * own `translate(-50%,-50%)` we give the parent a zero-size anchor
- * point and eliminate the jump caused by large margins / shadow
- * height that used to inflate the parent box.
- */}
<div
style={{
- position: "absolute",
- top: 0,
- left: 0,
- transform: "translate(-50%, -50%)",
- transformOrigin: "center center",
+ display: "inline-block",
+ transformOrigin: "top center",
width: PHONE_W,
- height: PHONE_H,
- pointerEvents: "none",
+ height: PHONE_H + (hasShadow ? computedBlur * 0.8 : 0),
+ marginTop: "220px",
+ marginLeft: "140px",
}}
>
- {hasShadow && (
+ <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
- 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 {...props} rootRef={rootRef} cameraRef={cameraRef} />
+ onPointerDown={() => setGrabbing(true)}
+ onPointerUp={() => setGrabbing(false)}
+ onPointerLeave={() => setGrabbing(false)}
+ >
+ <CanvasWithLoader {...props} rootRef={rootRef} cameraRef={cameraRef} />
+ </div>
</div>
</div>
</>