Create professional demos and 3D mockups in seconds, directly in your browser
feat: update Motion3DApplicator to reset base transform on baseRotationZ change
CristianOlivera1bdd38af00252
diff --git a/app/components/ui/editor/mockups-3d/Mockup3DStage.tsx b/app/components/ui/editor/mockups-3d/Mockup3DStage.tsxindex 358d860..8916e0d 100644--- a/app/components/ui/editor/mockups-3d/Mockup3DStage.tsx+++ b/app/components/ui/editor/mockups-3d/Mockup3DStage.tsx@@ -68,18 +68,23 @@ function Motion3DApplicator({rootRef,motionTransform,device,+ baseRotationZ,}: {rootRef: React.MutableRefObject<THREE.Group | null>;motionTransform: Mockup3DMotionTransform;device: ImageDeviceId;+ baseRotationZ: number;}) {const baseRef = useRef<{ rx: number; ry: number; rz: number; sx: number; sy: number; sz: number; px: number; py: number; pz: number } | null>(null);- // Reset the captured base transform whenever the device changes so the- // new model's own scale/rotation/position is re-captured fresh.+ // Reset the captured base transform whenever the device OR the target+ // base rotationZ changes. Without the second dependency, this ref stays+ // frozen at whatever rotation.z the model had at mount time, and every+ // useFrame tick below overwrites root.rotation.z back to that stale+ // value — silently undoing any rotateZ slider change made afterward.useEffect(() => {baseRef.current = null;- }, [device]);+ }, [device, baseRotationZ]);useEffect(() => {const root = rootRef.current;@@ -180,7 +185,7 @@ export function Mockup3DStage({ device, rootRef: externalRootRef, cameraRef: exthandleMount(gl.domElement);}}>- <Motion3DApplicator rootRef={rootRef} motionTransform={props.motionTransform ?? REST_MOCKUP_3D_MOTION} device={device} />+ <Motion3DApplicator rootRef={rootRef} motionTransform={props.motionTransform ?? REST_MOCKUP_3D_MOTION} device={device} baseRotationZ={props.initialRotationZ ?? 0} /><Suspense fallback={null}>{device === "iphone-13-pro-max" && (<IPhone13ProMaxScene {...props} rootRef={rootRef} cameraRef={cameraRef} onLoaded={markLoaded} />