修复导出问题
This commit is contained in:
1 parent
d224939efd
commit
5d12bf895b
8 files changed
+90
-56
No files matched your search
@@ -6,6 +6,7 @@ import { downgradeSpineJsonTo38 } from './spine38JsonExporter'
|
||||
import { reduceBezierSamples, reduceNumericSamples, roundSpine, unwrapDegrees, type NumericSample } from './spineKeyframeReducer'
|
||||
import { buildWeightedTrailMesh } from './spineMeshBuilder'
|
||||
import { loopPlaybackRange, loopSegmentTiming } from '../core/loopSegmentTiming'
|
||||
import { collectSubEmitterIds } from '../core/subEmitterIds'
|
||||
|
||||
type Track = { key: string; name: string; states: Array<ParticleState | null> }
|
||||
type ExportInput = { systems: ParticleSystem[]; timeline: TimelineState; settings: SpineExportSettings }
|
||||
@@ -327,6 +328,7 @@ export function buildSpineJson(input: ExportInput): SpineExportResult {
|
||||
const fps = settings.integerFrameAlignment ? targetFps : sourceFps
|
||||
const warnings: SpineExportWarning[] = []
|
||||
const visibleSystems = input.systems.filter((system) => system.visible !== false)
|
||||
const subEmitterIds = collectSubEmitterIds(input.systems)
|
||||
const document: SpineJsonDocument = {
|
||||
// 先生成当前运行时使用的公共结构;3.8 会在最终序列化前降级字段与时间轴格式。
|
||||
skeleton: { hash: '', spine: settings.spineVersion, x: 0, y: 0, width: 0, height: 0, images: settings.imagesPath || './images/' },
|
||||
@@ -339,7 +341,10 @@ export function buildSpineJson(input: ExportInput): SpineExportResult {
|
||||
const animationSystems = new Map<string, Array<{ system: ParticleSystem; tracks: Track[]; targetFrames: number; boundaryFrames: Set<number>; attachmentPrefix: string }>>()
|
||||
|
||||
for (const system of visibleSystems) {
|
||||
const sourceCount = Math.min(system.frames?.length || 0, particleDurationFrames(system, sourceFps))
|
||||
const frameLength = system.frames?.length || 0
|
||||
const sourceCount = subEmitterIds.has(system.id)
|
||||
? frameLength
|
||||
: Math.min(frameLength, particleDurationFrames(system, sourceFps))
|
||||
const frames = (system.frames || []).slice(0, sourceCount)
|
||||
if (!frames.length) warnings.push({ code: 'empty-cache', message: `“${system.config.name}”没有可用帧缓存。` })
|
||||
const prefix = uniqueName(safeName(system.config.name, `system_${system.id}`), usedNames)
|
||||
|
||||
+5
-3
@@ -222,7 +222,6 @@ function bakeSystemFrames(system: ParticleSystem, emitter: ParticleEmitter, fps:
|
||||
function ensureFramesBaked(fps: number) {
|
||||
const totalFrames = Math.max(2, Math.floor(store.timeline.totalFrames) || 2)
|
||||
const subEmitterIds = collectSubEmitterIds(store.systems)
|
||||
let complete = true
|
||||
// 烘焙预热会大量出生/死亡粒子,期间暂停跨系统事件,避免注入预热粒子。
|
||||
emitterSync.suspendEvents(true)
|
||||
try {
|
||||
@@ -231,13 +230,16 @@ function ensureFramesBaked(fps: number) {
|
||||
if (subEmitterIds.has(system.id)) continue
|
||||
if ((system.frames?.length || 0) >= totalFrames) continue
|
||||
const emitter = emitterSync.emitters.get(system.id)
|
||||
if (!emitter) { complete = false; continue }
|
||||
if (!emitter) continue
|
||||
bakeSystemFrames(system as unknown as ParticleSystem, emitter, fps, totalFrames)
|
||||
}
|
||||
} finally {
|
||||
emitterSync.suspendEvents(false)
|
||||
}
|
||||
if (complete) store.timeline.recorded = true
|
||||
// 子发射器必须通过父事件逐帧录制;只补齐根系统时不能把整段烘焙标记为完成。
|
||||
if (store.systems.every((system) => (system.frames?.length || 0) >= totalFrames)) {
|
||||
store.timeline.recorded = true
|
||||
}
|
||||
}
|
||||
|
||||
function loop() {
|
||||
|
||||
Reference in new issue
Block a user