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(viewport): rotate around the view-axis outer ring

yhh89ec61a08140
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 05f198e49..24ac21a73 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,10 @@ published separately; it ships inside the editor.
## [Unreleased]
+### Added
+
+- **Spatial rotation adds a view-axis outer ring.** The outer ring remains a screen circle and uses the presented camera axis captured at the press, with absolute twist snapping and the same undo/cancel path. Local inner rings use their rotated world axis; rotation writes, including Alt copies, convert through each target's parent frame. Flat 2D retains its existing Z ring.
+
## [0.86.1] - 2026-10-15
### Fixed
diff --git a/desktop b/desktop
index 984e4a83d..02d1eed1c 160000
--- a/desktop
+++ b/desktop
@@ -1 +1 @@
-Subproject commit 984e4a83da2f2e767baa97fa0404ca4818b90b54
+Subproject commit 02d1eed1cdcf62beb84c4e9609db259fbede59d3
diff --git a/docs/astro/src/content/docs/editor/viewport.mdx b/docs/astro/src/content/docs/editor/viewport.mdx
index 26b45d96d..95f6ec65f 100644
--- a/docs/astro/src/content/docs/editor/viewport.mdx
+++ b/docs/astro/src/content/docs/editor/viewport.mdx
@@ -27,7 +27,7 @@ handle:
|---|---|---|
| Select | `Q` | Pick / marquee only, no transform handles. |
| Move | `W` | Projected arrows. Spatial views add XY / YZ / ZX planes and screen-plane movement at the center; head-on 2D keeps X / Y and its center plane. |
-| Rotate | `E` | Projected axis rings; head-on 2D shows the Z ring. |
+| Rotate | `E` | Projected axis rings; spatial views add a circular screen-axis outer ring. Head-on 2D shows the original Z ring. |
| Scale | `R` | Projected axis boxes. Spatial views add plane handles and XYZ uniform scaling at the center; head-on 2D keeps two-axis center scaling. |
| 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. |
@@ -46,6 +46,13 @@ The spatial move center follows a plane parallel to the presented camera through
the selection pivot, captured at the start of the drag. Scale's spatial center
applies one factor to X, Y and Z. These gestures keep single-step undo and Esc.
+The spatial rotation outer ring stays circular on screen. It turns about the
+presented camera's forward axis captured at the press, regardless of Local mode.
+Inner rings use the projected Local or World axis they draw. Rotation writes are
+converted through each target's parent frame, including Alt copies. Outer-ring
+snapping rounds the primary object's signed quaternion twist about the view axis;
+the ring radius and axis remain fixed until the drag ends.
+
Hovering a transform handle highlights the handle that a press will grab. The
cursor shows moving, rotation or the projected resize direction. Camera or
selection changes recompute the target; leaving the canvas clears it. Navigation,
diff --git a/docs/astro/src/content/docs/zh-cn/editor/viewport.mdx b/docs/astro/src/content/docs/zh-cn/editor/viewport.mdx
index f33ebedc6..5e49c9ed1 100644
--- a/docs/astro/src/content/docs/zh-cn/editor/viewport.mdx
+++ b/docs/astro/src/content/docs/zh-cn/editor/viewport.mdx
@@ -25,7 +25,7 @@ description: "视口导航、变换 gizmo、对齐与分布、显示开关、Sce
|---|---|---|
| 选择 | `Q` | 只做拾取/框选,无变换手柄。 |
| 移动 | `W` | 投影后的轴向箭头;空间视角增加 XY / YZ / ZX 平面与中心屏幕平面移动,正面 2D 保留 X / Y 和中心平面。 |
-| 旋转 | `E` | 投影后的轴向旋转环;正对 2D 时显示 Z 环。 |
+| 旋转 | `E` | 投影后的轴向旋转环;空间视角增加屏幕圆形的视线轴外圈,正面 2D 保留原 Z 环。 |
| 缩放 | `R` | 投影后的轴向方块;空间视角增加平面手柄与中心 XYZ 等比缩放,正面 2D 保留中心两轴缩放。 |
| Rect | `T` | 选中精灵或 UI 节点自身的矩形手柄。 |
| 万能变换 | `Y` | 同时显示移动箭头与中心平面、外侧缩放方块和旋转环。 |
@@ -41,6 +41,11 @@ W / E / R 单独工具仍可使用,T 仍为 Rect。
拖拽开始时固定该平面;缩放中心对 X / Y / Z 应用同一倍数。
这些操作仍是一步撤销,按 Esc 取消。
+空间旋转外圈保持屏幕圆形,绕按下时已呈现相机的前向轴旋转,不受 Local
+坐标系影响。内环按绘制出的 Local / World 轴旋转;写回姿态时通过各对象的
+父节点坐标系换算,Alt 副本也遵守同一规则。外圈吸附按主对象绕视线轴的
+有符号四元数扭转角取整;本次拖拽的半径与旋转轴会保持到拖拽结束。
+
悬停变换手柄会高亮实际按下时将抓到的手柄,光标显示移动、旋转或投影后的
缩放方向。相机或选择变化会重新判断,离开画布即清除。导航、绘制、拾取和
贡献工具保留自己的指针路由;仅悬停不会修改变换或开启撤销事务。
diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjs
index 6fd577248..77a99c0ed 100644
--- a/tools/releaseNotes.mjs
+++ b/tools/releaseNotes.mjs
@@ -56,6 +56,8 @@ export const NOTED = {
{ note: 'Web audio startup failures release pooled nodes and keep resumes retryable.' },
'fix(tilemap): clip fills and preserve signed coordinate edges':
{ note: 'Tilemap rectangle fills clip safely across integer coordinate bounds.' },
+ 'feat(viewport): rotate around the view-axis outer ring':
+ { note: 'Spatial rotation adds a view-axis outer ring.' },
'fix(animation): keep paused sprite motions out of exit transitions':
{ note: 'Paused sprite motions wait for actual completion before exit transitions.' },
'feat(viewport): add spatial plane and center handles':
diff --git a/tools/verify-gizmo-planes.mjs b/tools/verify-gizmo-planes.mjs
index 47037fdef..d57ff4e91 100644
--- a/tools/verify-gizmo-planes.mjs
+++ b/tools/verify-gizmo-planes.mjs
@@ -18,13 +18,13 @@ fs.writeFileSync(path.join(project,'src/main.ts'),'export {};');fs.writeFileSync
const read=`(async()=>{const e=window.__estellaEditor;const snap=()=>{const t=e.surface.serializeScene().entities.find(v=>v.id===1).components.find(c=>c.type==='Transform').data;return {position:t.position??{x:0,y:0,z:0},scale:t.scale??{x:1,y:1,z:1},rotation:t.rotation??{x:0,y:0,z:0,w:1}};};const pose=snap(),layout=e.gizmoLayout();if(!window.__planesRead){window.__planesRead=true;return {pose,layout};}e.surface.undo();const undone=snap();e.surface.setViewPerspective(false);e.surface.setViewOrbit(0,0);e.runCommand('tool.move');await new Promise(resolve=>requestAnimationFrame(()=>requestAnimationFrame(resolve)));return {pose,layout,undone,flatLayout:e.gizmoLayout()};})()`;
const records=[];
try{
- for(const axis of ['xy','yz','zx','view','xyz']){
- const mode=axis==='xyz'?'scale':'move';
- const point=`(()=>{const g=window.__estellaEditor.gizmoLayout();if(!g?.spatial)throw Error('Missing spatial frame');${axis==='view'||axis==='xyz'?'return g.screen;':`const p=g.planes.find(p=>p.axis==='${axis}');if(!p)throw Error('Missing ${axis} plane');return {x:g.screen.x+p.corners.reduce((n,p)=>n+p.x,0)/4,y:g.screen.y+p.corners.reduce((n,p)=>n+p.y,0)/4};`}})()`;
+ for(const axis of ['xy','yz','zx','view','xyz','rotate-view']){
+ const mode=axis==='xyz'?'scale':axis==='rotate-view'?'rotate':'move';
+ const point=`(()=>{const g=window.__estellaEditor.gizmoLayout();if(!g?.spatial)throw Error('Missing spatial frame');${axis==='rotate-view'?"const r=g.rings.find(r=>r.axis==='view');if(!r)throw Error('Missing view ring');return {x:g.screen.x+r.radius,y:g.screen.y};":axis==='view'||axis==='xyz'?'return g.screen;':`const p=g.planes.find(p=>p.axis==='${axis}');if(!p)throw Error('Missing ${axis} plane');return {x:g.screen.x+p.corners.reduce((n,p)=>n+p.x,0)/4,y:g.screen.y+p.corners.reduce((n,p)=>n+p.y,0)/4};`}})()`;
const run=runElectron(['.'],{via:'npx',encoding:'utf8',cwd:path.join(root,'desktop'),timeout:180000,env:{
ESTELLA_SHOT:path.join(out,axis+'.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.surface.setViewPerspective(true);e.surface.setViewOrbit(45,30);e.surface.select(1);e.frame([1]);await new Promise(r=>setTimeout(r,750));e.runCommand('tool.${mode}');const layout=e.gizmoLayout();if(!layout?.spatial)throw Error('Spatial view was reset before drag: '+JSON.stringify({view:e.editorView(),orbit:e.surface.viewOrbit(),layout}));return {view:e.editorView(),layout};})()`,
- ESTELLA_SHOT_EDITOR_DRAG:JSON.stringify({selector:'.viewport__stage canvas',point,dx:axis==='xyz'?58:11,dy:axis==='xyz'?0:7,read})}});
+ ESTELLA_SHOT_EDITOR_DRAG:JSON.stringify({selector:'.viewport__stage canvas',point,dx:axis==='rotate-view'?-54:axis==='xyz'?58:11,dy:axis==='rotate-view'?54:axis==='xyz'?0:7,captureAfter:path.join(out,axis+'-spatial.png'),read})}});
fs.writeFileSync(path.join(out,axis+'.log'),run.stdout+'\n'+run.stderr);
assert.equal(run.status,0,run.stderr);const line=run.stdout.split('\n').find(l=>l.startsWith('[editorDrag] '));assert(line,'Missing trusted spatial drag: '+axis+'\n'+run.stdout+'\n'+run.stderr);
const result=JSON.parse(line.slice('[editorDrag] '.length));records.push({axis,...result});
@@ -33,8 +33,14 @@ try{
assert(result.after.flatLayout,'Missing 2D frame after projection reset');
assert.equal(result.after.flatLayout.spatial,false,'Tool selection restored the 3D view after switching back to 2D');
assert.deepEqual(result.after.undone,before,'Single undo did not restore the pose');
- assert.deepEqual(after.rotation,before.rotation,'Plane drag also rotated the subject');
- if(axis==='xyz'){
+ if(axis!=='rotate-view')assert.deepEqual(after.rotation,before.rotation,'Plane drag also rotated the subject');
+ if(axis==='rotate-view'){
+ assert.deepEqual(after.position,before.position);assert.deepEqual(after.scale,before.scale);
+ const q=after.rotation,n=result.before.layout.normal;
+ const len=Math.hypot(q.x,q.y,q.z)*Math.hypot(n.x,n.y,n.z);
+ assert(len>1e-6&&Math.abs((q.x*n.x+q.y*n.y+q.z*n.z)/len)>0.9999,'Outer ring did not turn about the presented view axis');
+ assert(Math.abs(2*Math.acos(Math.min(1,Math.abs(q.w)))-Math.PI/2)<0.04,'Outer ring did not turn a quarter circle');
+ }else if(axis==='xyz'){
assert.deepEqual(after.position,before.position);const s=after.scale;
assert(s.x>1.8&&s.x<2.2,'Uniform scale missed its center handle');
assert(Math.abs(s.x-s.y)<1e-6&&Math.abs(s.y-s.z)<1e-6,'Spatial center did not scale XYZ equally');
@@ -50,7 +56,8 @@ try{
}
}
assert(fs.existsSync(path.join(out,axis+'.png')),'Missing restored-pose screenshot');
+ assert(fs.existsSync(path.join(out,axis+'-spatial.png')),'Missing changed spatial-pose screenshot');
}
fs.writeFileSync(path.join(out,'checks.json'),JSON.stringify({status:'checks-passed',records},null,2));
- console.log('Spatial gizmos: XY/YZ/ZX, screen movement, XYZ scale and single-step undo pass');
+ console.log('Spatial gizmos: XY/YZ/ZX, screen movement, XYZ scale, view rotation and single-step undo pass');
}finally{if(!project.startsWith(out+path.sep))throw Error('Unexpected cleanup path');fs.rmSync(project,{recursive:true,force:true,maxRetries:10,retryDelay:50});}