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 enabled state of the script.
The enabled state of the script.
Sets the enabled state of the script.
The enabled state of the script.
Gets the name of the script.
The name.
Sets the name of the script to create. The name attribute is the single source of truth
(it is what the parent <pc-script> element reads when creating the instance), so the
property writes through to it — assigning before insertion works as expected:
const script = document.createElement('pc-script-instance');
script.name = 'rotate';
scriptsElement.appendChild(script);
await script.ready();
The name.
Sets the attributes of the script as an object. Values are converted with the same rules
as the attributes attribute: asset:/entity: references and vec2:/vec3:/vec4:/
color: prefixed strings are resolved, and a plain numeric array is converted to the
type of the attribute it targets when that attribute currently holds a Vec2, Vec3, Vec4
or Color.
The attributes of the script.
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.
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 ScriptInstanceElement interface provides properties and methods for manipulating
<pc-script-instance>elements. The ScriptInstanceElement interface also inherits the properties and methods of the AsyncElement interface.Script attributes can be supplied through two channels:
focus-point→focusPoint). Values are parsed according to the type of the attribute's current value — initially the script's declared default (numbers, booleans, strings, Vec2/3/4, Color, Quat as Euler angles) — and theasset:/entity:/vec2:/vec3:/vec4:/color:prefixes may be used to be explicit.attributesJSON attribute: an object supporting nested structures and attribute names that collide with reserved HTML attribute names (e.g.title).When both specify the same attribute, the per-property attribute wins — at creation and whenever either channel changes at runtime. The element's own
nameandenabledattributes configure the element itself and are not script attributes.Changing
nameon a live element destroys the old-name script instance and creates the new-name one, re-applying both attribute channels to it.The element becomes ready once its script instance has been created by the parent
<pc-script>element.Fires
scriptattributeschange - Fired when the script's attributes change. The
detailcarries the newattributesobject. Bubbles.Fires
scriptenablechange - Fired when the script's enabled state changes. The
detailcarries the newenabledstate. Bubbles.Fires
scriptnamechange - Fired when the script is renamed on a live element. The
detailcarriesoldNameandnewName. Bubbles.