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

    Class SceneElement

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

    The scene element is the ancestor of every entity element, so the pointer events <pc-app> dispatches on entities bubble through it, and it receives its own pointerenter and pointerleave as the pointer moves onto and off its entities as a whole. A listener here is a delegated listener for the whole scene: read event.target to find the entity element hit.

    Hierarchy (View Summary)

    Index
    • 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 exposure(): number

      Gets the exposure of the scene.

      Returns number

      The exposure.

    • set exposure(value: number): void

      Sets the exposure of the scene, which tweaks the overall brightness of the rendered image. Ignored if the scene is using physical units. Defaults to 1.

      Parameters

      • value: number

        The exposure.

      Returns void

    • get fog(): "none" | "linear" | "exp" | "exp2"

      Gets the fog type of the scene.

      Returns "none" | "linear" | "exp" | "exp2"

      The fog type.

    • set fog(value: "none" | "linear" | "exp" | "exp2"): void

      Sets the fog type of the scene. Can be none, linear, exp or exp2. Defaults to none.

      Parameters

      • value: "none" | "linear" | "exp" | "exp2"

        The fog type.

      Returns void

    • get fogColor(): Color

      Gets the fog color of the scene.

      Returns Color

      The fog color.

    • set fogColor(value: Color): void

      Sets the fog color of the scene. Defaults to black (0 0 0).

      Parameters

      • value: Color

        The fog color.

      Returns void

    • get fogDensity(): number

      Gets the fog density of the scene.

      Returns number

      The fog density.

    • set fogDensity(value: number): void

      Sets the fog density of the scene. Defaults to 0.

      Parameters

      • value: number

        The fog density.

      Returns void

    • get fogEnd(): number

      Gets the fog end distance of the scene.

      Returns number

      The fog end distance.

    • set fogEnd(value: number): void

      Sets the fog end distance of the scene. Defaults to 1000.

      Parameters

      • value: number

        The fog end distance.

      Returns void

    • get fogStart(): number

      Gets the fog start distance of the scene.

      Returns number

      The fog start distance.

    • set fogStart(value: number): void

      Sets the fog start distance of the scene. Defaults to 1.

      Parameters

      • value: number

        The fog start distance.

      Returns void

    • get gravity(): Vec3

      Gets the gravity of the scene.

      Returns Vec3

      The gravity.

    • set gravity(value: Vec3): void

      Sets the gravity of the scene.

      Parameters

      • value: Vec3

        The gravity.

      Returns void

    • get gsplatDither(): | "bayer2"
      | "bayer4"
      | "bayer8"
      | "bayer16"
      | "bluenoise"
      | "ignnoise"

      Gets the noise pattern stochastic Gaussian splats dither their coverage against.

      Returns "bayer2" | "bayer4" | "bayer8" | "bayer16" | "bluenoise" | "ignnoise"

      The Gaussian splat dither pattern.

    • set gsplatDither(
          value:
              | "bayer2"
              | "bayer4"
              | "bayer8"
              | "bayer16"
              | "bluenoise"
              | "ignnoise",
      ): void

      Sets the noise pattern stochastic Gaussian splats dither their coverage against, ignored unless gsplatStochastic is set. Can be bayer2, bayer4, bayer8, bayer16, bluenoise or ignnoise. Defaults to bluenoise, which looks best under temporal anti-aliasing.

      Parameters

      • value: "bayer2" | "bayer4" | "bayer8" | "bayer16" | "bluenoise" | "ignnoise"

        The Gaussian splat dither pattern.

      Returns void

    • get gsplatSplatBudget(): number

      Gets the number of splats rendered across the scene.

      Returns number

      The scene-wide splat budget.

    • set gsplatSplatBudget(value: number): void

      Sets the number of splats rendered across all Gaussian splats in the scene, used as gsplatSplatBudgetMode directs. The Engine distributes this budget globally between streamed splat assets. 0 means no budget. Defaults to 1,000,000.

      Parameters

      • value: number

        The scene-wide splat budget.

      Returns void

    • get gsplatSplatBudgetMode(): "target" | "limit"

      Gets how the splat budget is used for streamed Gaussian splats.

      Returns "target" | "limit"

      The Gaussian splat budget mode.

    • set gsplatSplatBudgetMode(value: "target" | "limit"): void

      Sets how the splat budget is used for streamed Gaussian splats. target raises detail until the budget is used up, wherever the camera is; the LOD distances of each <pc-gsplat> only shape how detail falls off and divides between splats. limit lets those distances decide the detail and only lowers it when they would exceed the budget, so a distant splat uses just the few splats its distance calls for. Defaults to target.

      Parameters

      • value: "target" | "limit"

        The Gaussian splat budget mode.

      Returns void

    • get gsplatStochastic(): boolean

      Gets whether Gaussian splats render with stochastic alpha on WebGPU: drawn unsorted, with dithered coverage and depth writes, rather than sorted and alpha blended.

      Returns boolean

      Whether Gaussian splats render with stochastic alpha.

    • set gsplatStochastic(value: boolean): void

      Sets whether Gaussian splats render with stochastic alpha on WebGPU: drawn unsorted, with dithered coverage and depth writes, rather than sorted and alpha blended. This skips the per-frame sort at the cost of noise, which temporal anti-aliasing on the camera smooths out. WebGL, which sorts splats on the CPU, ignores it. Defaults to false.

      Parameters

      • value: boolean

        Whether Gaussian splats render with stochastic alpha.

      Returns void

    • get gsplatUseFog(): boolean

      Gets whether the scene fog applies to Gaussian splats.

      Returns boolean

      Whether Gaussian splats are fogged.

    • set gsplatUseFog(value: boolean): void

      Sets whether the scene fog applies to Gaussian splats. Defaults to true.

      Parameters

      • value: boolean

        Whether Gaussian splats are fogged.

      Returns void

    • get gsplatUseTonemap(): boolean

      Gets whether the camera's tonemapping and the scene's exposure apply to Gaussian splats.

      Returns boolean

      Whether Gaussian splats are tonemapped.

    • set gsplatUseTonemap(value: boolean): void

      Sets whether the camera's tonemapping and the scene's exposure apply to Gaussian splats. When false, splats render with their stored colors, which suits captured scenes that are already display-ready. Fog still applies. Defaults to true.

      Parameters

      • value: boolean

        Whether Gaussian splats are tonemapped.

      Returns void

    • get lightingMaxLights(): number

      Gets the maximum number of lights clustered lighting uses in a frame.

      Returns number

      The maximum number of lights.

    • set lightingMaxLights(value: number): void

      Sets the maximum number of lights clustered lighting uses in a frame, from 1 to 65535; lights over the limit are ignored with a warning. Values above 255 double the memory of the light grid. Defaults to 255.

      Parameters

      • value: number

        The maximum number of lights.

      Returns void

    • get scene(): Scene | null

      The PlayCanvas scene instance. null until the containing application has been created — await whenReady or the element's ready() promise before accessing it.

      Returns Scene | null

      The scene instance, or null.

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

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