mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-25 16:19:20 +00:00
* feat(transcode): add 3D asset support and turntable viewer * perf(turntable): stream file via Bun.file and increase upload timeout * feat(turntable): increase upload timeout to 15m to support 5GB uploads * fix(webui): align 3D model viewer layout and full-width control bar with video viewer * feat(webui): unify 3D viewer bottom bar and redesign cyclic ruler slider - Place RulerSlider in single row with playback and zoom controls, centered with max 320px width - Flank RulerSlider with minus and plus buttons to step angle by 15° - Redesign RulerSlider with fixed center indicator and moving cyclic track with continuous 360° wrapping - Render major ticks longer at 60° intervals without numeric text labels on track - Display floating degree tooltip above center indicator only during dragging * fix(webui): prevent RulerSlider from collapsing to 0px width in control bar - Use flex layout with flex-1 on left and right clusters to preserve center cluster width - Enforce min-w-[140px] and w-full on RulerSlider - Fix tooltip positioning and remove outer overflow-hidden * feat(webui): snap RulerSlider track directly to discrete 15° ticks during drag * fix(webui): prevent ruler snap-back caused by floating point second truncation - Use Math.round instead of Math.floor in secondToDegree to avoid 0.999996 dropping to previous frame - Ensure final dragDegree is committed on pointer up * fix(webui): fix arrow key frame rounding and duplicate event bubbling - Use Math.round instead of Math.floor for keyboard arrow frame navigation in ModelViewer - Add e.stopPropagation() to RulerSlider keyboard events to prevent duplicate bubbling to window listener * feat(webui): redesign RulerSlider with encapsulated step buttons and capsule pill track * feat(webui): make RulerSlider responsive on mobile and remove bottom bar reset button * fix(webui): load 3d video directly without poster and invert drag rotation to counterclockwise * fix(webui): fix 3d asset viewer frame seeking and drag jitter * feat(transcode): show 3D asset poster preview immediately after render start * fix(viewer): synchronize 3D turntable playback via frame callback to prevent skipped degrees * fix(viewer): handle touchpad zoom gestures and prevent page zoom in 3D viewer * fix(viewer): eliminate 3D model rotation jitter at 345 degrees * fix(share): watermark 3D asset turntable video on share links * fix(share): preserve video transcode resolution on watermarked share links * fix(viewer): download original 3D model file instead of rendered turntable MP4
132 lines
4.9 KiB
TypeScript
132 lines
4.9 KiB
TypeScript
import React from 'react'
|
|
import { Play, Pause, Maximize, Minimize, Minus, Plus, Download } from 'lucide-react'
|
|
import { cn } from '@/ui/lib/utils'
|
|
import { RulerSlider } from './ruler-slider'
|
|
|
|
export interface ModelControlBarProps {
|
|
isPlaying: boolean
|
|
currentDegree: number
|
|
zoom: number
|
|
isFullScreen: boolean
|
|
allowDownload?: boolean
|
|
onDownload?: () => void
|
|
togglePlay: () => void
|
|
onSeekDegree: (degree: number) => void
|
|
onZoomChange: (zoom: number) => void
|
|
onZoomReset: () => void
|
|
toggleFullScreen: () => void
|
|
}
|
|
|
|
export const ModelControlBar: React.FC<ModelControlBarProps> = ({
|
|
isPlaying,
|
|
currentDegree,
|
|
zoom,
|
|
isFullScreen,
|
|
allowDownload = true,
|
|
onDownload,
|
|
togglePlay,
|
|
onSeekDegree,
|
|
onZoomChange,
|
|
onZoomReset,
|
|
toggleFullScreen,
|
|
}) => {
|
|
return (
|
|
<div
|
|
className={cn(
|
|
'transition-all duration-300 ease-in-out z-20 text-foreground',
|
|
isFullScreen
|
|
? 'absolute bottom-0 left-0 right-0 px-2 py-2 sm:px-4 sm:py-2.5 bg-card/90 backdrop-blur-md border-t border-border'
|
|
: 'relative w-full bg-card border-t border-border px-2 py-2 sm:px-4 sm:py-2.5 z-10 transition-colors duration-200',
|
|
)}
|
|
>
|
|
{/* Unified Single Row Controls */}
|
|
<div className="flex items-center justify-between text-foreground gap-1.5 sm:gap-3 md:gap-4">
|
|
{/* Left Side: Play/Pause, Degree Readout */}
|
|
<div className="flex items-center gap-1.5 sm:gap-3 justify-start min-w-0 flex-1">
|
|
<button
|
|
type="button"
|
|
onClick={togglePlay}
|
|
aria-label={isPlaying ? 'Pause' : 'Play'}
|
|
className="hover:text-primary transition-colors shrink-0 p-0.5 sm:p-1"
|
|
data-testid="play-toggle"
|
|
data-playing={isPlaying}
|
|
>
|
|
{isPlaying ? (
|
|
<Pause className="w-4 h-4 sm:w-5 sm:h-5 fill-current" />
|
|
) : (
|
|
<Play className="w-4 h-4 sm:w-5 sm:h-5 fill-current" />
|
|
)}
|
|
</button>
|
|
|
|
<div
|
|
className="flex items-center text-xs sm:text-sm font-medium tabular-nums select-none shrink-0"
|
|
data-testid="degree-readout"
|
|
>
|
|
<span className="text-muted-foreground font-mono">{currentDegree}° / 360°</span>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Center: RulerSlider with encapsulated minus & plus buttons */}
|
|
<div className="flex items-center w-full max-w-[130px] sm:max-w-[220px] md:max-w-[320px] justify-center mx-auto shrink min-w-0">
|
|
<RulerSlider currentDegree={currentDegree} onChange={onSeekDegree} className="w-full" />
|
|
</div>
|
|
|
|
{/* Right Side: Zoom controls, Download, Fullscreen */}
|
|
<div className="flex items-center gap-1 sm:gap-2 justify-end min-w-0 flex-1">
|
|
{/* Zoom controls */}
|
|
<div className="flex items-center gap-0.5 sm:gap-1 bg-muted/60 rounded-lg p-0.5 border border-border/40 shrink-0">
|
|
<button
|
|
type="button"
|
|
onClick={() => onZoomChange(Math.max(0.2, zoom - 0.2))}
|
|
aria-label="Zoom out"
|
|
className="p-1 rounded hover:bg-background/80 text-muted-foreground hover:text-foreground transition-colors"
|
|
>
|
|
<Minus className="w-3.5 h-3.5" />
|
|
</button>
|
|
<button
|
|
type="button"
|
|
onClick={onZoomReset}
|
|
aria-label="Reset zoom"
|
|
className="px-1 sm:px-1.5 py-0.5 text-[10px] sm:text-[11px] font-mono text-muted-foreground hover:text-foreground transition-colors"
|
|
>
|
|
{Math.round(zoom * 100)}%
|
|
</button>
|
|
<button
|
|
type="button"
|
|
onClick={() => onZoomChange(Math.min(5, zoom + 0.2))}
|
|
aria-label="Zoom in"
|
|
className="p-1 rounded hover:bg-background/80 text-muted-foreground hover:text-foreground transition-colors"
|
|
>
|
|
<Plus className="w-3.5 h-3.5" />
|
|
</button>
|
|
</div>
|
|
|
|
{/* Download */}
|
|
{allowDownload && onDownload && (
|
|
<button
|
|
type="button"
|
|
onClick={onDownload}
|
|
title="Download asset"
|
|
aria-label="Download asset"
|
|
className="p-1 sm:p-1.5 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors shrink-0"
|
|
>
|
|
<Download className="w-4 h-4" />
|
|
</button>
|
|
)}
|
|
|
|
{/* Fullscreen */}
|
|
<button
|
|
type="button"
|
|
onClick={toggleFullScreen}
|
|
title={isFullScreen ? 'Exit fullscreen' : 'Fullscreen'}
|
|
aria-label={isFullScreen ? 'Exit fullscreen' : 'Fullscreen'}
|
|
className="p-1 sm:p-1.5 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors shrink-0"
|
|
>
|
|
{isFullScreen ? <Minimize className="w-4 h-4" /> : <Maximize className="w-4 h-4" />}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|