Skip to content

Align scene origin axis visibility handling - #855

Open
bofeng-song wants to merge 1 commit into
cocos:mainfrom
bofeng-song:fix/scene-origin-axis-creator-parity
Open

Align scene origin axis visibility handling#855
bofeng-song wants to merge 1 commit into
cocos:mainfrom
bofeng-song:fix/scene-origin-axis-creator-parity

Conversation

@bofeng-song

@bofeng-song bofeng-song commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Releated issue: https://zentao.sud.center/index.php?m=bug&f=view&bugID=863

Summary

  • Align scene origin axis initialization with Creator by letting each camera controller restore its own axis settings.
  • Keep inactive 2D/3D camera controller grids hidden when axis visibility is updated externally.
  • Refresh 3D origin axis data independently from node active state so axes are correct immediately after switching back from 2D.

Problem

After switching the scene editor to 2D mode, creating a new scene, and then switching back to 3D, the scene origin axes could render incorrectly. In some cases the 2D green axis leaked into the 3D view; in another case only one 3D origin axis appeared until the mouse wheel triggered another grid update.

Root Cause

CameraService.initFromConfig() restored both originAxis2D and originAxis3D at the same time. This differs from Creator, where each camera controller restores its own origin-axis configuration during controller initialization. In CLI, both controllers coexist and configuration restoration is asynchronous, so applying both axis configs from CameraService could activate the inactive controller's axis nodes.

The 3D controller also skipped origin-axis data updates when the axis node was inactive. During a 2D to 3D switch, showGrid(true) updates grid data before the 3D origin-axis nodes are reactivated, so one axis could stay stale until another camera update occurred.

Changes

  • Moved initial origin-axis config restore into CameraController2D and CameraController3D.
  • Stopped CameraService from applying originAxis2D and originAxis3D during initial gizmo config restore.
  • Added controller grid visibility synchronization for external origin-axis updates.
  • Removed active-node guards from 3D origin-axis data updates to match Creator's update flow.
  • Added tests for CameraService gizmo restore behavior and inactive controller visibility handling.

Verification

  • npm run test -- --runTestsByPath src/core/scene/test/camera-view-mode-config.test.ts src/core/scene/test/scene-configs.test.ts --runInBand
  • npx tsc -b --pretty false
  • npm run build:static-web

@bofeng-song
bofeng-song force-pushed the fix/scene-origin-axis-creator-parity branch from f21c92f to ad883a4 Compare August 13, 2026 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants