The horizontal and vertical alignment of the text within the element. Each is from 0 to 1,
and applies to text elements only. Defaults to 0.5 0.5, centered; 0 1 aligns to the top
left.
The anchor of the element component. It is the left, bottom, right and top edges as fractions
of the parent's size, in that order. Defaults to 0 0 0 0, the parent's bottom-left corner;
0.5 0.5 0.5 0.5 centers the element.
Whether a text element automatically reduces its font size to fit its height. The size goes
down to min-font-size, so that the text fits within the element's height. Requires
auto-height to be false.
Whether a text element automatically reduces its font size to fit its width. The size goes
down to min-font-size, so that the text fits within the element's width. Requires
auto-width to be false.
Whether the element component should automatically adjust its height. It adjusts to the text content, and applies to text elements only.
Whether the element component should automatically adjust its width. It adjusts to the text content, and applies to text elements only.
The color of the element component.
Whether the element component should use markup.
How the texture or sprite fits the element's rectangle. Applies to image elements only. Can be:
stretch - Fills the rectangle exactly, ignoring the source aspect ratio.contain - Fits within the rectangle, preserving the source aspect ratio.cover - Covers the whole rectangle, preserving the source aspect ratio.Defaults to stretch.
The font size of the element component.
The height of the element component. Defaults to 32.
Whether wrapped lines are stretched flush with both edges of the element, which needs
wrap-lines and a fixed width. The gaps between their words are widened to do it, and it
applies to text elements only. The last line, and any line ended by an explicit line break,
follows alignment instead. Defaults to false.
The extra space between the letters of the text, as a fraction of the font size. Applies to
text elements only. 0.1 adds a tenth of the font size between each pair of characters, like
the CSS letter-spacing property, and a negative value tightens the text. It is added on top
of spacing. Defaults to 0.
The line height of the element component.
Whether the element component is a mask. A mask clips its descendants to its bounds, and applies to image elements only.
The largest font size a text element may use when auto-fitting.
The maximum number of lines wrap-lines wraps the text onto. Any leftover text is appended
to the last line, and it applies to text elements only. Defaults to null, no limit.
The smallest font size a text element may use when auto-fitting.
The opacity of the element component. It ranges from 0 to 1.
The color of the text outline, which is only drawn when outline-thickness is above 0.
Applies to text elements only. Defaults to opaque black.
The thickness of the text outline. It ranges from 0 to 1, and applies to text elements only. Defaults to 0, no outline.
The pivot of the element component. It is the point within its rectangle, as fractions of its
width and height, that sits on its position and that it rotates and scales about. Defaults to
0 0, the bottom-left corner; 0.5 0.5 centers it.
The color of the text shadow, which is only drawn when shadow-offset is not 0 0. Applies
to text elements only. Defaults to opaque black.
The offset of the text shadow. It is horizontal then vertical, each from -1 to 1 and
proportional to the font size, and applies to text elements only. Positive values shift the
shadow right and up. Defaults to 0 0, no shadow.
The spacing between the letters of the text. It is a multiple of their normal spacing, and applies to text elements only. Defaults to 1.
The frame of the sprite to render. Applies to image elements only.
The text of the element component.
The type of the element component.
Whether the element component accepts input events. Buttons and scrolling require it.
The width of the element component. Defaults to 32.
Whether the element component should wrap lines.
The nearest ancestor <pc-app> element, or null if this element has no <pc-app>
ancestor. The search starts at the parent, so an element never resolves to itself.
The closest app element, or null.
The nearest ancestor element that fronts an entity — <pc-entity>, <pc-model> or
<pc-node> — or null if this element has no such ancestor. The search starts at the
parent, so an element never resolves to itself.
The closest entity-fronting element, or null.
Gets the underlying PlayCanvas element component. null until the element is
ready — see ComponentElement.component.
The element component, or null.
Gets the enabled state of the component.
The enabled state of the component.
Sets the enabled state of the component.
The enabled state of the component.
Gets the id of the pc-asset to use for the font.
The font asset ID.
Sets the id of the pc-asset to use for the font (text elements).
The font asset ID.
Sets the margin of the element component (used to inset the element from stretched anchors).
The margin as a Vec4 (left, bottom, right, top).
Gets the number of pixels per unit used when rendering a sprite.
The pixels per unit.
Sets the number of pixels per unit to use when rendering a sprite (image elements only).
The pixels per unit.
Gets the id of the pc-asset to use for the sprite.
The sprite asset ID.
Sets the id of the pc-asset to use for the sprite (image elements only).
The sprite asset ID.
Gets the id of the pc-asset to use for the texture.
The texture asset ID.
Sets the id of the pc-asset to use for the texture (image elements only).
The texture asset ID.
Protected_Called when the element is fully initialized and ready. Subclasses should call this when
they're ready. Resolves the ready promise and dispatches a bubbling, composed ready
event. Signals at most once per readiness cycle: a repeat call before _resetReady
has re-armed the promise does nothing.
Protected_Returns the ready promise to its pending state. Subclasses should call this when the
resource their readiness announced is torn down (typically from disconnectedCallback),
so that a later re-initialization can signal readiness again. Does nothing while the
promise is still pending — an in-flight waiter carries over to the next readiness cycle
rather than being stranded on a promise nothing will ever resolve.
ProtectedgetReturns the data the component is created with: the value of every attribute in the
subclass's schema. Overridden by subclasses that cache their properties themselves, to
supply those. The element's enabled state is not among them: the base class adds it when
it creates the component.
The initial component data.
ProtectedinitConfigures the newly added component. Overridden by subclasses whose setup goes beyond the initial data — child-element handling, asset resolution and the like.
Returns a promise that resolves with this element when it's ready. This is the low-level primitive underlying whenReady, which is the recommended way to wait for elements.
Readiness tracks the element's current lifecycle: once a ready element is torn down (for example by removing it from the document), this returns a fresh promise that resolves when the element is next ready. A promise obtained earlier stays resolved — call this again after re-inserting an element rather than reusing a promise from before its removal.
A promise that resolves with this element when it's ready.
The ElementComponentElement interface provides properties and methods for manipulating
<pc-element>elements. The ElementComponentElement interface also inherits the properties and methods of the HTMLElement interface.Despite the name, this is not a base class or a generic wrapper: it is the engine's 2D UI component, which gives its host entity a rectangle in a
<pc-screen>hierarchy that draws either an image, a line of text or nothing (type="image","text"or"group"). The tag spells the engine component it adds, as every component element does.Engine component: ElementComponent (
element).