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

    Class AppElement

    The AppElement interface provides properties and methods for manipulating <pc-app> elements. The AppElement interface also inherits the properties and methods of the HTMLElement interface.

    progress - Fired while the application preloads its assets. loaded and total are asset counts, not bytes, and an asset that fails to load still counts as loaded. Fired at least once per boot, and the final event always has loaded equal to total. Does not bubble.

    Hierarchy (View Summary)

    Index
    • get alpha(): boolean

      Gets the alpha flag.

      Returns boolean

      The alpha flag.

    • set alpha(value: boolean): void

      Sets the alpha flag.

      Parameters

      • value: boolean

        The alpha flag.

      Returns void

    • get antialias(): boolean

      Gets the antialias flag.

      Returns boolean

      The antialias flag.

    • set antialias(value: boolean): void

      Sets the antialias flag.

      Parameters

      • value: boolean

        The antialias flag.

      Returns void

    • get app(): AppBase | null

      The PlayCanvas application instance. null until the element is ready, and again once it has been removed from the document — await whenReady or the element's ready() promise before accessing it.

      Returns AppBase | null

      The application instance, or null.

    • get backend(): "webgpu" | "webgl2" | "null"

      Gets the graphics backend.

      Returns "webgpu" | "webgl2" | "null"

      The graphics backend.

    • set backend(value: "webgpu" | "webgl2" | "null"): void

      Sets the graphics backend. Defaults to 'webgpu', which falls back to 'webgl2' if WebGPU is not supported by the browser.

      Parameters

      • value: "webgpu" | "webgl2" | "null"

        The graphics backend ('webgpu', 'webgl2', or 'null').

      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(): EntityElement | 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.

      Returns EntityElement | null

      The closest entity element, or null.

    • get depth(): boolean

      Gets the depth flag.

      Returns boolean

      The depth flag.

    • set depth(value: boolean): void

      Sets the depth flag.

      Parameters

      • value: boolean

        The depth flag.

      Returns void

    • get highResolution(): boolean

      Gets the high resolution flag.

      Returns boolean

      The high resolution flag.

    • set highResolution(value: boolean): void

      Sets the high resolution flag. When true, the application will render at the device's physical resolution. When false, the application will render at CSS resolution.

      Parameters

      • value: boolean

        The high resolution flag.

      Returns void

    • get loadingBar(): boolean

      Gets whether the application shows its built-in loading bar while it boots and preloads its assets.

      Returns boolean

      The loading bar flag.

    • set loadingBar(value: boolean): void

      Sets whether the application shows its built-in loading bar while it boots and preloads its assets. Enabled by default; setting false removes the bar immediately, while setting true has no effect until the element is next connected. The bar can be themed with the CSS custom properties --pc-loading-bar-color, --pc-loading-bar-background and --pc-loading-bar-height.

      Parameters

      • value: boolean

        The loading bar flag.

      Returns void

    • get loadProgress(): number

      The asset preload progress of the application, as a fraction from 0 to 1. It is 0 until preloading begins (and again once the element has been removed from the document), and 1 once preloading has finished — including when there was nothing to preload. Read this to initialize a loading UI; subsequent updates arrive via the progress event.

      Returns number

      The preload progress.

    • get stencil(): boolean

      Gets the stencil flag.

      Returns boolean

      The stencil flag.

    • set stencil(value: boolean): void

      Sets the stencil flag.

      Parameters

      • value: boolean

        The stencil flag.

      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.

      Returns void