The asset that is loaded. Available once the element is ready — await
whenReady or the element's ready() promise before accessing it.
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 <pc-entity> element, or null if this element has no <pc-entity>
ancestor. The search starts at the parent, so an element never resolves to itself.
The closest entity element, or null.
Gets whether the asset should be loaded lazily.
The lazy loading flag.
Sets whether the asset should be loaded lazily.
The lazy loading flag.
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.
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.
A promise that resolves with this element when it's ready.
The AssetElement interface provides properties and methods for manipulating
<pc-asset>elements. The AssetElement interface also inherits the properties and methods of the HTMLElement interface.The element becomes ready once the containing application has started and the asset is in the state declared by the markup: loaded for preloaded assets (even if loading failed — check the asset's
resource), or registered and awaiting a load forlazyassets. Elements inserted while the application is running are created and registered on insertion, and begin loading immediately unlesslazy. Apc-assetmust be a direct child ofpc-app— elements placed elsewhere, or with an unsupported asset type, never become ready.Apart from
lazy, these attributes are read once when the asset is created, so changing them later has no effect.Attribute
id - The identifier used to reference the asset from other elements.
Attribute
src - The URL of the asset to load.
Attribute
type - The asset type. Inferred from the
srcfile extension when omitted.Attribute
data - Additional asset data, as a JSON object.
Attribute
atlas - For a
spriteasset, theidof the texture atlas asset it uses. The atlas must be declared before the sprite.Attribute
frame-keys - For a
spriteasset, the atlas frame keys it uses, separated by spaces or commas.Attribute
pixels-per-unit - For a
spriteasset, the number of pixels per world unit.Attribute
render-mode - For a
spriteasset, how the sprite is rendered when resized.Fires
load - Fired each time the asset finishes loading, including a
lazyasset loaded later and any subsequent reloads. Does not bubble — listen on this element, or use a capture-phase listener on an ancestor to observe every asset.Fires
error - Fired when the asset fails to load, with the engine's error in
message. Does not bubble. The element still becomes ready — readiness means the load settled, not that it succeeded.