Skip to content

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.

feat(editor): make animations creatable + the Sequencer self-explanatory

esengine8c0d27c79ef9
diff --git a/desktop/electron/importAssets.ts b/desktop/electron/importAssets.ts
index 98444f38e..127f74b70 100644
--- a/desktop/electron/importAssets.ts
+++ b/desktop/electron/importAssets.ts
@@ -23,7 +23,7 @@ const EXT_TO_TYPE: Record<string, string> = {
'.png': 'texture', '.jpg': 'texture', '.jpeg': 'texture', '.webp': 'texture', '.bmp': 'texture',
'.wav': 'audio', '.mp3': 'audio', '.ogg': 'audio', '.aac': 'audio', '.flac': 'audio', '.m4a': 'audio', '.webm': 'audio',
'.esprefab': 'prefab', '.esscene': 'scene', '.esshader': 'shader', '.esmaterial': 'material', '.esmat': 'material',
- '.estl': 'timeline', '.esanim': 'animation', '.esanimclip': 'animation',
+ '.esanim': 'animation', '.esanimclip': 'animation', '.estimeline': 'animation',
'.fnt': 'bitmapFont', '.bmfont': 'bitmapFont', '.ttf': 'font', '.otf': 'font', '.woff': 'font', '.woff2': 'font',
'.tmx': 'tilemap', '.tmj': 'tilemap',
'.skel': 'spine', '.atlas': 'spine',
diff --git a/desktop/electron/main.ts b/desktop/electron/main.ts
index 816e62cbf..9a3f4f3f1 100644
--- a/desktop/electron/main.ts
+++ b/desktop/electron/main.ts
@@ -193,6 +193,10 @@ async function runScreenshot(w: BrowserWindow, out: string): Promise<void> {
if (err) console.log('[play] error:', err);
await settleFrames(30); // let the game loop run so animation/assets settle
}
+ if (process.env.ESTELLA_SHOT_EVAL) {
+ await exec(process.env.ESTELLA_SHOT_EVAL);
+ await settleFrames(8);
+ }
await settleFrames(12); // was sleep(2500) — let the engine loop spin up + fully paint the WebGL viewport
const img = await w.webContents.capturePage();
await writeFile(out, img.toPNG());
diff --git a/desktop/src/main.tsx b/desktop/src/main.tsx
index 16998c0d2..120a4b823 100644
--- a/desktop/src/main.tsx
+++ b/desktop/src/main.tsx
@@ -35,6 +35,7 @@ import { ProjectStore } from './project/ProjectStore';
import { useEditorStore } from './store/editorStore';
import { useSelection } from './store/selectionStore';
import { PlayRealm } from './engine/PlayRealm';
+import { dockApi } from './layout/dockApi';
import { EditorControlSurface } from './engine/EditorSession';
import { LogStore } from './store/LogStore';
import { initFsWatch } from './project/fsWatch';
@@ -61,6 +62,7 @@ if (new URLSearchParams(location.search).has('automation')) {
selectAsset: (path: string | null) => useSelection.getState().selectAsset(path),
play: () => useEditorStore.getState().togglePlay(),
playState: () => PlayRealm.getSnapshot(),
+ reveal: (id: string) => dockApi.revealAndExpand(id),
surface: EditorControlSurface,
};
}
diff --git a/desktop/src/panels/ContentBrowser.tsx b/desktop/src/panels/ContentBrowser.tsx
index 8d8a72592..9a6d32231 100644
--- a/desktop/src/panels/ContentBrowser.tsx
+++ b/desktop/src/panels/ContentBrowser.tsx
@@ -16,6 +16,7 @@ import { createTilesetFromTexture } from '@/tileset/openTileset';
import { createTilemapFromTileset } from '@/tilemap/createTilemap';
import { createMaterial, createMaterialInstance } from '@/material/openMaterial';
import { createMaterialGraph } from '@/material/openMaterialGraph';
+import { createAnimationClip } from '@/timeline/openClip';
import { fsRefresh } from '@/project/fsWatch';
import type { DirEntry } from '@/project/format';
import type { AssetType } from '@/types';
@@ -553,6 +554,7 @@ export function ContentBrowser() {
{ label: 'New Folder', icon: <FolderPlus size={14} />, onClick: () => void newFolder() },
{ sep: true },
{ label: 'New Scene', onClick: () => void newScene() },
+ { label: 'New Animation', onClick: () => void createAnimationClip(cwd) },
{ label: 'New Input Map', onClick: () => void newInputMap() },
{ label: 'New Material', onClick: () => void createMaterial(cwd) },
{ label: 'New Material Graph', onClick: () => void createMaterialGraph(cwd) },
diff --git a/desktop/src/panels/Sequencer.tsx b/desktop/src/panels/Sequencer.tsx
index 33758190c..7f9b4993e 100644
--- a/desktop/src/panels/Sequencer.tsx
+++ b/desktop/src/panels/Sequencer.tsx
@@ -20,6 +20,7 @@ import {
import { evaluateChannel, InterpType, WrapMode } from 'esengine';
import { animatableFieldsFor } from '@/engine/schema';
import { TimelineDocument } from '@/timeline/TimelineDocument';
+import { createAnimationClip } from '@/timeline/openClip';
import { TimelineCommands } from '@/timeline/TimelineCommands';
import { useSequencerStore } from '@/store/sequencerStore';
import { useSelection } from '@/store/selectionStore';
@@ -85,7 +86,15 @@ function EmptyState() {
<div className="seq-empty">
<Film size={30} strokeWidth={1.3} />
<div className="seq-empty__title">没有打开的动画</div>
- <div className="seq-empty__hint">在内容浏览器双击 .esanim / .estimeline 打开动画片段</div>
+ <div className="seq-empty__hint">新建一段动画,或在内容浏览器双击已有的 .esanim 打开。</div>
+ <button type="button" className="seq-btn seq-btn--text on" onClick={() => void createAnimationClip('')}>
+ <Plus size={14} /><span>新建动画</span>
+ </button>
+ <ol className="seq-empty__steps">
+ <li>在场景里选中一个物体,点工具栏「绑定」把预览绑到它</li>
+ <li>开「录制」,然后移动/旋转它或改属性 — 关键帧自动记录</li>
+ <li>拖动播放头预览,点「保存」写回文件</li>
+ </ol>
</div>
);
}
diff --git a/desktop/src/theme/sequencer.css b/desktop/src/theme/sequencer.css
index 82864805d..9510585e4 100644
--- a/desktop/src/theme/sequencer.css
+++ b/desktop/src/theme/sequencer.css
@@ -230,3 +230,13 @@
}
.seq-empty__title { color: var(--text-dim); font-size: 13px; }
.seq-empty__hint { font-size: var(--fs-xs); }
+.seq-empty__steps {
+ margin: 6px 0 0; padding: 0; list-style: none; counter-reset: step;
+ text-align: left; font-size: var(--fs-xs); line-height: 1.7; max-width: 300px;
+}
+.seq-empty__steps li { counter-increment: step; }
+.seq-empty__steps li::before {
+ content: counter(step); display: inline-grid; place-items: center;
+ width: 15px; height: 15px; margin-right: 7px; border-radius: 50%;
+ background: var(--srf-3); color: var(--text-dim); font-size: 9px; vertical-align: middle;
+}
diff --git a/desktop/src/timeline/openClip.ts b/desktop/src/timeline/openClip.ts
index 837a6e765..33385e003 100644
--- a/desktop/src/timeline/openClip.ts
+++ b/desktop/src/timeline/openClip.ts
@@ -16,6 +16,8 @@ import { useSequencerStore } from '@/store/sequencerStore';
import { useSelection } from '@/store/selectionStore';
import { dockApi } from '@/layout/dockApi';
import { Toasts } from '@/store/Toasts';
+import { ProjectStore } from '@/project/ProjectStore';
+import { baseName } from '@/project/assetMeta';
export async function openAnimationClip(path: string): Promise<void> {
try {
@@ -30,3 +32,27 @@ export async function openAnimationClip(path: string): Promise<void> {
Toasts.push(`无法打开动画:${String(e)}`, 'error');
}
}
+
+// A blank multi-track timeline, in the canonical serialized shape parseAnimationClip
+// reads (the Sequencer fills it by recording keys on a selected entity).
+const BLANK_CLIP = { version: '1.1', type: 'timeline', duration: 5, wrapMode: 'loop', tracks: [] };
+
+/** Create an empty `.esanim` timeline in @p dir and open it in the Sequencer. */
+export async function createAnimationClip(dir: string): Promise<void> {
+ const folder = dir ? (dir.endsWith('/') ? dir : `${dir}/`) : '';
+ let rel = `${folder}NewAnimation.esanim`;
+ for (let n = 1; ProjectStore.assetRef(rel); n++) rel = `${folder}NewAnimation-${n}.esanim`;
+ try {
+ await window.estella.fs.write(rel, JSON.stringify(BLANK_CLIP, null, 2) + '\n');
+ await window.estella.fs.write(
+ rel + '.meta',
+ JSON.stringify({ uuid: crypto.randomUUID(), version: '1.0', type: 'animation', importer: { autoMigrate: true } }, null, 2) + '\n',
+ );
+ } catch (e) {
+ Toasts.push(`创建动画失败:${String(e)}`, 'error');
+ return;
+ }
+ await ProjectStore.refreshAssets();
+ Toasts.push(`已创建动画:${baseName(rel)}`, 'info');
+ await openAnimationClip(rel);
+}