From e49c70b8524311ccfe0aa21e41b320916bb74368 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Wed, 13 May 2026 20:14:04 +0700 Subject: [PATCH] styling updates --- .../src/pages/pagescene/pagescene.tsx | 7 ++- .../apps/artcraft-webapp/tailwind.config.js | 3 + .../components/pagescene/src/lib/Stage3D.tsx | 15 ++++- .../pagescene/src/lib/Stage3DBody.tsx | 16 ++++- .../ControlPanelSceneObject.tsx | 30 ++++----- .../src/lib/comps/Controls3D/Controls3D.tsx | 38 +++++++----- .../comps/ControlsTopButtons/Help/Help.tsx | 61 +++++++++++++++++-- .../lib/comps/DragComponent/DragComponent.tsx | 19 +++++- 8 files changed, 145 insertions(+), 44 deletions(-) diff --git a/frontend/apps/artcraft-webapp/src/pages/pagescene/pagescene.tsx b/frontend/apps/artcraft-webapp/src/pages/pagescene/pagescene.tsx index 711646dcdc..8035d4315d 100644 --- a/frontend/apps/artcraft-webapp/src/pages/pagescene/pagescene.tsx +++ b/frontend/apps/artcraft-webapp/src/pages/pagescene/pagescene.tsx @@ -86,7 +86,12 @@ export default function PageScene() { className="relative h-full w-full overflow-hidden" style={{ transform: "translateZ(0)" }} > - + ); } diff --git a/frontend/apps/artcraft-webapp/tailwind.config.js b/frontend/apps/artcraft-webapp/tailwind.config.js index a91aa10c6e..cdcf30800d 100644 --- a/frontend/apps/artcraft-webapp/tailwind.config.js +++ b/frontend/apps/artcraft-webapp/tailwind.config.js @@ -167,6 +167,9 @@ module.exports = { divider: "#272727", modal: "#1F1F1F", }, + "axis-x": "#D33242", + "axis-y": "#308752", + "axis-z": "#2E70FF", }, }, plugins: [], diff --git a/frontend/libs/components/pagescene/src/lib/Stage3D.tsx b/frontend/libs/components/pagescene/src/lib/Stage3D.tsx index 4c30d91a95..8a628c90f1 100644 --- a/frontend/libs/components/pagescene/src/lib/Stage3D.tsx +++ b/frontend/libs/components/pagescene/src/lib/Stage3D.tsx @@ -26,6 +26,14 @@ export interface Stage3DProps { /** Called on unmount with the serialized scene JSON. The host * decides where to put it (tab store, localStorage, nowhere). */ onSceneSerialized?: (json: string) => void; + /** Show the bottom-right "Costs" cost-calculator button. Defaults + * to true so existing hosts (Tauri) keep their current chrome; + * hosts can opt out (e.g. the webapp suppresses it). */ + showCostCalculator?: boolean; + /** Show the top-bar "Create 3D model from image" magic-wand + * shortcut. Defaults to true; hosts without an Image-to-3D + * destination (e.g. the webapp) can hide it. */ + showImageTo3DButton?: boolean; } export const Stage3D = ({ @@ -33,6 +41,8 @@ export const Stage3D = ({ sceneToken, cacheJsonString, onSceneSerialized, + showCostCalculator = true, + showImageTo3DButton = true, }: Stage3DProps) => { // Engine's remountEngine() gate reads is3DPageMounted. With Stage3D // mounting only when the host's tab/route puts us on screen, the @@ -52,7 +62,10 @@ export const Stage3D = ({ cacheJsonString={cacheJsonString} onSceneSerialized={onSceneSerialized} > - + diff --git a/frontend/libs/components/pagescene/src/lib/Stage3DBody.tsx b/frontend/libs/components/pagescene/src/lib/Stage3DBody.tsx index 567f2d6a20..a3c531f3e1 100644 --- a/frontend/libs/components/pagescene/src/lib/Stage3DBody.tsx +++ b/frontend/libs/components/pagescene/src/lib/Stage3DBody.tsx @@ -57,7 +57,17 @@ import type { MediaItem } from "./models/assets"; const PAGE_ID: ModelPage = ModelPage.Stage3D; -export const Stage3DBody = () => { +export interface Stage3DBodyProps { + /** Show the bottom-right "Costs" cost-calculator button. */ + showCostCalculator?: boolean; + /** Show the top-bar "Create 3D model from image" magic-wand button. */ + showImageTo3DButton?: boolean; +} + +export const Stage3DBody = ({ + showCostCalculator = true, + showImageTo3DButton = true, +}: Stage3DBodyProps = {}) => { const camAspect = usePageSceneStore((s) => s.cameraAspectRatio); const outlinerShowing = usePageSceneStore((s) => s.outlinerShowing); const editorLoader = usePageSceneStore((s) => s.editorLoader); @@ -341,7 +351,7 @@ export const Stage3DBody = () => { >
- +
@@ -416,7 +426,7 @@ export const Stage3DBody = () => { />
- + {showCostCalculator && }
diff --git a/frontend/libs/components/pagescene/src/lib/comps/ControlPanelSceneObject/ControlPanelSceneObject.tsx b/frontend/libs/components/pagescene/src/lib/comps/ControlPanelSceneObject/ControlPanelSceneObject.tsx index 375abd925e..41e22641a5 100644 --- a/frontend/libs/components/pagescene/src/lib/comps/ControlPanelSceneObject/ControlPanelSceneObject.tsx +++ b/frontend/libs/components/pagescene/src/lib/comps/ControlPanelSceneObject/ControlPanelSceneObject.tsx @@ -25,10 +25,7 @@ import { objectMismatch } from "./utils/objectMismatch"; import { XYZ } from "../../datastructures/common"; import { useViewportSize } from "../../hooks/useViewportSize"; import { DraggablePrecisionMutator } from "./DraggablePrecisionMutator"; -import { - beginColorSession, - ColorSession, -} from "../../actions/setObjectColor"; +import { beginColorSession, ColorSession } from "../../actions/setObjectColor"; import { beginTransformSession, TransformSession, @@ -161,7 +158,9 @@ export const ControlPanelSceneObject = () => { setLocalRotation(engineToLocal(vectors.rotation)); setLocalScale(engineToLocal(vectors.scale)); - setLocked(editorEngine.selection.isObjectLocked(editorEngine?.selected?.uuid || "")); + setLocked( + editorEngine.selection.isObjectLocked(editorEngine?.selected?.uuid || ""), + ); setColor(editorEngine?.selected?.userData.color); // No cleanup function — uuid-change commit lives in the body // above. Unmount commit is handled by the separate effect below. @@ -327,7 +326,7 @@ export const ControlPanelSceneObject = () => { className={"flex flex-col gap-2 overflow-y-auto"} >
-
Color
+

Color

{ // close. const uuid = editorEngine?.selected?.uuid; if (uuid && editorEngine) { - colorSessionRef.current = beginColorSession( - editorEngine, - uuid, - ); + colorSessionRef.current = beginColorSession(editorEngine, uuid); } }} onChange={(e: ChangeEvent) => { @@ -361,15 +357,15 @@ export const ControlPanelSceneObject = () => { }} />
-
-
Location
+
+

Location

{ />
-
-
Rotation
+
+

Rotation

{ />
-
+
-
Scale
+

Scale

{ +export interface Controls3DProps { + /** Show the magic-wand "Create 3D model from image" shortcut next + * to the add-asset button. */ + showImageTo3DButton?: boolean; +} + +export const Controls3D = ({ + showImageTo3DButton = true, +}: Controls3DProps = {}) => { useSignals(); const editor = useContext(EngineContext); const { @@ -241,19 +249,21 @@ export const Controls3D = () => { />
- -
| diff --git a/frontend/libs/components/pagescene/src/lib/comps/ControlsTopButtons/Help/Help.tsx b/frontend/libs/components/pagescene/src/lib/comps/ControlsTopButtons/Help/Help.tsx index 9a563c9ab8..5d66e21ccd 100644 --- a/frontend/libs/components/pagescene/src/lib/comps/ControlsTopButtons/Help/Help.tsx +++ b/frontend/libs/components/pagescene/src/lib/comps/ControlsTopButtons/Help/Help.tsx @@ -37,20 +37,71 @@ export const KeyGroup = (props: { children: React.ReactNode }) => (
{props.children}
); +// Inline SVG instead of /resources/icons/mouse_*.png. The PNGs only +// ship with the Tauri host's public dir, so the webapp host showed a +// broken-image placeholder. Inlining keeps the lib self-contained and +// renders identically across both apps. export const Mouse = (props: { button: "left" | "middle" | "right"; label?: string; }) => (
- {`${props.button} + {props.label}
); +const MouseIcon = ({ active }: { active: "left" | "middle" | "right" }) => ( + + + {active === "left" && ( + + )} + {active === "right" && ( + + )} + + + +); + export const Plus = () =>
+
; const ShortcutsView = () => ( diff --git a/frontend/libs/components/pagescene/src/lib/comps/DragComponent/DragComponent.tsx b/frontend/libs/components/pagescene/src/lib/comps/DragComponent/DragComponent.tsx index 056197a637..cca71f7a55 100644 --- a/frontend/libs/components/pagescene/src/lib/comps/DragComponent/DragComponent.tsx +++ b/frontend/libs/components/pagescene/src/lib/comps/DragComponent/DragComponent.tsx @@ -1,5 +1,14 @@ +import { createPortal } from "react-dom"; import { usePageSceneStore } from "../../PageSceneStore"; +// Portaled to so the chip stays anchored to the page (using the +// document-coord pageX/pageY values stored in dragPosition) regardless +// of any positioned/`transform`ed ancestor the host wraps Stage3D in. +// Without the portal, hosts whose Stage3D wrapper is a containing +// block (e.g. the webapp's wrapper uses `transform: translateZ(0)` to +// scope the lib's fixed overlays) push the chip away from the cursor +// by the wrapper's offset. Tauri has no such wrapper so the portal is +// a no-op for it. export const DragComponent = () => { const dragItem = usePageSceneStore((s) => s.dragItem); const dragPosition = usePageSceneStore((s) => s.dragPosition); @@ -7,15 +16,18 @@ export const DragComponent = () => { if (!dragItem) { return null; } + if (typeof document === "undefined") { + return null; + } const { currX, currY } = dragPosition; const thumbnail = dragItem.thumbnail ? dragItem.thumbnail : `/resources/images/default-covers/${dragItem.imageIndex || 0}.webp`; - return ( + return createPortal(
{
{dragItem.name || dragItem.media_id}
-
+
, + document.body, ); };