The 2D layer · interface

UiNode

A node.

Explained in Sprites and tilemaps.

interface UiNode
import type { UiNode } from '@driftengine/ui2d';

In depth

An object with mutable fields rather than a row of typed arrays, and this is the one place in this package where that is the right answer. An interface tree is tens or hundreds of nodes built once and mutated, not thousands rebuilt per frame — the case struct-of-arrays exists for. What the hot path needs is that laying one out and drawing it allocates nothing, and both write into fields that already exist.

Properties

NameTypeDescription
childrenreadonlyUiNode[]
parentUiNode | null
direction'row' | 'column'
widthUiSize
heightUiSize
paddingLeftnumber
paddingTopnumber
paddingRightnumber
paddingBottomnumber
gapnumber
alignUiAlign
justifyUiJustify
absoluteboolean
xnumber
ynumber
contentWidthnumber
contentHeightnumber
hiddenboolean
clipbooleanWhether this node cuts its descendants to its own rectangle. See uiClip.ts.
scrollXnumberHow far this node's contents are moved under it. See uiScroll.ts.
scrollYnumber
contentSpanXnumberHow far the placed children reach past this node's content origin, along each axis.
More

Written by layoutUiTree and independent of the current scroll, because it is measured relative to the content origin that the scroll already moved — the offset cancels. That independence is the point: an extent derived from placed positions plus the live scroll value is wrong the moment the two disagree, which is exactly when a caller is scrolling.

contentSpanYnumber
layernumberDraw order beyond tree order. See uiLayer.ts.
rectreadonlyUiRectWhere this node ended up. Meaningless until layoutUiTree has run over its root.
measuredWidthnumberWhat it measured to along each axis, before the parent distributed anything.
measuredHeightnumber
backgroundFloat32Array | null
texturenumber
frameSpriteFrame | null
tintFloat32Array | null
textstring
interactiveboolean
focusableboolean
hoveredboolean
pressedboolean
namestring