styling updates

This commit is contained in:
bflatastic committed 2026-05-13 20:14:04 +07:00
1 parent 076552fda4
commit e49c70b852
8 files changed
+145 -44

No files matched your search

@@ -86,7 +86,12 @@ export default function PageScene() {
className="relative h-full w-full overflow-hidden"
style={{ transform: "translateZ(0)" }}
>
<Stage3D adapter={adapter} sceneToken={sceneToken} />
<Stage3D
adapter={adapter}
sceneToken={sceneToken}
showCostCalculator={false}
showImageTo3DButton={false}
/>
</div>
);
}
@@ -167,6 +167,9 @@ module.exports = {
divider: "#272727",
modal: "#1F1F1F",
},
"axis-x": "#D33242",
"axis-y": "#308752",
"axis-z": "#2E70FF",
},
},
plugins: [],
@@ -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}
>
<Stage3DBody />
<Stage3DBody
showCostCalculator={showCostCalculator}
showImageTo3DButton={showImageTo3DButton}
/>
<DragComponent />
<PrecisionSelector />
<EditorLoadingBar />
@@ -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 = () => {
>
<div className="grid grid-cols-3 gap-4">
<ControlsTopButtons />
<Controls3D />
<Controls3D showImageTo3DButton={showImageTo3DButton} />
</div>
</div>
@@ -416,7 +426,7 @@ export const Stage3DBody = () => {
/>
</div>
<div className="absolute bottom-6 right-6 z-20 flex items-center gap-2">
<CostCalculatorButton modelPage={PAGE_ID} />
{showCostCalculator && <CostCalculatorButton modelPage={PAGE_ID} />}
<HelpMenuButton />
</div>
</div>
@@ -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"}
>
<div className="flex flex-col gap-1">
<h5>Color</h5>
<p className="font-semibold text-sm">Color</p>
<input
className="h-0 w-0 cursor-pointer opacity-0"
id={colorInputId}
@@ -341,10 +340,7 @@ export const ControlPanelSceneObject = () => {
// close.
const uuid = editorEngine?.selected?.uuid;
if (uuid && editorEngine) {
colorSessionRef.current = beginColorSession(
editorEngine,
uuid,
);
colorSessionRef.current = beginColorSession(editorEngine, uuid);
}
}}
onChange={(e: ChangeEvent<HTMLInputElement>) => {
@@ -361,15 +357,15 @@ export const ControlPanelSceneObject = () => {
}}
/>
<Button
className="cursor-pointer p-3.5"
className="cursor-pointer p-3.5 w-full"
htmlFor={colorInputId}
style={{
backgroundColor: color,
}}
></Button>
</div>
<div className="flex flex-col gap-1">
<h5>Location</h5>
<div className="flex flex-col gap-2">
<p className="font-semibold text-sm">Location</p>
<InputVector
x={localPosition.x.toString()}
y={localPosition.y.toString()}
@@ -381,8 +377,8 @@ export const ControlPanelSceneObject = () => {
/>
</div>
<div className="flex flex-col gap-1">
<h5>Rotation</h5>
<div className="flex flex-col gap-2">
<p className="font-semibold text-sm">Rotation</p>
<InputVector
x={localRotation.x.toString()}
y={localRotation.y.toString()}
@@ -395,9 +391,9 @@ export const ControlPanelSceneObject = () => {
/>
</div>
<div className="mb-1 flex flex-col gap-1">
<div className="mb-1 flex flex-col gap-2">
<DraggablePrecisionMutator onChange={handleUniformScaleChange}>
<h5>Scale</h5>
<p className="font-semibold text-sm">Scale</p>
</DraggablePrecisionMutator>
<InputVector
x={localScale.x.toString()}
@@ -31,7 +31,15 @@ import {
} from "../../PageSceneStore";
import { AssetModal } from "../AssetMenu";
export const Controls3D = () => {
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 = () => {
/>
</Tooltip>
</div>
<Tooltip
content="Create 3D model from image"
position="bottom"
delay={300}
closeOnClick
>
<Button
icon={faMagicWandSparkles}
className="text-md h-9 w-9 rounded-[10px] bg-white/15 transition-colors hover:bg-white/25"
variant="secondary"
onClick={handleOpenCreate3dModal}
/>
</Tooltip>
{showImageTo3DButton && (
<Tooltip
content="Create 3D model from image"
position="bottom"
delay={300}
closeOnClick
>
<Button
icon={faMagicWandSparkles}
className="text-md h-9 w-9 rounded-[10px] bg-white/15 transition-colors hover:bg-white/25"
variant="secondary"
onClick={handleOpenCreate3dModal}
/>
</Tooltip>
)}
</div>
<span className="opacity-20">|</span>
@@ -37,20 +37,71 @@ export const KeyGroup = (props: { children: React.ReactNode }) => (
<div className="flex gap-1">{props.children}</div>
);
// 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;
}) => (
<div className="flex items-center gap-2.5">
<img
alt={`${props.button} mouse`}
src={`/resources/icons/mouse_${props.button === "left" ? "lmb" : props.button === "middle" ? "mmb" : "rmb"}.png`}
className="h-7 w-auto object-contain"
/>
<MouseIcon active={props.button} />
<span className="text-sm font-normal opacity-60">{props.label}</span>
</div>
);
const MouseIcon = ({ active }: { active: "left" | "middle" | "right" }) => (
<svg
viewBox="0 0 20 28"
aria-hidden
className="h-7 w-auto text-white"
>
<rect
x="1.25"
y="1.25"
width="17.5"
height="25.5"
rx="8.75"
ry="11"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
opacity="0.85"
/>
{active === "left" && (
<path
d="M9 1.75 V12 H1.5 V10 A8.5 8.5 0 0 1 9 1.75 Z"
fill="currentColor"
/>
)}
{active === "right" && (
<path
d="M11 1.75 V12 H18.5 V10 A8.5 8.5 0 0 0 11 1.75 Z"
fill="currentColor"
/>
)}
<rect
x="9"
y="4"
width="2"
height="5"
rx="1"
fill="currentColor"
opacity={active === "middle" ? "1" : "0.5"}
/>
<line
x1="1.5"
y1="12"
x2="18.5"
y2="12"
stroke="currentColor"
strokeWidth="0.75"
opacity="0.4"
/>
</svg>
);
export const Plus = () => <div className="text-xl font-medium">+</div>;
const ShortcutsView = () => (
@@ -1,5 +1,14 @@
import { createPortal } from "react-dom";
import { usePageSceneStore } from "../../PageSceneStore";
// Portaled to <body> 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(
<div
className="absolute rounded-lg"
className="pointer-events-none absolute rounded-lg"
style={{
width: 91,
height: 114,
@@ -35,6 +47,7 @@ export const DragComponent = () => {
<div className="w-full truncate rounded-b-lg bg-ui-controls px-2 py-1 text-center text-[12px]">
{dragItem.name || dragItem.media_id}
</div>
</div>
</div>,
document.body,
);
};