Skip to content

feat(visual): center layout visuals that have no transform - #388

Merged
han4wluc merged 2 commits into
mainfrom
feat/center-layout-visuals-without-transform
Nov 15, 2026
Merged

han4wluc merged 2 commits into
mainfrom
feat/center-layout-visuals-without-transform

Conversation

@han4wluc

@han4wluc han4wluc commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem

A layout visual, whether it has an inline layout or a resourceId that names a layout resource, throws Visual item "…" requires transformId or transform when it has no transform.

An authoring tool that edits a visual as a full screen layout has no transform to give it: the layout's elements are already placed on the screen. Requiring a predefined or inline transform for that case forces the tool to invent one, and a predefined transform made for character sprites (for example a bottom-left anchor) moves the whole layout off the screen.

Fix

  • A layout visual without transformId or transform is centered on the screen at scale 1, like a background: its container is drawn at the screen's center with anchor 0.5, 0.5. The container is the size of the screen unless the layout sets width and height, so a screen-sized layout covers the screen and each element keeps the position it was authored at. A scale or rotation turns the layout around the screen's center.
  • Top-level transform fields still override that placement, and a visual with a transform is placed exactly as before.
  • Image, video, spritesheet, particle and text visuals still need a transform.
  • An inline layout may carry a source field. The engine keeps it in the presentation state and never draws it, so an authoring tool can map what is presented back to the form it edits. The schema and docs/RouteEngine.md document it.
  • Bumps the version to 1.52.0.

No existing project data changes behaviour: a layout visual without a transform could not render before.

Tests

  • spec/visualInlineLayout.test.js: an inline layout and a layout resource without a transform are centered on the screen and keep their elements' positions; on a 1280×720 screen the center is 640, 360; a layout with its own width and height is centered at that size; top-level x, anchorX, scaleX and rotation override the centered placement; a later line that changes only the opacity keeps the layout centered; a layout resource with a transform is placed by it; a resource visual without a transform still throws; a layout's source stays in the presentation state and is not drawn.
  • spec/system/renderState/addVisuals.spec.yaml: the render state of an inline layout without a transform.

bun run test (2602 tests), bun run lint, bun run format:changed and bun run build pass.

A layout visual, with an inline layout or a layout resource, no longer needs
a transform. Without transformId or transform it is centered on the screen at
scale 1, like a background, so a screen-sized layout covers the screen and its
elements keep the positions they were authored at. Top-level transform fields
still override that placement. Image, video, spritesheet, particle and text
visuals still need a transform.

An inline layout may now carry a `source` field, which the engine keeps in the
presentation state and never draws, so an authoring tool can map what is
presented back to the form it edits.

Bumps the version to 1.52.0.
@han4wluc
han4wluc merged commit 87a180f into main Nov 15, 2026
46 checks passed
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.

1 participant