mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-27 03:14:11 +00:00
- 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
23 lines
600 B
TypeScript
23 lines
600 B
TypeScript
import { FileTypeDefinition } from '../types'
|
|
import ModelViewer from './model-viewer'
|
|
|
|
export function secondToDegree(second: number): number {
|
|
const frameIndex = Math.min(Math.max(0, Math.round(second * 6)), 23)
|
|
return (frameIndex * 15) % 360
|
|
}
|
|
|
|
export const modelTypeDefinition: FileTypeDefinition = {
|
|
id: '3d',
|
|
name: '3D Model',
|
|
match: (file) => file.proxyType === '3d',
|
|
viewer: ModelViewer,
|
|
commentsConfig: {
|
|
hasTimestamp: true,
|
|
hasAnnotations: true,
|
|
formatTimestamp: (second: number) => {
|
|
const deg = secondToDegree(second)
|
|
return `${deg}°`
|
|
},
|
|
},
|
|
}
|