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 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-scripts> 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');
script.name = 'rotate';
scriptsElement.appendChild(script);
await script.ready();
The name.
Gets the Script instance created for this element. Returns null until the
instance exists — await whenReady or the element's ready() promise before
accessing it.
The script instance, or null.
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.
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 ScriptElement interface provides properties and methods for manipulating
<pc-script>elements. The ScriptElement 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-scripts>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.