HomeWeb Components API Reference - v0.29.0
    Preparing search index...

    Class SpriteClipElement

    The SpriteClipElement interface provides properties and methods for manipulating <pc-sprite-clip> elements. The SpriteClipElement interface also inherits the properties and methods of the AsyncElement interface.

    A clip declares one named animation on its parent <pc-sprite>: the frames of its sprite asset, played in frame-key order at fps frames per second. Names must be unique within a <pc-sprite>. The element becomes ready once its clip is added to the sprite component, which loads the sprite asset itself.

    Hierarchy (View Summary)

    Index
    • get asset(): string

      Gets the id of the pc-asset of the sprite whose frames the clip plays.

      Returns string

      The sprite asset id.

    • set asset(value: string): void

      Sets the id of the pc-asset of the sprite whose frames the clip plays.

      Parameters

      • value: string

        The sprite asset id.

      Returns void

    • get closestApp(): AppElement | null

      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.

      Returns AppElement | null

      The closest app element, or null.

    • get closestEntity(): EntityBaseElement | 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.

      Returns EntityBaseElement | null

      The closest entity-fronting element, or null.

    • get fps(): number

      Gets the rate the clip plays at, in frames per second, where a negative rate plays a looping clip backwards and ends one that does not loop at once.

      Returns number

      The frames per second.

    • set fps(value: number): void

      Sets the rate the clip plays at, in frames per second, where a negative rate plays a looping clip backwards. A clip starts on its first frame whichever way it plays, so a looping clip at a negative rate wraps round to its last frame and counts down from there, while one that does not loop ends at once. Defaults to 0, which holds the first frame.

      Parameters

      • value: number

        The frames per second.

      Returns void

    • get loop(): boolean

      Gets whether the clip loops.

      Returns boolean

      Whether the clip loops.

    • set loop(value: boolean): void

      Sets whether the clip loops. A clip that does not loop stops on its last frame. Defaults to false.

      Parameters

      • value: boolean

        Whether the clip loops.

      Returns void

    • get name(): string

      Gets the name of the clip, which the parent <pc-sprite>'s clip attribute selects it by.

      Returns string

      The clip name.

    • set name(value: string): void

      Sets the name of the clip, which the parent <pc-sprite>'s clip attribute selects it by. Names must be unique within a <pc-sprite>.

      Parameters

      • value: string

        The clip name.

      Returns void

    • 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.

      Returns void

    • 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 void

    • 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.

      Returns Promise<SpriteClipElement>

      A promise that resolves with this element when it's ready.