A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(editor): show .esanim clip properties in the shared Inspector
esengine8ec5c2bb6465
diff --git a/desktop/src/flipbook/animClipInspectorModel.ts b/desktop/src/flipbook/animClipInspectorModel.tsnew file mode 100644index 000000000..f1eb46141--- /dev/null+++ b/desktop/src/flipbook/animClipInspectorModel.ts@@ -0,0 +1,64 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file animClipInspectorModel.ts+ * @brief The open .esanim flipbook as shared-inspector components — an Animation+ * section (fps / loop) and, for sheet clips, a Sheet section (grid). Same+ * `InspectorComponent[]` + `FieldWrite` contract the entity and material+ * inspectors use, so the one ComponentSection engine renders it; edits+ * route through AnimClipCommands (one undo step each). The point is one+ * inspector, no bespoke property panel.+ */+import type { AnimClipAssetData } from 'esengine';+import type { InspectorComponent, InspectorFieldType, GradientValue, CurveValue, DimensionValue } from '@/types';+import { AnimClipCommands } from './AnimClipCommands';+import { t } from '@/i18n';++const DEFAULT_FPS = 12;++export function buildAnimClipComponents(asset: AnimClipAssetData): InspectorComponent[] {+ const out: InspectorComponent[] = [+ {+ name: 'Animation',+ label: t('fb.insp.animation'),+ fields: [+ { key: 'fps', label: t('fb.field.fps'), type: 'number', value: asset.fps ?? DEFAULT_FPS, min: 1, max: 240, step: 1, defaultValue: DEFAULT_FPS },+ { key: 'loop', label: t('fb.loop'), type: 'bool', value: asset.loop ?? true, defaultValue: true },+ ],+ },+ ];+ const s = asset.sheet;+ if (s) {+ out.push({+ name: 'Sheet',+ label: t('fb.insp.sheet'),+ fields: [+ { key: 'cellWidth', label: t('fb.field.cellW'), type: 'number', value: s.cellWidth, min: 1, step: 1 },+ { key: 'cellHeight', label: t('fb.field.cellH'), type: 'number', value: s.cellHeight, min: 1, step: 1 },+ { key: 'margin', label: t('fb.field.margin'), type: 'number', value: s.margin, min: 0, step: 1 },+ { key: 'spacing', label: t('fb.field.spacing'), type: 'number', value: s.spacing, min: 0, step: 1 },+ ],+ });+ }+ return out;+}++/** A FieldWrite routing inspector edits to the open AnimClipDocument via AnimClipCommands. */+export function makeAnimClipWrite() {+ return (key: string, _type: InspectorFieldType, value: number | boolean | string | number[] | GradientValue | CurveValue | DimensionValue): void => {+ switch (key) {+ case 'fps':+ AnimClipCommands.setFps(value as number);+ break;+ case 'loop':+ AnimClipCommands.setLoop(value as boolean);+ break;+ case 'cellWidth':+ case 'cellHeight':+ case 'margin':+ case 'spacing':+ AnimClipCommands.setGrid({ [key]: value as number });+ break;+ }+ };+}diff --git a/desktop/src/flipbook/openFlipbook.ts b/desktop/src/flipbook/openFlipbook.tsindex 412679648..0ec7ab18e 100644--- a/desktop/src/flipbook/openFlipbook.ts+++ b/desktop/src/flipbook/openFlipbook.ts@@ -8,6 +8,7 @@import { createAnimClip, serializeAnimClip } from 'esengine';import { AnimClipDocument } from './AnimClipDocument';+import { useSelection } from '@/store/selectionStore';import { ProjectStore } from '@/project/ProjectStore';import { confirmDiscardDoc } from '@/project/discardGuard';import { dockApi } from '@/layout/dockApi';@@ -20,6 +21,7 @@ export async function openFlipbook(path: string): Promise<void> {// Already-open file: just front the panel — a reload would clobber unsaved edits.if (AnimClipDocument.isOpen && AnimClipDocument.filePath === path) {dockApi.openDocument('flipbook', 'flipbook', t('fb.panelTitle'));+ useSelection.getState().selectAsset(path);return;}if (!(await confirmDiscardDoc(AnimClipDocument.dirty, t('discard.openAsset', { name: baseName(path) })))) return;@@ -27,6 +29,7 @@ export async function openFlipbook(path: string): Promise<void> {const text = await window.estella.fs.read(path);AnimClipDocument.openJson(JSON.parse(text), path);dockApi.openDocument('flipbook', 'flipbook', t('fb.panelTitle'));+ useSelection.getState().selectAsset(path);} catch (e) {Toasts.push(t('fb.toast.openFailed', { error: String(e) }), 'error');}diff --git a/desktop/src/i18n/messages/flipbook.ts b/desktop/src/i18n/messages/flipbook.tsindex de984920b..da3acbd3e 100644--- a/desktop/src/i18n/messages/flipbook.ts+++ b/desktop/src/i18n/messages/flipbook.ts@@ -26,6 +26,9 @@ export const flipbookMessages = defineMessages({'fb.field.zoom': { en: 'Zoom', zh: '缩放' },'fb.loop': { en: 'Loop', zh: '循环' },'fb.frameCount': { en: '{count} frames', zh: '{count} 帧' },+ 'fb.animClip': { en: 'Animation Clip', zh: '动画剪辑' },+ 'fb.insp.animation': { en: 'Animation', zh: '动画' },+ 'fb.insp.sheet': { en: 'Sprite Sheet', zh: '精灵表' },'fb.save': { en: 'Save', zh: '保存' },// — Sheet canvas —diff --git a/desktop/src/panels/Details.tsx b/desktop/src/panels/Details.tsxindex b229a2343..998a1951e 100644--- a/desktop/src/panels/Details.tsx+++ b/desktop/src/panels/Details.tsx@@ -74,6 +74,8 @@ import {renderMaterialThumbnail,type MaterialContext,} from '@/material/materialInspectorModel';+import { AnimClipDocument } from '@/flipbook/AnimClipDocument';+import { buildAnimClipComponents, makeAnimClipWrite } from '@/flipbook/animClipInspectorModel';import { ColorControl, rgbaToHex8 } from '@/components/ColorControl';import { IconButton } from '@/components/IconButton';import { ContextMenu } from '@/components/Menu';@@ -2394,6 +2396,9 @@ function AssetInspector({ path }: { path: string }) {if (isMaterialAsset(path)) {return <MaterialAssetInspector path={path} />;}+ if (type === 'animclip') {+ return <AnimClipAssetInspector path={path} />;+ }if (type === 'inputmap') {return <InputMapAssetInspector path={path} />;}@@ -2403,6 +2408,58 @@ function AssetInspector({ path }: { path: string }) {return <GenericAssetInspector path={path} />;}+// The .esanim inspector: the open flipbook's fps/loop (+ sheet grid) rendered+// through the same ComponentSection engine as entities and materials. Passive —+// the Flipbook panel owns the AnimClipDocument lifecycle, so this only reflects it+// when the selected clip IS the open one, else falls back to import settings.+function AnimClipAssetInspector({ path }: { path: string }) {+ useSyncExternalStore(AnimClipDocument.subscribe, AnimClipDocument.getRevision);+ const [collapsed, setCollapsed] = useState<Set<string>>(new Set());+ const toggle = (name: string) =>+ setCollapsed((s) => {+ const n = new Set(s);+ n.has(name) ? n.delete(name) : n.add(name);+ return n;+ });++ const asset = AnimClipDocument.asset;+ const loaded = !!asset && AnimClipDocument.filePath === path;+ if (!loaded || !asset) return <GenericAssetInspector path={path} />;++ const components = buildAnimClipComponents(asset);+ const write = makeAnimClipWrite();+ const dirty = AnimClipDocument.dirty;++ return (+ <div className="insp">+ <div className="ent-head">+ <div className="ent-row1">+ <div className="ent-name">{baseName(path)}</div>+ </div>+ <div className="ent-meta">+ <span className="pill">+ <span className="pk">{t('fb.animClip')}</span>+ {t('fb.frameCount', { count: asset.frames.length })}+ </span>+ {dirty && <span className="pill">{t('det.unsaved')}</span>}+ </div>+ </div>+ <div className="insp-body">+ {components.map((comp) => (+ <ComponentSection+ key={comp.name}+ entities={[]}+ comp={comp}+ collapsed={collapsed.has(comp.name)}+ onToggle={() => toggle(comp.name)}+ write={write}+ />+ ))}+ </div>+ </div>+ );+}+function formatBytes(n: number): string {if (n < 1024) return `${n} B`;const units = ['KB', 'MB', 'GB'];diff --git a/desktop/src/panels/FlipbookEditor.tsx b/desktop/src/panels/FlipbookEditor.tsxindex 5dbf743a6..271be8bc3 100644--- a/desktop/src/panels/FlipbookEditor.tsx+++ b/desktop/src/panels/FlipbookEditor.tsx@@ -164,15 +164,6 @@ export function FlipbookEditor() {<span className="fb-sep" /></>)}- <GridField label={t('fb.field.fps')} value={fps} min={1} onCommit={(n) => AnimClipCommands.setFps(n)} />- <label className="fb-field fb-loop">- <input- type="checkbox" checked={asset.loop ?? true}- onChange={(e) => AnimClipCommands.setLoop(e.target.checked)}- />- <span>{t('fb.loop')}</span>- </label>- <span className="fb-sep" /><label className="fb-field"><span>{t('fb.field.zoom')}</span><input type="range" min={1} max={8} step={1} value={zoom}