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
@@ -312,6 +312,128 @@ describe.each(['local', 'temporal'] as const)(
expect(mediaInfo?.videoTranscodes?.[0].resolution).toBe('360p')
})
it('should generate watermark proxy for a 3d asset from turntable video and update sharelink status to ready', async () => {
// 1. Seed Database
const team = await prisma.team.create({
data: { name: 'E2E Watermark 3D Team' },
})
const projectFolder = await prisma.asset.create({
data: { name: 'root', type: 'root', status: 'processed' },
})
const project = await prisma.project.create({
data: {
name: 'E2E Watermark 3D Project',
teamId: team.id,
rootFolderId: projectFolder.id,
},
})
const storageKey = await prisma.storageKey.create({
data: { key: 'files/e2e-watermark-3d/model.glb' },
})
const turntableKey = 'files/e2e-watermark-3d/turntable.mp4'
const videoPath = path.join(fixturesDir, 'small.mp4')
const videoBuffer = fs.readFileSync(videoPath)
await s3Service.putObject(
'shumai-e2e-test-bucket-watermark',
turntableKey,
videoBuffer,
videoBuffer.length,
'video/mp4',
)
const asset = await prisma.asset.create({
data: {
name: 'model.glb',
type: 'file',
mediaType: 'model/gltf-binary',
status: 'processed',
projectId: project.id,
storageKeyId: storageKey.id,
media: {
duration: 1,
filesize: videoBuffer.length,
frames: 30,
proxyType: '3d',
imageTranscodes: [],
videoTranscodes: [{ key: turntableKey, width: 640, height: 360, resolution: '360p' }],
videoPreview: { key: turntableKey, width: 640, height: 360, resolution: '360p' },
poster: { key: 'files/e2e-watermark-3d/poster.webp' },
finishedAt: new Date().toISOString(),
metadata: {
originalWidth: 640,
originalHeight: 360,
duration: 1,
bitRate: 0,
frameRate: 30,
totalFrames: 30,
startTimecode: '00:00:00:00',
hasAudio: false,
format: {},
},
original: {
key: storageKey.key,
filesizeInBytes: 100,
codec: '',
},
},
},
})
const shareLink = await shareService.createShareLink(project.id, {
name: 'Public Watermarked 3D Share',
})
await shareService.addAssetToShare(shareLink.id, { assetIds: [asset.id] })
const watermarkConfig: WatermarkConfigSpec = {
blocks: [
{
id: 'b1',
type: 'text',
x: 0.5,
y: 0.5,
opacity: 0.5,
rotation: 0,
text: 'CONFIDENTIAL 3D',
size: 0.2,
color: '#FF0000',
},
],
}
const updatedShare = await watermarkService.updateShareLinkWatermark(
shareLink.id,
true,
watermarkConfig,
)
expect(updatedShare.watermarkStatus).toBe('processing')
let share = await shareService.getShareLink(shareLink.id)
const startTime = Date.now()
while (share.watermarkStatus === 'processing' && Date.now() - startTime < 60000) {
await new Promise((resolve) => setTimeout(resolve, 500))
share = await shareService.getShareLink(shareLink.id)
}
expect(share.watermarkStatus).toBe('ready')
const wf = await prisma.watermarkFile.findUnique({
where: {
// eslint-disable-next-line @typescript-eslint/naming-convention
assetId_watermarkConfigId: {
assetId: asset.id,
watermarkConfigId: updatedShare.watermarkConfigId!,
},
},
})
expect(wf).toBeDefined()
expect(wf?.status).toBe(WatermarkFileStatus.completed)
const media = wf?.media as PrismaJson.MediaInfo
expect(media.proxyType).toBe('3d')
expect(media.videoTranscodes?.length).toBeGreaterThan(0)
expect(media.videoPreview?.key).toBe(media.videoTranscodes?.[0]?.key)
})
it('should watermark a newly added asset after the sharelink is already ready', async () => {
// 1. Seed Database
const team = await prisma.team.create({