feat(transcode): add 3D asset support and turntable viewer (#454)

* 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
This commit is contained in:
Yiling-J
2026-10-11 21:32:28 +08:00
committed by GitHub
parent e894457275
commit 43a2eced75
68 changed files with 5548 additions and 59 deletions
+115
View File
@@ -513,6 +513,121 @@ describe('Share API', () => {
expect(body.media.hls).toBeUndefined()
})
test('serves watermarked turntable video for a 3d asset when watermark enabled and completed', async () => {
vi.spyOn(shareService, 'verifyPublicAccess').mockResolvedValue(shareLinkWithWatermark)
const asset3d = {
id: 'file1',
name: 'model.glb',
sizeByte: 1024,
fileCount: 0,
type: 'file',
status: 'processed',
proxyType: '3d',
media: {
proxyType: '3d',
videoPreview: {
url: 'http://s3/unwatermarked-turntable.mp4',
key: 'files/turntable.mp4',
},
videoTranscodes: [
{
id: 'orig-turntable',
url: 'http://s3/unwatermarked-turntable.mp4',
key: 'files/turntable.mp4',
width: 1080,
height: 1080,
},
],
original: { key: 'files/model.glb' },
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any
vi.spyOn(assetService, 'getAsset').mockResolvedValue(asset3d)
vi.spyOn(watermarkService, 'getCompletedWatermarkMediaMap').mockResolvedValue(
new Map([
[
'file1',
watermarkMediaInfo({
proxyType: '3d',
videoTranscodes: [
{
key: 'files/watermarked-turntable.mp4',
width: 1080,
height: 1080,
resolution: '1080p',
},
],
videoPreview: { key: 'files/watermarked-turntable.mp4', width: 1080, height: 1080 },
}),
],
]),
)
const res = await app.request('/shares/share1/files/file1', {
method: 'GET',
headers: { 'x-share-password': 'pass' },
})
expect(res.status).toBe(200)
const body = await res.json()
expect(body.media.videoTranscodes).toEqual([
{
id: 'files/watermarked-turntable.mp4',
url: 'http://s3/presigned',
key: 'files/watermarked-turntable.mp4',
width: 1080,
height: 1080,
size: 0,
resolution: '1080p',
},
])
expect(body.media.videoPreview?.url).toBe('http://s3/presigned')
expect(body.media.videoPreview?.key).toBe('files/watermarked-turntable.mp4')
})
test('strips videoPreview url and serves empty videoTranscodes for a 3d asset while watermark is in flight', async () => {
vi.spyOn(shareService, 'verifyPublicAccess').mockResolvedValue(shareLinkWithWatermark)
const asset3d = {
id: 'file1',
name: 'model.glb',
sizeByte: 1024,
fileCount: 0,
type: 'file',
status: 'processed',
proxyType: '3d',
media: {
proxyType: '3d',
videoPreview: {
url: 'http://s3/unwatermarked-turntable.mp4',
key: 'files/turntable.mp4',
},
videoTranscodes: [
{
id: 'orig-turntable',
url: 'http://s3/unwatermarked-turntable.mp4',
key: 'files/turntable.mp4',
width: 1080,
height: 1080,
},
],
original: { key: 'files/model.glb' },
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any
vi.spyOn(assetService, 'getAsset').mockResolvedValue(asset3d)
vi.spyOn(watermarkService, 'getCompletedWatermarkMediaMap').mockResolvedValue(new Map())
const res = await app.request('/shares/share1/files/file1', {
method: 'GET',
headers: { 'x-share-password': 'pass' },
})
expect(res.status).toBe(200)
const body = await res.json()
expect(body.media.videoTranscodes).toEqual([])
expect(body.media.videoPreview?.url).toBeUndefined()
})
test('leaves non-video/image media untouched when watermark enabled', async () => {
vi.spyOn(shareService, 'verifyPublicAccess').mockResolvedValue(shareLinkWithWatermark)
vi.spyOn(assetService, 'getAsset').mockResolvedValue({