mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-22 23:17:37 +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
75 lines
2.5 KiB
TypeScript
75 lines
2.5 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import {
|
|
calculateFrameCenterTime,
|
|
secondToFrame,
|
|
secondToDegree,
|
|
TOTAL_FRAMES,
|
|
FPS,
|
|
FRAME_DURATION,
|
|
} from './utils'
|
|
|
|
describe('model viewer utils', () => {
|
|
describe('calculateFrameCenterTime', () => {
|
|
it('calculates the center time for frame 0', () => {
|
|
expect(calculateFrameCenterTime(0)).toBeCloseTo(0.5 / FPS)
|
|
})
|
|
|
|
it('calculates presentation times safely within frame boundaries for all frames 0 to 23', () => {
|
|
for (let i = 0; i < TOTAL_FRAMES - 1; i++) {
|
|
const center = calculateFrameCenterTime(i)
|
|
expect(center).toBeCloseTo((i + 0.5) * FRAME_DURATION)
|
|
}
|
|
// For the final frame (frame 23, 345°), ensure it is safely offset away from EOF (4.0s)
|
|
const lastCenter = calculateFrameCenterTime(TOTAL_FRAMES - 1)
|
|
expect(lastCenter).toBeCloseTo((TOTAL_FRAMES - 1) * FRAME_DURATION + FRAME_DURATION * 0.25)
|
|
expect(lastCenter).toBeLessThan(TOTAL_FRAMES * FRAME_DURATION)
|
|
})
|
|
|
|
it('handles negative and wrapping frames properly', () => {
|
|
expect(calculateFrameCenterTime(-1)).toBeCloseTo(calculateFrameCenterTime(23))
|
|
expect(calculateFrameCenterTime(24)).toBeCloseTo(calculateFrameCenterTime(0))
|
|
})
|
|
})
|
|
|
|
describe('secondToFrame', () => {
|
|
it('correctly maps frame start times to frame index without float truncation', () => {
|
|
for (let i = 0; i < TOTAL_FRAMES; i++) {
|
|
const startSec = i * FRAME_DURATION
|
|
expect(secondToFrame(startSec)).toBe(i)
|
|
}
|
|
})
|
|
|
|
it('correctly maps frame center times to frame index', () => {
|
|
for (let i = 0; i < TOTAL_FRAMES; i++) {
|
|
const centerSec = calculateFrameCenterTime(i)
|
|
expect(secondToFrame(centerSec)).toBe(i)
|
|
}
|
|
})
|
|
|
|
it('clamps values below 0 and above total duration', () => {
|
|
expect(secondToFrame(-1)).toBe(0)
|
|
expect(secondToFrame(100)).toBe(TOTAL_FRAMES - 1)
|
|
})
|
|
})
|
|
|
|
describe('secondToDegree', () => {
|
|
it('returns 0 for 0s', () => {
|
|
expect(secondToDegree(0)).toBe(0)
|
|
})
|
|
|
|
it('returns exact degrees (0..345) for every frame center', () => {
|
|
for (let i = 0; i < TOTAL_FRAMES; i++) {
|
|
const center = calculateFrameCenterTime(i)
|
|
expect(secondToDegree(center)).toBe((i * 15) % 360)
|
|
}
|
|
})
|
|
|
|
it('returns exact degrees for frame start times', () => {
|
|
for (let i = 0; i < TOTAL_FRAMES; i++) {
|
|
const start = i * FRAME_DURATION
|
|
expect(secondToDegree(start)).toBe((i * 15) % 360)
|
|
}
|
|
})
|
|
})
|
|
})
|