Skip to content

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

feat: add backgroundColorCss prop to ControlPanel and update related components

CristianOlivera1c043bbbff3f3
diff --git a/app/[locale]/(editor)/editor/page.tsx b/app/[locale]/(editor)/editor/page.tsx
index ec351e1..d093bbc 100644
--- a/app/[locale]/(editor)/editor/page.tsx
+++ b/app/[locale]/(editor)/editor/page.tsx
@@ -3056,6 +3056,7 @@ export default function Editor() {
onImageSelect={handleImageSelect}
onImageRemove={handleImageRemove}
backgroundColorConfig={backgroundColorConfig}
+ backgroundColorCss={backgroundColorCss}
onBackgroundColorChange={handleBackgroundColorChange}
onTogglePanel={() => setIsControlPanelOpen(!isControlPanelOpen)}
isOpen={isControlPanelOpen}
diff --git a/app/components/ui/editor/ControlPanel.tsx b/app/components/ui/editor/ControlPanel.tsx
index bf61343..95e42cb 100644
--- a/app/components/ui/editor/ControlPanel.tsx
+++ b/app/components/ui/editor/ControlPanel.tsx
@@ -57,6 +57,7 @@ export function ControlPanel({
uploadedImages,
selectedImageUrl,
backgroundColorConfig,
+ backgroundColorCss,
onBackgroundTabChange,
onWallpaperSelect,
onBackgroundBlurChange,
@@ -286,6 +287,7 @@ export function ControlPanel({
backgroundTab={backgroundTab}
selectedWallpaper={selectedWallpaper}
selectedImageUrl={selectedImageUrl}
+ backgroundColorCss={backgroundColorCss}
initialPage={initialMockupMenuPage}
mediaType={mediaType}
/>
diff --git a/app/components/ui/editor/mockups-3d/DoubleIPhone3DViewer.tsx b/app/components/ui/editor/mockups-3d/DoubleIPhone3DViewer.tsx
index f910dce..453261a 100644
--- a/app/components/ui/editor/mockups-3d/DoubleIPhone3DViewer.tsx
+++ b/app/components/ui/editor/mockups-3d/DoubleIPhone3DViewer.tsx
@@ -395,6 +395,7 @@ function CanvasWithLoader(
failIfMajorPerformanceCaveat: false,
}}
dpr={3}
+ resize={{ scroll: false, debounce: { scroll: 0, resize: 0 } }}
onCreated={({ gl, scene }) => {
gl.outputColorSpace = THREE.SRGBColorSpace;
gl.toneMapping = THREE.NeutralToneMapping;
diff --git a/app/components/ui/editor/mockups-3d/IPhone13ProMax3DViewer.tsx b/app/components/ui/editor/mockups-3d/IPhone13ProMax3DViewer.tsx
index 12adf14..fc5295a 100644
--- a/app/components/ui/editor/mockups-3d/IPhone13ProMax3DViewer.tsx
+++ b/app/components/ui/editor/mockups-3d/IPhone13ProMax3DViewer.tsx
@@ -132,7 +132,7 @@ function ModelScene({
shadowIntensity?: number;
shadowColor?: string;
}) {
- const { gl, scene, camera } = useThree();
+ const { gl, scene, camera, invalidate } = useThree();
const gltf = useGLTF("/models/apple_iphone_13_pro_max.glb") as unknown as {
nodes: GLTFNodes;
materials: GLTFMaterials;
@@ -327,6 +327,7 @@ function ModelScene({
tex.anisotropy = gl.capabilities.getMaxAnisotropy();
mat.map = tex;
mat.needsUpdate = true;
+ invalidate();
lastLoadedImageUrlRef.current = imageUrl;
lastLoadedMaskKeyRef.current = maskKey;
@@ -348,6 +349,7 @@ function ModelScene({
const theta = initialRotationY * DEG;
orbit.object.position.setFromSphericalCoords(radius, phi, theta);
orbit.update();
+ invalidate();
prevRotationRef.current = { x: initialRotationX, y: initialRotationY };
}, 0);
@@ -358,8 +360,9 @@ function ModelScene({
const root = rootRef.current;
if (root) {
root.rotation.z = initialRotationZ * (Math.PI / 180);
+ invalidate();
}
- }, [initialRotationZ]);
+ }, [initialRotationZ, invalidate]);
const shadowT = Math.max(0, Math.min(1, shadowIntensity));
const showContactShadow = shadowT > 0.01;
@@ -373,6 +376,7 @@ function ModelScene({
<Environment
preset={environment as EnvironmentPreset}
environmentIntensity={glow}
+ background={false}
/>
<OrbitControls
@@ -492,6 +496,8 @@ function CanvasWithLoader({
failIfMajorPerformanceCaveat: false,
}}
dpr={3}
+ frameloop={videoElement ? "always" : "demand"}
+ resize={{ scroll: false, debounce: { scroll: 0, resize: 0 } }}
onCreated={({ gl, scene }) => {
gl.outputColorSpace = THREE.SRGBColorSpace;
gl.toneMapping = THREE.NeutralToneMapping;
diff --git a/app/components/ui/editor/mockups-3d/Laptop3DViewer.tsx b/app/components/ui/editor/mockups-3d/Laptop3DViewer.tsx
index 1d39d7e..ee21210 100644
--- a/app/components/ui/editor/mockups-3d/Laptop3DViewer.tsx
+++ b/app/components/ui/editor/mockups-3d/Laptop3DViewer.tsx
@@ -493,6 +493,7 @@ function CanvasWithLoader(props: Props & { rootRef: React.MutableRefObject<THREE
powerPreference: "high-performance"
}}
dpr={Math.min((typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1) * RENDER_MULTIPLIER, 4)}
+ resize={{ scroll: false, debounce: { scroll: 0, resize: 0 } }}
onCreated={({ gl }) => {
gl.setClearColor(0x000000, 0);
gl.outputColorSpace = THREE.SRGBColorSpace;
diff --git a/app/components/ui/editor/mockups-3d/Phone3DViewer.tsx b/app/components/ui/editor/mockups-3d/Phone3DViewer.tsx
index 3aaff19..59a0b88 100644
--- a/app/components/ui/editor/mockups-3d/Phone3DViewer.tsx
+++ b/app/components/ui/editor/mockups-3d/Phone3DViewer.tsx
@@ -553,6 +553,7 @@ function CanvasWithLoader(props: Props & { rootRef: React.MutableRefObject<THREE
failIfMajorPerformanceCaveat: false,
}}
dpr={3}
+ resize={{ scroll: false, debounce: { scroll: 0, resize: 0 } }}
onCreated={({ gl, scene }) => {
gl.outputColorSpace = THREE.SRGBColorSpace;
gl.toneMapping = THREE.NeutralToneMapping;
diff --git a/types/control-panel.types.ts b/types/control-panel.types.ts
index 4d21a0b..3352332 100644
--- a/types/control-panel.types.ts
+++ b/types/control-panel.types.ts
@@ -19,6 +19,7 @@ export interface ControlPanelProps {
uploadedImages: string[];
selectedImageUrl: string;
backgroundColorConfig: BackgroundColorConfig | null;
+ backgroundColorCss?: string;
onBackgroundTabChange: (tab: BackgroundTab) => void;
onWallpaperSelect: (index: number) => void;
onBackgroundBlurChange: (value: number) => void;