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
fix: apply pivot-to-center offset in editor world transform for UI gizmo alignment
esengine1edf861b71f0
diff --git a/editor/src/renderer/EditorSceneRenderer.ts b/editor/src/renderer/EditorSceneRenderer.tsindex ef3da01f5..d94c0539f 100644--- a/editor/src/renderer/EditorSceneRenderer.ts+++ b/editor/src/renderer/EditorSceneRenderer.ts@@ -307,8 +307,31 @@ export class EditorSceneRenderer {const registry = this.sceneManager_.registry;if (!registry.hasTransform(entity)) return null;const wt = registry.getTransform(entity);++ let px = wt.worldPosition.x;+ let py = wt.worldPosition.y;++ if (registry.hasUIRect(entity) && registry.hasSprite(entity)) {+ const uiRect = registry.getUIRect(entity);+ const sprite = registry.getSprite(entity);+ let dx = (0.5 - uiRect.pivot.x) * sprite.size.x * wt.worldScale.x;+ let dy = (0.5 - uiRect.pivot.y) * sprite.size.y * wt.worldScale.y;+ const sinHalf = wt.worldRotation.z;+ if (sinHalf * sinHalf > 1e-6) {+ const cosHalf = wt.worldRotation.w;+ const s = 2.0 * sinHalf * cosHalf;+ const c = cosHalf * cosHalf - sinHalf * sinHalf;+ const rdx = dx * c - dy * s;+ const rdy = dx * s + dy * c;+ dx = rdx;+ dy = rdy;+ }+ px += dx;+ py += dy;+ }+return {- position: { x: wt.worldPosition.x, y: wt.worldPosition.y, z: wt.worldPosition.z },+ position: { x: px, y: py, z: wt.worldPosition.z },rotation: { x: wt.worldRotation.x, y: wt.worldRotation.y, z: wt.worldRotation.z, w: wt.worldRotation.w },scale: { x: wt.worldScale.x, y: wt.worldScale.y, z: wt.worldScale.z },};