解决粒子首位帧衔接问题
This commit is contained in:
1 parent
0656684a92
commit
9c2421110c
22 files changed
+2873
-1407
No files matched your search
@@ -0,0 +1,15 @@
|
||||
export type PlaybackRange = { start: number; end: number }
|
||||
|
||||
export function normalizePlaybackRange(start: unknown, end: unknown, totalFrames: number): PlaybackRange {
|
||||
const last = Math.max(1, Math.floor(totalFrames) - 1)
|
||||
const safeStart = Math.min(last - 1, Math.max(0, Math.floor(Number(start) || 0)))
|
||||
const safeEnd = Math.min(last, Math.max(safeStart + 1, Math.floor(Number(end) || last)))
|
||||
return { start: safeStart, end: safeEnd }
|
||||
}
|
||||
|
||||
export function resizePlaybackRange(range: PlaybackRange, previousTotal: number, nextTotal: number) {
|
||||
const previousLast = Math.max(1, previousTotal - 1)
|
||||
const nextLast = Math.max(1, nextTotal - 1)
|
||||
const end = range.end >= previousLast ? nextLast : range.end
|
||||
return normalizePlaybackRange(range.start, end, nextTotal)
|
||||
}
|
||||
Reference in new issue
Block a user