Class AdvancedDynamicTexture
Hierarchy (View Summary)
- WebXRSpatialLayerType
- AdvancedDynamicTexture
Index
Properties
Accessors
Methods
Properties
apply Y Inversion On Update
Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
check Pointer Every Frame
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.
disable Picking
A boolean indicating whether controls can be picked/clicked on or not. Defaults to false.
disable Tab Navigation
A boolean indicating whether or not the elements can be navigated to using the tab key. Defaults to false.
on Begin Layout Observable
Observable event triggered before layout is evaluated
on Begin Render Observable
Observable event triggered before the texture is rendered
on Clipboard Observable
Observable event triggered each time an clipboard event is received from the rendering canvas
on Control Picked Observable
Observable event triggered each time a pointer down is intercepted by a control
on End Layout Observable
Observable event triggered after the layout was evaluated
on End Render Observable
Observable event triggered after the texture was rendered
on Gui Ready Observable
Observable that fires when the GUI is ready
parse Content
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: booleandefines whether to scale to texture to the saved size
OptionalurlRewriter: (url: string) => stringdefines an url rewriter to update urls before sending them to the controls
Returns void
- serializedObject: any
- (
premul Alpha
Gets or sets a boolean defining if alpha is stored as premultiplied
skip Block Events
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
snippet Id
Snippet ID if the content was created from the snippet server
use Pointer Tap For Click Event
If set to true, the POINTERTAP event type will be used for "click", instead of POINTERUP
Readonlyuse Standalone
Indicates whether the ADT is used autonomously
StaticAllow GPU Optimizations
Indicates if some optimizations can be performed in GUI GPU management (the downside is additional memory/GPU texture memory used)
StaticSnippet Url
Define the url to load snippets
Accessors
adjust To Engine Hardware Scaling Level
-
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
background
-
get background(): string
Gets or sets the background color
Returns string
-
set background(value: string): void
Parameters
- value: string
Returns void
clipboard Data
-
get clipboardData(): string
Gets or set information about clipboardData
Returns string
-
set clipboardData(value: string): void
Parameters
- value: string
Returns void
focused Control
ideal Height
-
get idealHeight(): number
Gets or sets the ideal height used to design controls. The GUI will then rescale everything accordingly
Returns number
-
set idealHeight(value: number): void
Parameters
- value: number
Returns void
ideal Ratio
-
get idealRatio(): number
Gets the ratio used when in "ideal mode"
Returns number
ideal Width
-
get idealWidth(): number
Gets or sets the ideal width used to design controls. The GUI will then rescale everything accordingly
Returns number
-
set idealWidth(value: number): void
Parameters
- value: number
Returns void
is Foreground
-
get isForeground(): boolean
Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
Returns boolean
-
set isForeground(value: boolean): void
Parameters
- value: boolean
Returns void
layer
-
get layer(): Nullable<Layer>
Gets the underlying layer used to render the texture when in fullscreen mode
Returns Nullable<Layer>
num Layout Calls
-
get numLayoutCalls(): number
Gets the number of layout calls made the last time the ADT has been rendered
Returns number
num Render Calls
-
get numRenderCalls(): number
Gets the number of render calls made the last time the ADT has been rendered
Returns number
render At Ideal Size
-
get renderAtIdealSize(): boolean
Gets or sets a boolean indicating if adaptive scaling must be used
Returns boolean
-
set renderAtIdealSize(value: boolean): void
Parameters
- value: boolean
Returns void
render Scale
-
get renderScale(): number
Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger). Useful when you want more antialiasing
Returns number
-
set renderScale(value: number): void
Parameters
- value: number
Returns void
root Container
-
Gets the root container control
Returns Container
use Invalidate Rect Optimization
-
get useInvalidateRectOptimization(): boolean
Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
Returns boolean
-
set useInvalidateRectOptimization(value: boolean): void
Parameters
- value: boolean
Returns void
use Smallest Ideal
-
get useSmallestIdeal(): boolean
Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
Returns boolean
-
set useSmallestIdeal(value: boolean): void
Parameters
- value: boolean
Returns void
Methods
add Control
-
Adds a new control to the root container
Parameters
- control: Control
defines the control to add
Returns AdvancedDynamicTexture
the current texture
- control: Control
attach
-
Attach to all scene events required to support pointer events
Returns void
attach To Mesh
-
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
- mesh: AbstractMesh
clone
-
Clones the ADT. If no mesh is defined, the GUI will be considered as a fullscreen GUI
Parameters
OptionalnewName: stringdefines the name of the new ADT
OptionalattachToMesh: anydefines if the new ADT should be attached to a mesh
Returns AdvancedDynamicTexture
the clone of the ADT
create Style
dispose
-
Release all resources
Returns void
execute On All Controls
get Children
-
Returns an array containing the root container. This is mostly used to let the Inspector introspects the ADT
Returns Container[]
an array containing the rootContainer
get Class Name
-
Get the current class name of the texture useful for serialization or dynamic coding.
Returns string
"AdvancedDynamicTexture"
get Control By Name
-
Will return the first control with the given name
Parameters
- name: string
defines the name to search for
Returns Nullable<Control>
the first control found or null
- name: string
get Controls By Type
-
Will return all controls with the given type name
Parameters
- typeName: string
defines the type name to search for
Returns Control[]
an array of all controls found
- typeName: string
get Descendants
-
getDescendants(
directDescendantsOnly?: boolean,
predicate?: (control: Control) => boolean,
): Control[]Will return all controls that are inside this texture
Parameters
OptionaldirectDescendantsOnly: booleandefines 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) => booleandefines 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 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 Vector2
the projected position
- position: Vector3
get Projected Position With Z
-
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
- position: Vector3
gui Is Ready
-
Returns boolean
true if all the GUI components are ready to render
invalidate Rect
-
invalidateRect(
invalidMinX: number,
invalidMinY: number,
invalidMaxX: number,
invalidMaxY: number,
): voidInvalidates 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
- invalidMinX: number
mark As Dirty
-
Marks the texture as dirty forcing a complete update
Returns void
move Focus To Control
-
Move the focus to a specific control
Parameters
- control: Control
defines the control which will receive the focus
Returns void
- control: Control
move To Non Overlapped Position
-
moveToNonOverlappedPosition(
overlapGroup?: number | Control[],
deltaStep?: number,
repelFactor?: number,
): voidMoves 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
parse From Snippet Async
-
parseFromSnippetAsync(
snippetId: string,
scaleToSize?: boolean,
urlRewriter?: (url: string) => string,
): Promise<AdvancedDynamicTexture>Recreate the content of the ADT from a snippet saved by the GUI editor
Parameters
- snippetId: string
defines the snippet to load
OptionalscaleToSize: booleandefines whether to scale to texture to the saved size
OptionalurlRewriter: (url: string) => stringdefines an url rewriter to update urls before sending them to the controls
Returns Promise<AdvancedDynamicTexture>
a promise that will resolve on success
- snippetId: string
parse From URL Async
-
parseFromURLAsync(
url: string,
scaleToSize?: boolean,
urlRewriter?: (url: string) => string,
): Promise<AdvancedDynamicTexture>Recreate the content of the ADT from a url json
Parameters
- url: string
defines the url to load
OptionalscaleToSize: booleandefines whether to scale to texture to the saved size
OptionalurlRewriter: (url: string) => stringdefines an url rewriter to update urls before sending them to the controls
Returns Promise<AdvancedDynamicTexture>
a promise that will resolve on success
- url: string
parse Serialized Object
-
parseSerializedObject(
serializedObject: any,
scaleToSize?: boolean,
urlRewriter?: (url: string) => string,
): voidRecreate the content of the ADT from a JSON object
Parameters
- serializedObject: any
define the JSON serialized object to restore from
OptionalscaleToSize: booleandefines whether to scale to texture to the saved size
OptionalurlRewriter: (url: string) => stringdefines an url rewriter to update urls before sending them to the controls
Returns void
- serializedObject: any
pick
-
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
- x: number
register Clipboard Events
-
Register the clipboard Events onto the canvas
Returns void
remove Control
-
Removes a control from the root container
Parameters
- control: Control
defines the control to remove
Returns AdvancedDynamicTexture
the current texture
- control: Control
scale
-
Scales the texture
Parameters
- ratio: number
the scale factor to apply to both width and height
Returns void
- ratio: number
scale To
-
Resizes the texture
Parameters
- width: number
the new width
- height: number
the new height
Returns void
- width: number
serialize Content
-
Serializes the entire GUI system
Returns any
an object with the JSON serialized data
un Register Clipboard Events
-
Unregister the clipboard Events from the canvas
Returns void
StaticCreate For Mesh
-
CreateForMesh(
mesh: AbstractMesh,
width?: number,
height?: number,
supportPointerMove?: boolean,
onlyAlphaTesting?: boolean,
invertY?: boolean,
materialSetupCallback?: (
mesh: AbstractMesh,
uniqueId: string,
texture: AdvancedDynamicTexture,
onlyAlphaTesting: boolean,
) => void,
sampling?: any,
): AdvancedDynamicTextureCreates 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: booleandefines 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
- mesh: AbstractMesh
StaticCreate For Mesh Texture
-
CreateForMeshTexture(
mesh: AbstractMesh,
width?: number,
height?: number,
supportPointerMove?: boolean,
invertY?: boolean,
sampling?: any,
): AdvancedDynamicTextureCreates 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: booleandefines 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
- mesh: AbstractMesh
StaticCreate Fullscreen UI
-
CreateFullscreenUI(
name: string,
foreground?: boolean,
sceneOrOptions?: any,
sampling?: any,
adaptiveScaling?: boolean,
): AdvancedDynamicTextureCreates 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
- name: string
StaticParse From File Async
-
ParseFromFileAsync(
url: string,
scaleToSize?: boolean,
appendToAdt?: AdvancedDynamicTexture,
urlRewriter?: (url: string) => string,
): Promise<AdvancedDynamicTexture>Recreate the content of the ADT from a url json
Parameters
- url: string
defines the url to load
OptionalscaleToSize: booleandefines whether to scale to texture to the saved size
OptionalappendToAdt: AdvancedDynamicTextureif provided the snippet will be appended to the adt. Otherwise a fullscreen ADT will be created.
OptionalurlRewriter: (url: string) => stringdefines an url rewriter to update urls before sending them to the controls
Returns Promise<AdvancedDynamicTexture>
a promise that will resolve on success
- url: string
StaticParse From Snippet Async
-
ParseFromSnippetAsync(
snippetId: string,
scaleToSize?: boolean,
appendToAdt?: AdvancedDynamicTexture,
urlRewriter?: (url: string) => string,
): Promise<AdvancedDynamicTexture>Recreate the content of the ADT from a snippet saved by the GUI editor
Parameters
- snippetId: string
defines the snippet to load
OptionalscaleToSize: booleandefines whether to scale to texture to the saved size
OptionalappendToAdt: AdvancedDynamicTextureif provided the snippet will be appended to the adt. Otherwise a fullscreen ADT will be created.
OptionalurlRewriter: (url: string) => stringdefines an url rewriter to update urls before sending them to the controls
Returns Promise<AdvancedDynamicTexture>
a promise that will resolve on success
- snippetId: string
Class used to create texture to support 2D GUI elements
See
https://doc.babylonjs.com/features/featuresDeepDive/gui/gui