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(viewport): combine transform handles in a universal tool
yhh25db9e738097
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 36a12c8b5..68b6483ed 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -26,6 +26,10 @@ published separately; it ships inside the editor.### Added+- **Universal Transform combines move, rotate and scale handles.** The viewport toolbar and Command Palette offer a combined tool on Y, preserving T for Rect. Move handles win overlaps, then outer scale boxes, then rotation rings; each drag captures one operation and highlights only its target. Scale boxes remain separate from arrow tips, and their drag sensitivity uses the captured box-arm length. Existing pivot, size, transaction and copy paths remain shared.++- **Alt-copy on transform handles reaches the tool.** Camera orbit no longer consumes an Alt-left press on a visible, editable selected transform handle; the rest of the canvas retains its navigation behavior. Individual Origins starts duplicates at the originals' positions before applying rotation or scale, and CI saves intermediate observations even when a gesture check fails.+- **Multi-selection transforms support Individual Origins.** The viewport pivot control cycles Center, active-object Pivot and Individual Origins, with direct View menu and Command Palette choices. Individual rotation and scale keep each transform target's position, while translation, hierarchy pruning, locks, snapping and the existing undo/Alt-copy path remain shared. Each gesture captures its pivot policy.- **Transform handle size is configurable.** Editor settings scale move/scale handles, rotation rings and hit areas together from 0.5 to 2, with the legacy size as default. The preference persists across sessions; active handle drags keep their captured size and sensitivity until release or cancellation.diff --git a/desktop b/desktopindex da6cf0e06..e91793867 160000--- a/desktop+++ b/desktop@@ -1 +1 @@-Subproject commit da6cf0e06afd8f4954ff7a34ecbb405f78d33d15+Subproject commit e91793867ab864a0c62462bf5cb71d01efb9ada7diff --git a/docs/astro/src/content/docs/editor/shortcuts.mdx b/docs/astro/src/content/docs/editor/shortcuts.mdxindex 07d2702b7..9ce160d75 100644--- a/docs/astro/src/content/docs/editor/shortcuts.mdx+++ b/docs/astro/src/content/docs/editor/shortcuts.mdx@@ -20,6 +20,7 @@ Settings → Keyboard Shortcuts.| Delete | `Delete` / `Backspace` || Select All | `mod + A` || Select / Move / Rotate / Scale / Rect tool | `Q` / `W` / `E` / `R` / `T` |+| Universal Transform tool | `Y` || Nudge selection (×10 with Shift) | Arrow keys || Frame Selected | `F` || Play · Stop | `F5` · `Esc` |diff --git a/docs/astro/src/content/docs/editor/viewport.mdx b/docs/astro/src/content/docs/editor/viewport.mdxindex dd5e11de7..0664f7898 100644--- a/docs/astro/src/content/docs/editor/viewport.mdx+++ b/docs/astro/src/content/docs/editor/viewport.mdx@@ -30,6 +30,14 @@ handle:| Rotate | `E` | Projected axis rings; head-on 2D shows the Z ring. || Scale | `R` | Projected axis boxes plus a center handle that scales the visible plane's two axes. || Rect | `T` | The selected sprite or UI node's own rectangle grips. |+| Universal Transform | `Y` | Move arrows and center plane, outer scale boxes and rotation rings together. |++Universal Transform gives move handles priority over scale boxes, then rotation+rings. Scale boxes sit beyond the arrow tips so they remain reachable; a drag+along one complete box-arm length doubles that axis's scale. Each press chooses+one operation, which remains fixed for the entire drag. Its hover and drag+highlight affect only that operation. The separate W / E / R tools keep their+existing geometry and T remains Rect.Hovering a transform handle highlights the handle that a press will grab. Thecursor shows moving, rotation or the projected resize direction. Camera or@@ -51,10 +59,13 @@ and child are both selected, the parent still carries its subtree to avoid applythe gesture twice. Locked targets stay excluded. The pivot policy is captured atthe start of a drag, so changing it during that drag applies to the next gesture.-Each drag is a single undo step; **Esc** cancels it. **Alt-drag** a selection to+Each drag is a single undo step; **Esc** cancels it. **Alt-drag a selected handle** toduplicate it and drag the copies. Nudge the selection with the **arrow keys** (onegrid step; hold **Shift** for ×10).+Alt-left on the rest of the canvas still orbits the camera. Hidden or locked+handles and contributed tools do not claim this copy gesture.+**Align & distribute** — select two or more entities and a strip of alignment buttonsappears in the viewport overlay: align **left / centre / right** edges and **top / middle /bottom** edges. With three or more selected, two **distribute** buttons even out horizontaldiff --git a/docs/astro/src/content/docs/zh-cn/editor/shortcuts.mdx b/docs/astro/src/content/docs/zh-cn/editor/shortcuts.mdxindex ca28e8f5d..4e67e0a7e 100644--- a/docs/astro/src/content/docs/zh-cn/editor/shortcuts.mdx+++ b/docs/astro/src/content/docs/zh-cn/editor/shortcuts.mdx@@ -19,6 +19,7 @@ import { Aside } from '@astrojs/starlight/components';| 删除 | `Delete` / `Backspace` || 全选 | `mod + A` || 选择 / 移动 / 旋转 / 缩放 / Rect 工具 | `Q` / `W` / `E` / `R` / `T` |+| 万能变换工具 | `Y` || 微移选择(按 Shift ×10) | 方向键 || 聚焦选中 | `F` || 运行 · 停止 | `F5` · `Esc` |diff --git a/docs/astro/src/content/docs/zh-cn/editor/viewport.mdx b/docs/astro/src/content/docs/zh-cn/editor/viewport.mdxindex 78023dc7c..bd7cb263f 100644--- a/docs/astro/src/content/docs/zh-cn/editor/viewport.mdx+++ b/docs/astro/src/content/docs/zh-cn/editor/viewport.mdx@@ -28,6 +28,12 @@ description: "视口导航、变换 gizmo、对齐与分布、显示开关、Sce| 旋转 | `E` | 投影后的轴向旋转环;正对 2D 时显示 Z 环。 || 缩放 | `R` | 投影后的轴向方块,中心手柄缩放可见平面的两轴。 || Rect | `T` | 选中精灵或 UI 节点自身的矩形手柄。 |+| 万能变换 | `Y` | 同时显示移动箭头与中心平面、外侧缩放方块和旋转环。 |++万能变换按移动手柄、缩放方块、旋转环的顺序命中。缩放方块位于箭头外侧,+保持可抓取;沿方块所在轴拖动一个完整臂长,该轴缩放加倍。+每次按下只选择一种操作,并在整个拖拽期间保持;悬停和拖拽仅高亮该操作。+W / E / R 单独工具的几何保持原样,T 仍为 Rect。悬停变换手柄会高亮实际按下时将抓到的手柄,光标显示移动、旋转或投影后的缩放方向。相机或选择变化会重新判断,离开画布即清除。导航、绘制、拾取和@@ -44,9 +50,12 @@ description: "视口导航、变换 gizmo、对齐与分布、显示开关、Sce子树,避免重复变换;锁定对象仍被排除。每次拖拽开始时固定轴心策略,拖拽中修改模式会在下次操作生效。-每次拖动是一步撤销,按 **Esc** 取消。**Alt 拖动**选择可复制并拖动副本。+每次拖动是一步撤销,按 **Esc** 取消。**Alt 拖动选中的手柄**可复制并拖动副本。用**方向键**微移选择(一格;按 **Shift** 为 ×10)。+画布其他位置的 Alt + 左键仍用于旋转相机。隐藏、锁定的手柄和贡献工具+不会占用这个复制手势。+**对齐与分布**——选中两个或更多实体,视口浮层里会出现一排对齐按钮:对齐**左 / 中 / 右**边和**上 / 中 / 下**边。选中三个或更多时,另有两个**分布**按钮可把水平或垂直间距均分。每个都是一步撤销,且对每种实体都有效(精灵、UI 节点、纯 gizmo 实体一视同仁)。diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex 3bc1f66b6..a19c94f29 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -30,6 +30,8 @@ export const NOTES_FLOOR = 'v0.65.0';export const NOTED = {'perf(ui): search measured list bounds and retry failed syncs':{ note: 'Measured lists locate visible items without scanning every preceding row.' },+ 'feat(viewport): combine transform handles in a universal tool':+ { note: 'Universal Transform combines move, rotate and scale handles.' },'perf(text): wrap plain text with incremental glyph advances':{ note: 'Plain-text wrapping avoids repeated whole-line glyph measurements.' },'perf(text): trim overflowing plain text with prefix advances':diff --git a/tools/verify-gizmo-hover.mjs b/tools/verify-gizmo-hover.mjsindex f3b1a1f39..fed7cb90c 100644--- a/tools/verify-gizmo-hover.mjs+++ b/tools/verify-gizmo-hover.mjs@@ -10,14 +10,18 @@ fs.writeFileSync(path.join(project,'src/main.ts'),'export {};');fs.writeFileSyncconst records=[];const read="(() => { const s=document.querySelector('.viewport__stage'); return {hover:s?.dataset.gizmoHover,cursor:s?.style.cursor,size:JSON.parse(localStorage.getItem('estella.settings') || '{}')['viewport.gizmoSize'],scene:JSON.stringify(window.__estellaEditor.surface.serializeScene())}; })()";try{- for(const size of [0.5,1,2]) for(const c of [{mode:'move',x:50,y:0,id:'move.x',cursor:'move'},{mode:'scale',x:58,y:0,id:'scale.x',cursor:'ew-resize'},{mode:'rotate',x:42,y:0,id:'rotate.z',cursor:'grab'}]){+ for(const size of [0.5,1,2]) for(const c of [{mode:'move',x:50,y:0,id:'move.x',cursor:'move'},{mode:'scale',x:58,y:0,id:'scale.x',cursor:'ew-resize'},{mode:'rotate',x:42,y:0,id:'rotate.z',cursor:'grab'},+ {mode:'universal',name:'universal-move',x:42,y:0,id:'move.x',cursor:'move'},+ {mode:'universal',name:'universal-scale',x:80,y:0,id:'scale.x',cursor:'ew-resize'},+ {mode:'universal',name:'universal-rotate',x:30,y:-30,id:'rotate.z',cursor:'grab'}]){+ const name=c.name ?? c.mode;const run=runElectron(['.'],{via:'npx',encoding:'utf8',cwd:path.join(root,'desktop'),timeout:180000,env:{- ESTELLA_SHOT:path.join(out,c.mode+'-'+size+'.png'),ESTELLA_SHOT_PROJECT:project,ESTELLA_SHOT_SCENE:'assets/scenes/main.esscene',+ ESTELLA_SHOT:path.join(out,name+'-'+size+'.png'),ESTELLA_SHOT_PROJECT:project,ESTELLA_SHOT_SCENE:'assets/scenes/main.esscene',ESTELLA_SHOT_EVAL:`(async () => {const e=window.__estellaEditor;const wait=ms=>new Promise(resolve=>setTimeout(resolve,ms));const find=async selector=>{for(let i=0;i<50;i++){const node=document.querySelector(selector);if(node)return node;await wait(100);}throw Error('Missing settings control: '+selector);};e.runCommand('settings.open');const search=await find('.set-search input');Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,'value').set.call(search,'viewport.gizmoSize');search.dispatchEvent(new Event('input',{bubbles:true}));await wait(200);if(document.querySelectorAll('.set-content .set-row').length!==1)throw Error('Size search must identify one setting');const value=await find('.set-num');value.focus();value.value='${size}';value.blur();await wait(100);if(JSON.parse(localStorage.getItem('estella.settings')||'{}')['viewport.gizmoSize']!==${size})throw Error('Size preference was not saved');document.querySelector('.set-win').dispatchEvent(new KeyboardEvent('keydown',{key:'Escape',bubbles:true}));await wait(300);e.runCommand('mode.scene');e.runCommand('view.resetOrbit');e.surface.setGizmoDisplay({show:true,selectedOnly:true,iconSize:16,types:{}});e.surface.select(1);e.frame([1]);await wait(750);e.runCommand('tool.${c.mode}');return true;})()`,ESTELLA_SHOT_EDITOR_DRAG:JSON.stringify({selector:'.viewport__stage canvas',ox:c.x*size,oy:c.y*size,steps:1,hoverOnly:true,read})}});assert.equal(run.status,0,run.stderr);const line=run.stdout.split('\n').find(line=>line.startsWith('[editorDrag] '));assert(line,'Missing trusted hover observation');const result=JSON.parse(line.slice('[editorDrag] '.length));assert.equal(result.after.hover,c.id);assert.equal(result.after.cursor,c.cursor);assert.equal(result.after.size,size);assert.equal(result.after.scene,result.before.scene,'Hover edited the scene');- assert(fs.existsSync(path.join(out,c.mode+'-'+size+'.png')),'Missing editor screenshot');records.push({mode:c.mode,size,...result});+ assert(fs.existsSync(path.join(out,name+'-'+size+'.png')),'Missing editor screenshot');records.push({mode:c.mode,name,size,...result});}fs.writeFileSync(path.join(out,'checks.json'),JSON.stringify({status:'checks-passed',mode:'CI-editor-trusted-hover',records},null,2));console.log('Gizmo hover CI: move/scale/rotate preselection and cursors pass; scene unchanged');diff --git a/tools/verify-gizmo-origins.mjs b/tools/verify-gizmo-origins.mjsindex 6df4a3582..c0abffbb7 100644--- a/tools/verify-gizmo-origins.mjs+++ b/tools/verify-gizmo-origins.mjs@@ -48,24 +48,31 @@ try {]),{ pivot: 'individual', mode: 'scale', ox: 58, dx: 58, dy: 0, cancel: true },{ pivot: 'individual', mode: 'rotate', ox: 42, dx: -42, dy: -42, alt: true },+ { pivot: 'individual', tool: 'universal', mode: 'move', ox: 42, dx: 25, dy: 0 },+ { pivot: 'individual', tool: 'universal', mode: 'scale', ox: 80, dx: 80, dy: 0 },+ { pivot: 'individual', tool: 'universal', mode: 'rotate', ox: 30, oy: -30, dx: -60, dy: 0 },+ { pivot: 'individual', tool: 'universal', mode: 'scale', ox: 80, dx: 80, dy: 0, cancel: true },+ { pivot: 'individual', tool: 'universal', mode: 'rotate', ox: 30, oy: -30, dx: -60, dy: 0, alt: true },];for (const c of cases) {- const name = `${c.pivot}-${c.mode}${c.cancel ? '-escape' : c.alt ? '-duplicate' : ''}`;+ const name = `${c.tool === 'universal' ? 'universal-' : ''}${c.pivot}-${c.mode}${c.cancel ? '-escape' : c.alt ? '-duplicate' : ''}`;const run = runElectron(['.'], { via: 'npx', encoding: 'utf8', cwd: path.join(root, 'desktop'), timeout: 180000, env: {ESTELLA_SHOT: path.join(out, name + '.png'), ESTELLA_SHOT_PROJECT: project,ESTELLA_SHOT_SCENE: 'assets/scenes/main.esscene',- ESTELLA_SHOT_EVAL: `(async()=>{const e=window.__estellaEditor;e.runCommand('mode.scene');e.runCommand('view.resetOrbit');e.runCommand('view.pivot${c.pivot === 'individual' ? 'Individual' : 'Center'}');e.surface.selectMany([1,2],1);e.frame([1,2]);await new Promise(r=>setTimeout(r,750));e.runCommand('tool.${c.mode}');return true;})()`,+ ESTELLA_SHOT_EVAL: `(async()=>{const e=window.__estellaEditor;e.runCommand('mode.scene');e.runCommand('view.resetOrbit');e.runCommand('view.pivot${c.pivot === 'individual' ? 'Individual' : 'Center'}');e.surface.selectMany([1,2],1);e.frame([1,2]);await new Promise(r=>setTimeout(r,750));e.runCommand('tool.${c.tool ?? c.mode}');return true;})()`,ESTELLA_SHOT_EDITOR_DRAG: JSON.stringify({ selector: '.viewport__stage canvas', ...c, read }),} });assert.equal(run.status, 0, run.stderr);const line = run.stdout.split('\n').find(line => line.startsWith('[editorDrag] '));assert(line, 'No trusted drag observation');const result = JSON.parse(line.slice('[editorDrag] '.length));+ records.push({ name, ...result });+ fs.writeFileSync(path.join(out, 'observations.json'), JSON.stringify({ status: 'checking', records }, null, 2));const before = result.before.scene, after = result.after.scene;assert.deepEqual(result.after.undone, before, 'A single undo did not restore all targets');if (c.cancel) assert.deepEqual(after, before, 'Escape failed to restore the transaction');else {- assert.notDeepEqual(after, before, 'Gesture did not change the scene');+ assert.notDeepEqual(after, before, 'Gesture did not change the scene: ' + name);if (c.alt) {assert.equal(after.length, 4, 'Alt did not duplicate the selection');for (const initial of before) assert.deepEqual(after.find(t=>t.id===initial.id), initial, 'Alt modified an original');@@ -77,11 +84,12 @@ try {else if (c.pivot === 'individual') assert.deepEqual(t.position, initial.position, 'Individual origin moved');else assert.notDeepEqual(t.position, initial.position, 'Shared center did not move target');if (c.mode === 'rotate') assert.notDeepEqual(t.rotation, initial.rotation);+ else assert.deepEqual(t.rotation, initial.rotation, 'Gesture also rotated the target');+ if (c.mode !== 'scale') assert.deepEqual(t.scale, initial.scale, 'Gesture also scaled the target');if (c.mode === 'scale') { near(t.scale.x, 2); near(t.scale.y, 1); near(t.scale.z, 1); }}}assert(fs.existsSync(path.join(out, name + '.png')), 'Missing restored-scene PNG');- records.push({ name, ...result });}assert.deepEqual(records.find(r=>r.name==='individual-move').after.scene,records.find(r=>r.name==='center-move').after.scene, 'Translation changed with the pivot policy');