Files
artcraft/frontend/apps
Tanish Manku abf2e1d6c2 PageScene: extract GizmoController from editor.ts
Third step of the editor.ts decomposition. Pulls TransformControls
ownership and the gizmo lifecycle out of Editor into a focused module.

GizmoController owns:
  control (TransformControls).

Methods take their dependencies as method arguments — no `editor`
reference, no `import type Editor`, no circular import:
  configure(camera, domElement, scene, callbacks)
  changeMode(type, space)
  setSpace(space)
  canToggleSpace()
  attach(object), detach()
  addToScene(scene), removeFromScene(scene)
  setVisible(v), isVisible()

Editor exposes the gizmo as `editor.gizmo` and constructs it empty in
the constructor; configure() is called from initialize() once camera
and renderer exist. The two existing public methods stay on Editor as
facades, so the external callers (actions/setTransformMode.ts,
comps/Controls3D.tsx, engine/keymap.ts) keep working unchanged:
  Editor.change_mode reads the store's transformSpace and forwards.
  Editor.toggleTransformSpace toggles the store and pushes into gizmo.

External readers updated:
  helper.ts (SceneUtils.lockUnlockObject + removeTransformControls)
    routes through editor.gizmo.attach/detach/addToScene/removeFromScene
    instead of poking editor.control directly.
  Editor.snapShotOfCurrentFrame uses editor.gizmo.setVisible /
    isVisible instead of touching control.visible.
  Editor passes editor.gizmo.control to the MouseControls constructor
    where it previously passed editor.control.

Dead code removed:
  - transform_interaction on Editor: passed by value to MouseControls
    (which has its own internal copy that overrides) and the `= true`
    write in change_mode mutated a field nothing read. Pure dead code.
  - The "if (this.control == undefined) return;" guard immediately
    after `new TransformControls(...)` — that branch was unreachable.
  - Unused TransformControls import in editor.ts.

Net: editor.ts down to 1196 LOC. Typecheck error count drops by 3.
2026-04-30 11:05:00 -07:00
..
2026-03-12 21:35:29 +07:00