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.

fix(editor): zoom-to-cursor, Flipbook fps/loop in panel, honest import toast

esengine7244acea04d5
diff --git a/desktop/src/engine/ViewportController.ts b/desktop/src/engine/ViewportController.ts
index f2b12f4cb..7c770553d 100644
--- a/desktop/src/engine/ViewportController.ts
+++ b/desktop/src/engine/ViewportController.ts
@@ -377,6 +377,24 @@ export const ViewportController = {
view.orthoSize = Math.max(8, Math.min(40000, view.orthoSize * factor));
},
+ /** Zoom about the cursor: the world point under (clientX, clientY) stays put, so
+ * you zoom INTO what you're looking at (Figma/Blender/Godot). Analytic — no
+ * post-zoom re-project (the engine camera only updates next frame): for an ortho
+ * camera the world offset from center scales with orthoSize, so the new center is
+ * `view + (W − view)·(1 − factor)`. */
+ zoomAtClient(clientX: number, clientY: number, factor: number): void {
+ const view = editorView();
+ if (!view) return;
+ const w = this.canvasToWorld(clientX, clientY); // current matrices — read BEFORE zoom
+ const next = Math.max(8, Math.min(40000, view.orthoSize * factor));
+ const applied = next / view.orthoSize; // clamped factor
+ view.orthoSize = next;
+ if (w) {
+ view.x += (w.x - view.x) * (1 - applied);
+ view.y += (w.y - view.y) * (1 - applied);
+ }
+ },
+
/**
* Frame a set of entities: center the editor view on their union bounds and zoom
* to fit (with padding). Empty / single-point selections keep the current zoom and
diff --git a/desktop/src/i18n/messages/details.ts b/desktop/src/i18n/messages/details.ts
index af539e4bc..63aeab1e1 100644
--- a/desktop/src/i18n/messages/details.ts
+++ b/desktop/src/i18n/messages/details.ts
@@ -161,7 +161,7 @@ export const detailsMessages = defineMessages({
// — Generic asset inspector (import settings + metadata) —
'det.importSettings': { en: 'Import Settings', zh: '导入设置' },
'det.saveImportTip': { en: 'Save import settings', zh: '保存导入设置' },
- 'det.importSaved': { en: 'Import settings saved', zh: '导入设置已保存' },
+ 'det.importSaved': { en: 'Import settings saved — size / compression apply on the next build', zh: '导入设置已保存——尺寸 / 压缩在下次构建时生效' },
'det.importSaveFailed': { en: 'Failed to save import settings: {error}', zh: '保存导入设置失败:{error}' },
'det.noImportSettings': { en: 'This asset type has no import settings.', zh: '此资产类型没有导入设置。' },
'det.audioSeekTip': { en: 'Click to seek', zh: '点击跳转播放位置' },
diff --git a/desktop/src/i18n/messages/flipbook.ts b/desktop/src/i18n/messages/flipbook.ts
index 1a77b27e9..09226b830 100644
--- a/desktop/src/i18n/messages/flipbook.ts
+++ b/desktop/src/i18n/messages/flipbook.ts
@@ -25,6 +25,7 @@ export const flipbookMessages = defineMessages({
'fb.field.fps': { en: 'FPS', zh: '帧率' },
'fb.field.zoom': { en: 'Zoom', zh: '缩放' },
'fb.loop': { en: 'Loop', zh: '循环' },
+ 'fb.fps': { en: 'FPS', zh: '帧率' },
'fb.frameCount': { en: '{count} frames', zh: '{count} 帧' },
'fb.animClip': { en: 'Animation Clip', zh: '动画剪辑' },
'fb.insp.animation': { en: 'Animation', zh: '动画' },
diff --git a/desktop/src/panels/FlipbookEditor.tsx b/desktop/src/panels/FlipbookEditor.tsx
index fbb1cc9c5..03d41c96a 100644
--- a/desktop/src/panels/FlipbookEditor.tsx
+++ b/desktop/src/panels/FlipbookEditor.tsx
@@ -217,6 +217,13 @@ export function FlipbookEditor() {
frameCount={asset.frames.length}
/>
<span className="fb-grow" />
+ {/* fps + loop live here too, not only in the Details inspector (which
+ vanishes the moment you select an entity). */}
+ <GridField label={t('fb.fps')} value={fps} min={1} onCommit={(n) => AnimClipCommands.setFps(n)} />
+ <label className="fb-field" title={t('fb.loop')}>
+ <input type="checkbox" checked={asset.loop ?? true} onChange={(e) => AnimClipCommands.setLoop(e.target.checked)} />
+ <span>{t('fb.loop')}</span>
+ </label>
<label className="fb-field fb-onion" title={t('fb.onionTip')}>
<input type="checkbox" checked={onion} onChange={(e) => setOnion(e.target.checked)} />
<span>{t('fb.onion')}</span>
diff --git a/desktop/src/panels/Viewport.tsx b/desktop/src/panels/Viewport.tsx
index 38b27a4f7..d6e08e15d 100644
--- a/desktop/src/panels/Viewport.tsx
+++ b/desktop/src/panels/Viewport.tsx
@@ -980,7 +980,7 @@ export function Viewport() {
const onWheel = (e: WheelEvent) => {
e.preventDefault();
const orthoFactor = e.deltaY > 0 ? 1.1 : 1 / 1.1; // larger orthoSize = zoom out
- ViewportController.zoomBy(orthoFactor);
+ ViewportController.zoomAtClient(e.clientX, e.clientY, orthoFactor); // zoom toward the cursor
setZoomPct((z) => Math.max(10, Math.min(800, Math.round(z / orthoFactor))));
};
stage.addEventListener('wheel', onWheel, { passive: false });