API

Class AdvancedDynamicTexture

Class used to create texture to support 2D GUI elements

Hierarchy (View Summary)

Index
applyYInversionOnUpdate: boolean = true

Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture

checkPointerEveryFrame: boolean = false

If set to true, every scene render will trigger a pointer event for the GUI if it is linked to a mesh or has controls linked to a mesh. This will allow you to catch the pointer moving around the GUI due to camera or mesh movements, but it has a performance cost.

disablePicking: boolean = false

A boolean indicating whether controls can be picked/clicked on or not. Defaults to false.

disableTabNavigation: boolean = false

A boolean indicating whether or not the elements can be navigated to using the tab key. Defaults to false.

onBeginLayoutObservable: any = ...

Observable event triggered before layout is evaluated

onBeginRenderObservable: any = ...

Observable event triggered before the texture is rendered

onClipboardObservable: any = ...

Observable event triggered each time an clipboard event is received from the rendering canvas

onControlPickedObservable: any = ...

Observable event triggered each time a pointer down is intercepted by a control

onEndLayoutObservable: any = ...

Observable event triggered after the layout was evaluated

onEndRenderObservable: any = ...

Observable event triggered after the texture was rendered

onGuiReadyObservable: any = ...

Observable that fires when the GUI is ready

parseContent: (
    serializedObject: any,
    scaleToSize?: boolean,
    urlRewriter?: (url: string) => string,
) => void = ...

Recreate the content of the ADT from a JSON object

Type Declaration

    • (
          serializedObject: any,
          scaleToSize?: boolean,
          urlRewriter?: (url: string) => string,
      ): void
    • Recreate the content of the ADT from a JSON object

      Parameters

      • serializedObject: any

        define the JSON serialized object to restore from

      • OptionalscaleToSize: boolean

        defines whether to scale to texture to the saved size

      • OptionalurlRewriter: (url: string) => string

        defines an url rewriter to update urls before sending them to the controls

      Returns void

define the JSON serialized object to restore from

defines whether to scale to texture to the saved size

defines an url rewriter to update urls before sending them to the controls

Please use parseSerializedObject instead

premulAlpha: boolean = false

Gets or sets a boolean defining if alpha is stored as premultiplied

skipBlockEvents: number = 0

If this is set, even when a control is pointer blocker, some events can still be passed through to the scene. Options from values are PointerEventTypes POINTERDOWN, POINTERUP, POINTERMOVE, POINTERWHEEL, POINTERPICK, POINTERTAP, POINTERDOUBLETAP

snippetId: string

Snippet ID if the content was created from the snippet server

usePointerTapForClickEvent: boolean = false

If set to true, the POINTERTAP event type will be used for "click", instead of POINTERUP

useStandalone: boolean = false

Indicates whether the ADT is used autonomously

AllowGPUOptimizations: boolean = true

Indicates if some optimizations can be performed in GUI GPU management (the downside is additional memory/GPU texture memory used)

SnippetUrl: any = Constants.SnippetUrl

Define the url to load snippets

  • get adjustToEngineHardwareScalingLevel(): boolean

    If set to true, the renderScale will be adjusted automatically to the engine's hardware scaling If this is set to true, manually setting the renderScale will be ignored This is useful when the engine's hardware scaling is set to a value other than 1

    Returns boolean

  • set adjustToEngineHardwareScalingLevel(value: boolean): void

    Parameters

    • value: boolean

    Returns void

  • Connect the texture to a hosting mesh to enable interactions

    Parameters

    • mesh: AbstractMesh

      defines the mesh to attach to

    • supportPointerMove: boolean = true

      defines a boolean indicating if pointer move events must be catched as well

    Returns void

  • Will return all controls that are inside this texture

    Parameters

    • OptionaldirectDescendantsOnly: boolean

      defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered

    • Optionalpredicate: (control: Control) => boolean

      defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored

    Returns Control[]

    all child controls

  • Get screen coordinates for a vector3

    Parameters

    • position: Vector3

      defines the position to project

    • worldMatrix: Matrix

      defines the world matrix to use

    Returns Vector2

    the projected position

  • Get screen coordinates for a vector3

    Parameters

    • position: Vector3

      defines the position to project

    • worldMatrix: Matrix

      defines the world matrix to use

    Returns Vector3

    the projected position with Z

  • Invalidates a rectangle area on the gui texture

    Parameters

    • invalidMinX: number

      left most position of the rectangle to invalidate in the texture

    • invalidMinY: number

      top most position of the rectangle to invalidate in the texture

    • invalidMaxX: number

      right most position of the rectangle to invalidate in the texture

    • invalidMaxY: number

      bottom most position of the rectangle to invalidate in the texture

    Returns void

  • Moves overlapped controls towards a position where it is not overlapping anymore. Please note that this method alters linkOffsetXInPixels and linkOffsetYInPixels.

    Parameters

    • OptionaloverlapGroup: number | Control[]

      the overlap group which will be processed or undefined to process all overlap groups

    • deltaStep: number = 1

      the step size (speed) to reach the target non overlapping position (default 0.1)

    • repelFactor: number = 1

      how much is the control repelled by other controls

    Returns void

  • Recreate the content of the ADT from a snippet saved by the GUI editor

    Parameters

    • snippetId: string

      defines the snippet to load

    • OptionalscaleToSize: boolean

      defines whether to scale to texture to the saved size

    • OptionalurlRewriter: (url: string) => string

      defines an url rewriter to update urls before sending them to the controls

    Returns Promise<AdvancedDynamicTexture>

    a promise that will resolve on success

  • Recreate the content of the ADT from a url json

    Parameters

    • url: string

      defines the url to load

    • OptionalscaleToSize: boolean

      defines whether to scale to texture to the saved size

    • OptionalurlRewriter: (url: string) => string

      defines an url rewriter to update urls before sending them to the controls

    Returns Promise<AdvancedDynamicTexture>

    a promise that will resolve on success

  • Recreate the content of the ADT from a JSON object

    Parameters

    • serializedObject: any

      define the JSON serialized object to restore from

    • OptionalscaleToSize: boolean

      defines whether to scale to texture to the saved size

    • OptionalurlRewriter: (url: string) => string

      defines an url rewriter to update urls before sending them to the controls

    Returns void

  • This function will run a pointer event on this ADT and will trigger any pointer events on any controls This will work on a fullscreen ADT only. For mesh based ADT, simulate pointer events using the scene directly.

    Parameters

    • x: number

      pointer X on the canvas for the picking

    • y: number

      pointer Y on the canvas for the picking

    • pi: Nullable<PointerInfoPre> = null

      optional pointer information

    Returns void

  • Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)

    Parameters

    • mesh: AbstractMesh

      defines the mesh which will receive the texture

    • width: number = 1024

      defines the texture width (1024 by default)

    • height: number = 1024

      defines the texture height (1024 by default)

    • supportPointerMove: boolean = true

      defines a boolean indicating if the texture must capture move events (true by default)

    • onlyAlphaTesting: boolean = false

      defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)

    • OptionalinvertY: boolean

      defines if the texture needs to be inverted on the y axis during loading (true by default)

    • materialSetupCallback: (
          mesh: AbstractMesh,
          uniqueId: string,
          texture: AdvancedDynamicTexture,
          onlyAlphaTesting: boolean,
      ) => void = ...

      defines a custom way of creating and setting up the material on the mesh

    • sampling: any = Texture.TRILINEAR_SAMPLINGMODE

      defines the texture sampling mode (Texture.TRILINEAR_SAMPLINGMODE by default)

    Returns AdvancedDynamicTexture

    a new AdvancedDynamicTexture

  • Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh) BUT do not create a new material for the mesh. You will be responsible for connecting the texture

    Parameters

    • mesh: AbstractMesh

      defines the mesh which will receive the texture

    • width: number = 1024

      defines the texture width (1024 by default)

    • height: number = 1024

      defines the texture height (1024 by default)

    • supportPointerMove: boolean = true

      defines a boolean indicating if the texture must capture move events (true by default)

    • OptionalinvertY: boolean

      defines if the texture needs to be inverted on the y axis during loading (true by default)

    • sampling: any = Texture.TRILINEAR_SAMPLINGMODE

      defines the texture sampling mode (Texture.TRILINEAR_SAMPLINGMODE by default)

    Returns AdvancedDynamicTexture

    a new AdvancedDynamicTexture

  • Creates a new AdvancedDynamicTexture in fullscreen mode. In this mode the texture will rely on a layer for its rendering. This allows it to be treated like any other layer. As such, if you have a multi camera setup, you can set the layerMask on the GUI as well. LayerMask is set through advancedTexture.layer.layerMask

    Parameters

    • name: string

      defines name for the texture

    • foreground: boolean = true

      defines a boolean indicating if the texture must be rendered in foreground (default is true)

    • sceneOrOptions: any = null

      defines the hosting scene or options (IAdvancedDynamicTextureOptions)

    • sampling: any = Texture.BILINEAR_SAMPLINGMODE

      defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)

    • adaptiveScaling: boolean = false

      defines whether to automatically scale root to match hardwarescaling (false by default)

    Returns AdvancedDynamicTexture

    a new AdvancedDynamicTexture

  • Recreate the content of the ADT from a url json

    Parameters

    • url: string

      defines the url to load

    • OptionalscaleToSize: boolean

      defines whether to scale to texture to the saved size

    • OptionalappendToAdt: AdvancedDynamicTexture

      if provided the snippet will be appended to the adt. Otherwise a fullscreen ADT will be created.

    • OptionalurlRewriter: (url: string) => string

      defines an url rewriter to update urls before sending them to the controls

    Returns Promise<AdvancedDynamicTexture>

    a promise that will resolve on success

  • Recreate the content of the ADT from a snippet saved by the GUI editor

    Parameters

    • snippetId: string

      defines the snippet to load

    • OptionalscaleToSize: boolean

      defines whether to scale to texture to the saved size

    • OptionalappendToAdt: AdvancedDynamicTexture

      if provided the snippet will be appended to the adt. Otherwise a fullscreen ADT will be created.

    • OptionalurlRewriter: (url: string) => string

      defines an url rewriter to update urls before sending them to the controls

    Returns Promise<AdvancedDynamicTexture>

    a promise that will resolve on success