Files
artcraft/frontend/apps
Tanish Manku c352edd38c PageScene: extract ViewportController from editor.ts
First step of the editor.ts decomposition (refactor/3d-editor-cleanup).
Pulls the canvas/container DOM seam, the ResizeObserver, and the resize
cascade out of the ~1450-LOC Editor class into a standalone module.

ViewportController owns container, canvReference, canvasRenderCamReference,
the ResizeObserver, lastCanvasSize, plus the onWindowResize / observed
resize logic.

Engine fields are forwarded explicitly through the `engine` constructor
argument:
  - cameras, renderer, render aspect ratio: closure-based getters that
    resolve at call time
  - post-processing: a single resizePostProcessing(w, h) callback rather
    than three composer field getters

The single callback is deliberate. The original code creates the main
composer in _configurePostProcessing but the raw composer + custom
outline pass much later in _configurePostProcessingRaw, with the first
viewport.onWindowResize() landing between the two. Three separate
composer getters would have ViewportController peeking at fields that
don't exist yet at that first resize and silently no-op'ing via `?.`.
The callback hides that lifecycle concern inside the post-processing
module, where it belongs.

No `import type Editor`, no circular import. The dead `update*` and
`*MayReset` accessors that the original code carried as defensive
fallbacks (with self-deprecating "we should not need this" comments)
were never actually called and are dropped here. containerMayReset
stays — it has live internal callers.

Editor exposes the controller as `editor.viewport` and routes its
internal call sites through `this.viewport.<method>()`.

Net: editor.ts loses ~107 lines and one cohesive responsibility.
2026-04-30 10:37:29 -07:00
..
2026-03-12 21:35:29 +07:00