开发中途存档

This commit is contained in:
tianmo committed 2026-08-29 22:59:38 +08:00
1 parent a2de23a789
commit a80575ef5e
19 files changed
+1998 -91

No files matched your search

+37 -15
View File
@@ -2,6 +2,7 @@ import { defineStore } from 'pinia'
import { EmitterConfig, defaultConfig, ParticleState, type SceneCollider } from '../core/particleEmitter'
import type { SpineSceneObject } from '../spine/spineTypes'
import { releaseSpineAsset, retainSpineAsset } from '../spine/spineAssetRegistry'
import { cloneEditorValue } from '../editor/editorClone'
export interface ParticleSystem {
id: number
@@ -62,6 +63,18 @@ export interface SettingsState {
showAxisLabels: boolean
/** 坐标轴数值颜色(#rrggbb) */
axisColor: string
/** 最大撤回操作数。 */
undoLimit: number
/** 背景图世界坐标与透明度。 */
backgroundX: number
backgroundY: number
backgroundOpacity: number
backgroundImageName: string
backgroundImageData: string
showEmitter: boolean
showBones: boolean
showSkinMesh: boolean
showGrid: boolean
}
export interface TimelineState {
@@ -88,20 +101,6 @@ let colliderSeq = 1
let pathSeq = 1
let spineSeq = 1
/** 深拷贝编辑器配置,但保留 Texture 等运行时类实例的共享引用。 */
function cloneEditorValue<T>(value: T): T {
if (Array.isArray(value)) return value.map((item) => cloneEditorValue(item)) as T
if (value && typeof value === 'object') {
const prototype = Object.getPrototypeOf(value)
if (prototype === Object.prototype || prototype === null) {
const copy: Record<string, unknown> = {}
for (const [key, item] of Object.entries(value)) copy[key] = cloneEditorValue(item)
return copy as T
}
}
return value
}
function copyName(name: string, names: string[]) {
const existing = new Set(names)
const base = `${name} Copy`
@@ -123,12 +122,34 @@ export const useParticleStore = defineStore('particle', {
activeObjectId: 0,
// 与 Spine 编辑器默认时间基准对齐:1 秒 = 30 帧。
timeline: { playing: true, loop: true, frame: 0, totalFrames: 60, fps: 30, recorded: false, animation: 'animation', animations: ['animation'] } as TimelineState,
settings: { tickEnabled: false, axisFontSize: 12, tickWidth: 1, showAxisLabels: true, axisColor: '#7a86ad' } as SettingsState,
settings: {
tickEnabled: false,
axisFontSize: 12,
tickWidth: 1,
showAxisLabels: true,
axisColor: '#7a86ad',
undoLimit: 20,
backgroundX: 0,
backgroundY: 0,
backgroundOpacity: 1,
backgroundImageName: '',
backgroundImageData: '',
showEmitter: true,
showBones: false,
showSkinMesh: false,
showGrid: true,
} as SettingsState,
}),
getters: {
activeSystemCount: (s) => s.systems.length,
},
actions: {
syncSceneSequences() {
seq = Math.max(seq, ...this.systems.map((item) => item.id + 1), 1)
colliderSeq = Math.max(colliderSeq, ...this.colliders.map((item) => item.id + 1), 1)
pathSeq = Math.max(pathSeq, ...this.paths.map((item) => item.id + 1), 1)
spineSeq = Math.max(spineSeq, ...this.spines.map((item) => item.id + 1), 1)
},
addSystem(initial?: Partial<{ config: Partial<EmitterConfig> }>) {
const cfg = defaultConfig()
if (initial?.config) Object.assign(cfg, initial.config)
@@ -283,6 +304,7 @@ export const useParticleStore = defineStore('particle', {
skeletonFileName: '',
atlasFileName: '',
textureFileNames: [],
sourceBundle: null,
selectedAnimation: '',
selectedBone: '',
animations: [],