Protected_The application element this entity is registered with, cached at registration time so the entity can be unregistered even once this element has left the DOM.
Protected_Whether this entity has its place in the hierarchy: it has been parented, or it is the root of an inserted subtree, which is parented once the subtree under it is built. Read by subclasses that gate work on the entity being built.
Protected_Whether the element has connected: its connectedCallback has run since it was last put in the document. Set and cleared by the subclasses, whose callbacks those are. An element in the document that has yet to connect has only just arrived, in the DOM operation that is still connecting what it inserted - which is how a root tells the elements that arrived with it from the ones that were there before.
The enabled state of the entity.
The name of the entity.
Gets the id of the pc-asset to use for the model.
The asset ID.
Sets the id of the pc-asset to use for the model.
The asset ID.
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.
The root entity of the instantiated model content, parented beneath the host entity.
null until the container asset has loaded and been instantiated, after a failed load,
and again once the element has been removed from the document.
The content root entity, or null.
Gets the tags of the entity.
The tags of the entity.
Sets the tags of the entity.
The tags of the entity.
Protected_Builds this element and everything declared under it, in an application whose hierarchy already exists - along with the elements that arrived beside it. Called when the element connects.
Everything is assembled before any of it joins the scene: the entities, the content of
every model whose container has loaded, and every component with the script instances
whose class is registered. Adding the root entity to its parent then enables the whole
hierarchy at once, as the engine does for a hierarchy handed to addChild: every script
in it runs initialize(), and then every script runs postInitialize(), with every
entity and component in place. Each element reports ready as it is built, which is before
its root joins the scene.
One DOM operation can insert several entity-owning elements side by side: the children of
a fragment or a cloned template, of innerHTML, or the arguments of append. The first
of them to connect builds them all, so that what one declares can refer to another, and
then adds them to the scene one after the other, in document order. Each is a hierarchy of
its own to the engine, as each would be in as many calls to addChild: the scripts of one
have initialized and post-initialized before the next joins the scene.
While the application is still preloading, only the entities are built. The application builds every component under it once preload has finished, and starts its scripts together.
An element whose ancestor is assembling the subtree it belongs to, or which another element has built, has nothing left to do here.
The application element, which has built its hierarchy.
Protected_Starts (or restarts) the content load once the host has been built. Readiness is not announced here — it tracks the content settling, not the host being built.
Protected_Extends the owner reset for the content: the engine's destroy cascade has already taken the content root down with the host subtree, so only the reference and the in-flight load are dropped here. The next build re-creates the host and re-instantiates the content.
The host entity that was destroyed.
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_Registers entity as this element's backing entity with the owning application, which
joins engine nodes back to elements by identity (never by name).
The entity to register.
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.
Protected_Removes the registration for entity.
The entity to unregister.
Returns a snapshot of the instantiated node tree, or null while there is none (the
container asset has not loaded, or the element has left the document). One call grounds a
session — a browser console, a test, an agent — in the vocabulary pc-node binding
resolves against: the instantiated names (HierarchyNode.name), paths, match
indices, attached component types and the material assignments of render components
(HierarchyNode.materials). String(...) of the result, or of any node in it,
is the printable form.
The snapshot is plain data, computed afresh each call: it does not follow later changes to the hierarchy, and mutating it changes nothing. It covers the instantiated content only — the host entity the element fronts is not part of the asset's node tree.
The root of the instantiated node tree, or null.
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 ModelElement interface provides properties and methods for manipulating
<pc-model>elements. The ModelElement interface also inherits the properties and methods of the HTMLElement interface.The element creates and fronts a stable host entity:
entityis that host, created when the application builds its hierarchy and kept acrossassetchanges, so the element's transform and tags are instance placement that composes with whatever transform the asset authored on its root. The instantiated content is parented beneath the host and exposed as contentEntity.The element becomes ready once its current asset selection has settled: the container asset has loaded and its content root has been parented beneath the host, the load has failed (
contentEntitystaysnull— listen forerror, or checkcontentEntity, to tell the outcomes apart), or no asset is assigned at all. Changingassetre-arms readiness and instantiates anew, so aready()obtained after the change resolves against the new content. Apc-modeloutside apc-app, or referencing an unknown asset id, warns and never becomes ready.The pointer events below are dispatched by the containing
<pc-app>element when the pointer intersects the model's geometry, exactly as for<pc-entity>— a hit on a content node that nopc-nodefronts resolves to this element.Attribute
enabled - The enabled state of the model.
Attribute
name - The name of the model.
Attribute
position - The position of the model.
Attribute
rotation - The rotation of the model.
Attribute
scale - The scale of the model.
Attribute
tags - The tags of the model.
Attribute
onpointerover - Script to run when the pointer moves onto the model, or onto an entity below it.
Attribute
onpointerenter - Script to run when the pointer moves onto the model or an entity below it, having been over none of them.
Attribute
onpointermove - Script to run when the pointer moves over the model.
Attribute
onpointerdown - Script to run when a pointer button is pressed over the model.
Attribute
onpointerup - Script to run when a pointer button is released over the model.
Attribute
onpointercancel - Script to run when the browser cancels a press that began over the model, for example because a touch became a scroll.
Attribute
onpointerout - Script to run when the pointer moves off the model, or off an entity below it.
Attribute
onpointerleave - Script to run when the pointer moves off the model and every entity below it.
Attribute
onclick - Script to run when the model is clicked: a primary pointer button pressed and then released over it.
Fires
pointerover - Fired when the pointer moves onto the model. Bubbles;
relatedTargetis the element the pointer came from, which is<pc-app>when it came from the background.Fires
pointerenter - Fired when the pointer moves onto the model or an entity below it, having been over none of them. Does not bubble.
Fires
pointermove - Fired when the pointer moves over the model.
Fires
pointerdown - Fired when a pointer button is pressed over the model.
Fires
pointerup - Fired when a pointer button is released over the model.
Fires
pointercancel - Fired on the model a press began over when the browser cancels that press, for example because a touch became a scroll. No click follows.
Fires
pointerout - Fired when the pointer moves off the model. Bubbles;
relatedTargetis the element the pointer went to, which is<pc-app>when it went to the background.Fires
pointerleave - Fired when the pointer moves off the model and every entity below it. Does not bubble.
Fires
click - Fired when a primary pointer button is pressed and then released over the model. A press and release that picked different elements fires on their nearest common ancestor instead, as in the DOM.
detailcarries the click count, so a double click arrives as a click whosedetailis 2.Fires
load - Fired each time a container asset finishes instantiating, including re-instantiation after
assetchanges. Does not bubble — listen on this element, or use a capture-phase listener on an ancestor.Fires
error - Fired when the container 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.