Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Tools

Class containing a set of static utilities functions

Hierarchy

  • Tools

Index

Properties

Static Readonly AllLogLevelSearch playground for AllLogLevel

AllLogLevel: number

All logs

Static CustomRequestHeadersSearch playground for CustomRequestHeaders

CustomRequestHeaders: {}

Custom HTTP Request Headers to be sent with XMLHttpRequests i.e. when loading files, where the server/service expects an Authorization header

Type declaration

  • [key: string]: string

Static EndPerformanceCounterSearch playground for EndPerformanceCounter

EndPerformanceCounter: (counterName: string, condition?: boolean) => void

Ends a specific performance counter

Type declaration

    • (counterName: string, condition?: boolean): void
    • Parameters

      • counterName: string
      • Optional condition: boolean

      Returns void

Static Readonly ErrorLogLevelSearch playground for ErrorLogLevel

ErrorLogLevel: number

Only error logs

Static GetDOMTextContentSearch playground for GetDOMTextContent

GetDOMTextContent: typeof GetDOMTextContent

Extracts text content from a DOM element hierarchy Back Compat only, please use DomManagement.GetDOMTextContent instead.

Static IsWindowObjectExistSearch playground for IsWindowObjectExist

IsWindowObjectExist: typeof IsWindowObjectExist

Checks if the window object exists Back Compat only, please use DomManagement.IsWindowObjectExist instead.

Static Readonly MessageLogLevelSearch playground for MessageLogLevel

MessageLogLevel: number

Only message logs

Static Readonly NoneLogLevelSearch playground for NoneLogLevel

NoneLogLevel: number

No log

Static OnNewCacheEntrySearch playground for OnNewCacheEntry

OnNewCacheEntry: (entry: string) => void

Callback called when a new log is added

Type declaration

    • (entry: string): void
    • Parameters

      • entry: string

      Returns void

Static Readonly PerformanceConsoleLogLevelSearch playground for PerformanceConsoleLogLevel

PerformanceConsoleLogLevel: number

Log performance to the console

Static Readonly PerformanceNoneLogLevelSearch playground for PerformanceNoneLogLevel

PerformanceNoneLogLevel: number

No performance log

Static Readonly PerformanceUserMarkLogLevelSearch playground for PerformanceUserMarkLogLevel

PerformanceUserMarkLogLevel: number

Use user marks to log performance

Static StartPerformanceCounterSearch playground for StartPerformanceCounter

StartPerformanceCounter: (counterName: string, condition?: boolean) => void

Starts a performance counter

Type declaration

    • (counterName: string, condition?: boolean): void
    • Parameters

      • counterName: string
      • Optional condition: boolean

      Returns void

Static UseCustomRequestHeadersSearch playground for UseCustomRequestHeaders

UseCustomRequestHeaders: boolean

Enable/Disable Custom HTTP Request Headers globally. default = false

see

CustomRequestHeaders

Static Readonly WarningLogLevelSearch playground for WarningLogLevel

WarningLogLevel: number

Only warning logs

Accessors

Static BaseUrl

  • get BaseUrl(): string
  • set BaseUrl(value: string): any
  • Gets or sets the base URL to use to load assets

    Returns string

  • Gets or sets the base URL to use to load assets

    Parameters

    • value: string

    Returns any

Static CorsBehavior

  • get CorsBehavior(): string | ((url: string | string[]) => string)
  • set CorsBehavior(value: string | ((url: string | string[]) => string)): any
  • Default behaviour for cors in the application. It can be a string if the expected behavior is identical in the entire app. Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)

    Returns string | ((url: string | string[]) => string)

  • Default behaviour for cors in the application. It can be a string if the expected behavior is identical in the entire app. Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)

    Parameters

    • value: string | ((url: string | string[]) => string)

    Returns any

Static DefaultRetryStrategy

  • get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number
  • set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number): any
  • Gets or sets the retry strategy to apply when an error happens while loading an asset

    Returns (url: string, request: WebRequest, retryIndex: number) => number

      • (url: string, request: WebRequest, retryIndex: number): number
      • Parameters

        • url: string
        • request: WebRequest
        • retryIndex: number

        Returns number

  • Gets or sets the retry strategy to apply when an error happens while loading an asset

    Parameters

    • strategy: (url: string, request: WebRequest, retryIndex: number) => number
        • (url: string, request: WebRequest, retryIndex: number): number
        • Parameters

          • url: string
          • request: WebRequest
          • retryIndex: number

          Returns number

    Returns any

Static LogCache

  • get LogCache(): string
  • Gets current log cache (list of logs)

    Returns string

Static LogLevels

  • set LogLevels(level: number): any
  • Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)

    Parameters

    • level: number

    Returns any

Static Now

  • get Now(): number
  • Gets either window.performance.now() if supported or Date.now() else

    Returns number

Static PerformanceLogLevel

  • set PerformanceLogLevel(level: number): any
  • Sets the current performance log level

    Parameters

    • level: number

    Returns any

Static PreprocessUrl

  • get PreprocessUrl(): (url: string) => string
  • set PreprocessUrl(processor: (url: string) => string): any
  • Gets or sets a function used to pre-process url before using them to load assets

    Returns (url: string) => string

      • (url: string): string
      • Parameters

        • url: string

        Returns string

  • Gets or sets a function used to pre-process url before using them to load assets

    Parameters

    • processor: (url: string) => string
        • (url: string): string
        • Parameters

          • url: string

          Returns string

    Returns any

Static RegisteredExternalClasses

  • get RegisteredExternalClasses(): {}
  • set RegisteredExternalClasses(classes: {}): any
  • Use this object to register external classes like custom textures or material to allow the loaders to instantiate them

    Returns {}

    • [key: string]: Object
  • Use this object to register external classes like custom textures or material to allow the loaders to instantiate them

    Parameters

    • classes: {}
      • [key: string]: Object

    Returns any

Static UseFallbackTexture

  • get UseFallbackTexture(): boolean
  • set UseFallbackTexture(value: boolean): any
  • Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded

    ignorenaming

    Returns boolean

  • Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded

    ignorenaming

    Parameters

    • value: boolean

    Returns any

Static errorsCount

  • get errorsCount(): number
  • Gets a value indicating the number of loading errors

    ignorenaming

    Returns number

Static fallbackTexture

  • get fallbackTexture(): string
  • set fallbackTexture(value: string): any
  • Texture content used if a texture cannot loaded

    ignorenaming

    Returns string

  • Texture content used if a texture cannot loaded

    ignorenaming

    Parameters

    • value: string

    Returns any

Methods

Static BackCompatCameraNoPreventDefaultSearch playground for BackCompatCameraNoPreventDefault

  • BackCompatCameraNoPreventDefault(args: IArguments): boolean
  • Will return the right value of the noPreventDefault variable Needed to keep backwards compatibility to the old API.

    Parameters

    • args: IArguments

      arguments passed to the attachControl function

    Returns boolean

    the correct value for noPreventDefault

Static CleanUrlSearch playground for CleanUrl

  • CleanUrl(url: string): string
  • Removes unwanted characters from an url

    Parameters

    • url: string

      defines the url to clean

    Returns string

    the cleaned url

Static ClearLogCacheSearch playground for ClearLogCache

  • ClearLogCache(): void
  • Clears the log cache

    Returns void

Static CreateScreenshotSearch playground for CreateScreenshot

  • CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void
  • Captures a screenshot of the current rendering

    see

    https://doc.babylonjs.com/how_to/render_scene_on_a_png

    Parameters

    • engine: Engine

      defines the rendering engine

    • camera: Camera

      defines the source camera

    • size: IScreenshotSize | number

      This parameter can be set to a single number or to an object with the following (optional) properties: precision, width, height. If a single number is passed, it will be used for both width and height. If an object is passed, the screenshot size will be derived from the parameters. The precision property is a multiplier allowing rendering at a higher or lower resolution

    • Optional successCallback: (data: string) => void

      defines the callback receives a single parameter which contains the screenshot as a string of base64-encoded characters. This string can be assigned to the src parameter of an to display it

        • (data: string): void
        • Parameters

          • data: string

          Returns void

    • Optional mimeType: string

      defines the MIME type of the screenshot image (default: image/png). Check your browser for supported MIME types

    Returns void

Static CreateScreenshotAsyncSearch playground for CreateScreenshotAsync

  • Captures a screenshot of the current rendering

    see

    https://doc.babylonjs.com/how_to/render_scene_on_a_png

    Parameters

    • engine: Engine

      defines the rendering engine

    • camera: Camera

      defines the source camera

    • size: IScreenshotSize | number

      This parameter can be set to a single number or to an object with the following (optional) properties: precision, width, height. If a single number is passed, it will be used for both width and height. If an object is passed, the screenshot size will be derived from the parameters. The precision property is a multiplier allowing rendering at a higher or lower resolution

    • Optional mimeType: string

      defines the MIME type of the screenshot image (default: image/png). Check your browser for supported MIME types

    Returns Promise<string>

    screenshot as a string of base64-encoded characters. This string can be assigned to the src parameter of an to display it

Static CreateScreenshotUsingRenderTargetSearch playground for CreateScreenshotUsingRenderTarget

  • CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void
  • Generates an image screenshot from the specified camera.

    see

    https://doc.babylonjs.com/how_to/render_scene_on_a_png

    Parameters

    • engine: Engine

      The engine to use for rendering

    • camera: Camera

      The camera to use for rendering

    • size: IScreenshotSize | number

      This parameter can be set to a single number or to an object with the following (optional) properties: precision, width, height. If a single number is passed, it will be used for both width and height. If an object is passed, the screenshot size will be derived from the parameters. The precision property is a multiplier allowing rendering at a higher or lower resolution

    • Optional successCallback: (data: string) => void

      The callback receives a single parameter which contains the screenshot as a string of base64-encoded characters. This string can be assigned to the src parameter of an to display it

        • (data: string): void
        • Parameters

          • data: string

          Returns void

    • Optional mimeType: string

      The MIME type of the screenshot image (default: image/png). Check your browser for supported MIME types

    • Optional samples: number

      Texture samples (default: 1)

    • Optional antialiasing: boolean

      Whether antialiasing should be turned on or not (default: false)

    • Optional fileName: string

      A name for for the downloaded file.

    Returns void

Static CreateScreenshotUsingRenderTargetAsyncSearch playground for CreateScreenshotUsingRenderTargetAsync

  • CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>
  • Generates an image screenshot from the specified camera.

    see

    https://doc.babylonjs.com/how_to/render_scene_on_a_png

    Parameters

    • engine: Engine

      The engine to use for rendering

    • camera: Camera

      The camera to use for rendering

    • size: IScreenshotSize | number

      This parameter can be set to a single number or to an object with the following (optional) properties: precision, width, height. If a single number is passed, it will be used for both width and height. If an object is passed, the screenshot size will be derived from the parameters. The precision property is a multiplier allowing rendering at a higher or lower resolution

    • Optional mimeType: string

      The MIME type of the screenshot image (default: image/png). Check your browser for supported MIME types

    • Optional samples: number

      Texture samples (default: 1)

    • Optional antialiasing: boolean

      Whether antialiasing should be turned on or not (default: false)

    • Optional fileName: string

      A name for for the downloaded file.

    Returns Promise<string>

    screenshot as a string of base64-encoded characters. This string can be assigned to the src parameter of an to display it

Static DecodeBase64Search playground for DecodeBase64

  • DecodeBase64(uri: string): ArrayBuffer
  • Decode the given base64 uri.

    deprecated

    Please use FileTools.DecodeBase64UrlToBinary instead.

    Parameters

    • uri: string

      The uri to decode

    Returns ArrayBuffer

    The decoded base64 data.

Static DeepCopySearch playground for DeepCopy

  • DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void
  • Tries to copy an object by duplicating every property

    Parameters

    • source: any

      defines the source object

    • destination: any

      defines the target object

    • Optional doNotCopyList: string[]

      defines a list of properties to avoid

    • Optional mustCopyList: string[]

      defines a list of properties to copy (even if they start with _)

    Returns void

Static DelayAsyncSearch playground for DelayAsync

  • DelayAsync(delay: number): Promise<void>
  • Returns a promise that resolves after the given amount of time.

    Parameters

    • delay: number

      Number of milliseconds to delay

    Returns Promise<void>

    Promise that resolves after the given amount of time

Static DownloadSearch playground for Download

  • Download(blob: Blob, fileName: string): void
  • Downloads a blob in the browser

    Parameters

    • blob: Blob

      defines the blob to download

    • fileName: string

      defines the name of the downloaded file

    Returns void

Static DumpDataSearch playground for DumpData

  • DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void
  • Dumps an array buffer

    Parameters

    • width: number

      defines the rendering width

    • height: number

      defines the rendering height

    • data: ArrayBufferView

      the data array

    • Optional successCallback: (data: string | ArrayBuffer) => void

      defines the callback triggered once the data are available

        • (data: string | ArrayBuffer): void
        • Parameters

          • data: string | ArrayBuffer

          Returns void

    • Optional mimeType: string

      defines the mime type of the result

    • Optional fileName: string

      defines the filename to download. If present, the result will automatically be downloaded

    • Optional invertY: boolean

      true to invert the picture in the Y dimension

    • Optional toArrayBuffer: boolean

      true to convert the data to an ArrayBuffer (encoded as mimeType) instead of a base64 string

    Returns void

Static DumpDataAsyncSearch playground for DumpDataAsync

  • DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>
  • Dumps an array buffer

    Parameters

    • width: number

      defines the rendering width

    • height: number

      defines the rendering height

    • data: ArrayBufferView

      the data array

    • Optional mimeType: string

      defines the mime type of the result

    • Optional fileName: string

      defines the filename to download. If present, the result will automatically be downloaded

    • Optional invertY: boolean

      true to invert the picture in the Y dimension

    • Optional toArrayBuffer: boolean

      true to convert the data to an ArrayBuffer (encoded as mimeType) instead of a base64 string

    Returns Promise<string | ArrayBuffer>

    a promise that resolve to the final data

Static DumpFramebufferSearch playground for DumpFramebuffer

  • DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>
  • Dumps the current bound framebuffer

    Parameters

    • width: number

      defines the rendering width

    • height: number

      defines the rendering height

    • engine: Engine

      defines the hosting engine

    • Optional successCallback: (data: string) => void

      defines the callback triggered once the data are available

        • (data: string): void
        • Parameters

          • data: string

          Returns void

    • Optional mimeType: string

      defines the mime type of the result

    • Optional fileName: string

      defines the filename to download. If present, the result will automatically be downloaded

    Returns Promise<void>

    a void promise

Static EncodeScreenshotCanvasDataSearch playground for EncodeScreenshotCanvasData

  • EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void
  • Encodes the canvas data to base 64 or automatically download the result if filename is defined

    Parameters

    • Optional successCallback: (data: string) => void

      defines the callback triggered once the data are available

        • (data: string): void
        • Parameters

          • data: string

          Returns void

    • Optional mimeType: string

      defines the mime type of the result

    • Optional fileName: string

      defines he filename to download. If present, the result will automatically be downloaded

    • Optional canvas: HTMLCanvasElement

      canvas to get the data from. If not provided, use the default screenshot canvas

    Returns void

Static ErrorSearch playground for Error

  • Error(message: string): void
  • Write an error message to the console

    Parameters

    • message: string

      defines the message to log

    Returns void

Static FetchToRefSearch playground for FetchToRef

  • FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void
  • Read the content of a byte array at a specified coordinates (taking in account wrapping)

    Parameters

    • u: number

      defines the coordinate on X axis

    • v: number

      defines the coordinate on Y axis

    • width: number

      defines the width of the source data

    • height: number

      defines the height of the source data

    • pixels: Uint8Array

      defines the source byte array

    • color: IColor4Like

      defines the output color

    Returns void

Static FileAsURLSearch playground for FileAsURL

  • FileAsURL(content: string): string
  • Creates a data url from a given string content

    Parameters

    • content: string

      defines the content to convert

    Returns string

    the new data url link

Static FirstSearch playground for First

  • First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>
  • Gets the first element of an array satisfying a given predicate

    Type parameters

    • T

    Parameters

    • array: Array<T>

      defines the array to browse

    • predicate: (item: T) => boolean

      defines the predicate to use

        • (item: T): boolean
        • Parameters

          • item: T

          Returns boolean

    Returns Nullable<T>

    null if not found or the element

Static FloatRoundSearch playground for FloatRound

  • FloatRound(value: number): number
  • Returns the nearest 32-bit single precision float representation of a Number

    Parameters

    • value: number

      A Number. If the parameter is of a different type, it will get converted to a number or to NaN if it cannot be converted

    Returns number

    number

Static FormatSearch playground for Format

  • Format(value: number, decimals?: number): string
  • Format the given number to a specific decimal format

    Parameters

    • value: number

      defines the number to format

    • Optional decimals: number

      defines the number of decimals to use

    Returns string

    the formatted string

Static GetAbsoluteUrlSearch playground for GetAbsoluteUrl

  • GetAbsoluteUrl(url: string): string
  • Gets the absolute url.

    Parameters

    • url: string

      the input url

    Returns string

    the absolute url

Static GetClassNameSearch playground for GetClassName

  • GetClassName(object: any, isType?: boolean): string
  • This method will return the name of the class used to create the instance of the given object. It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.

    Parameters

    • object: any

      the object to get the class name from

    • Optional isType: boolean

      defines if the object is actually a type

    Returns string

    the name of the class, will be "object" for a custom data type not using the @className decorator

Static GetFilenameSearch playground for GetFilename

  • GetFilename(path: string): string
  • Extracts the filename from a path

    Parameters

    • path: string

      defines the path to use

    Returns string

    the filename

Static GetFolderPathSearch playground for GetFolderPath

  • GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string
  • Extracts the "folder" part of a path (everything before the filename).

    Parameters

    • uri: string

      The URI to extract the info from

    • Optional returnUnchangedIfNoSlash: boolean

      Do not touch the URI if no slashes are present

    Returns string

    The "folder" part of the path

Static GetPointerPrefixSearch playground for GetPointerPrefix

  • GetPointerPrefix(engine: Engine): string
  • Gets the pointer prefix to use

    Parameters

    • engine: Engine

      defines the engine we are finding the prefix for

    Returns string

    "pointer" if touch is enabled. Else returns "mouse"

Static InstantiateSearch playground for Instantiate

  • Instantiate(className: string): any
  • Tries to instantiate a new object from a given class name

    Parameters

    • className: string

      defines the class name to instantiate

    Returns any

    the new object or null if the system was not able to do the instantiation

Static IsBase64Search playground for IsBase64

  • IsBase64(uri: string): boolean
  • Test if the given uri is a base64 string

    deprecated

    Please use FileTools.IsBase64DataUrl instead.

    Parameters

    • uri: string

      The uri to test

    Returns boolean

    True if the uri is a base64 string or false otherwise

Static IsEmptySearch playground for IsEmpty

  • IsEmpty(obj: any): boolean
  • Gets a boolean indicating if the given object has no own property

    Parameters

    • obj: any

      defines the object to test

    Returns boolean

    true if object has no own property

Static IsExponentOfTwoSearch playground for IsExponentOfTwo

  • IsExponentOfTwo(value: number): boolean
  • Function indicating if a number is an exponent of 2

    Parameters

    • value: number

      defines the value to test

    Returns boolean

    true if the value is an exponent of 2

Static IsSafariSearch playground for IsSafari

  • IsSafari(): boolean
  • Utility function to detect if the current user agent is Safari

    Returns boolean

    whether or not the current user agent is safari

Static LoadFileSearch playground for LoadFile

  • LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest
  • Loads a file from a url

    Parameters

    • url: string

      url string, ArrayBuffer, or Blob to load

    • onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void

      callback called when the file successfully loads

        • (data: string | ArrayBuffer, responseURL?: string): void
        • Parameters

          • data: string | ArrayBuffer
          • Optional responseURL: string

          Returns void

    • Optional onProgress: (data: any) => void

      callback called while file is loading (if the server supports this mode)

        • (data: any): void
        • Parameters

          • data: any

          Returns void

    • Optional offlineProvider: IOfflineProvider

      defines the offline provider for caching

    • Optional useArrayBuffer: boolean

      defines a boolean indicating that date must be returned as ArrayBuffer

    • Optional onError: (request?: WebRequest, exception?: any) => void

      callback called when the file fails to load

        • Parameters

          • Optional request: WebRequest
          • Optional exception: any

          Returns void

    Returns IFileRequest

    a file request object

Static LoadFileAsyncSearch playground for LoadFileAsync

  • LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>
  • Loads a file from a url

    Parameters

    • url: string

      the file url to load

    • Optional useArrayBuffer: boolean

      defines a boolean indicating that date must be returned as ArrayBuffer

    Returns Promise<ArrayBuffer | string>

    a promise containing an ArrayBuffer corresponding to the loaded file

Static LoadImageSearch playground for LoadImage

  • LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>
  • Loads an image as an HTMLImageElement.

    Parameters

    • input: string | ArrayBuffer | Blob

      url string, ArrayBuffer, or Blob to load

    • onLoad: (img: HTMLImageElement | ImageBitmap) => void

      callback called when the image successfully loads

    • onError: (message?: string, exception?: any) => void

      callback called when the image fails to load

        • (message?: string, exception?: any): void
        • Parameters

          • Optional message: string
          • Optional exception: any

          Returns void

    • offlineProvider: Nullable<IOfflineProvider>

      offline provider for caching

    • Optional mimeType: string

      optional mime type

    Returns Nullable<HTMLImageElement>

    the HTMLImageElement of the loaded image

Static LoadScriptSearch playground for LoadScript

  • LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void
  • Load a script (identified by an url). When the url returns, the content of this file is added into a new script element, attached to the DOM (body element)

    Parameters

    • scriptUrl: string

      defines the url of the script to laod

    • onSuccess: () => void

      defines the callback called when the script is loaded

        • (): void
        • Returns void

    • Optional onError: (message?: string, exception?: any) => void

      defines the callback to call if an error occurs

        • (message?: string, exception?: any): void
        • Parameters

          • Optional message: string
          • Optional exception: any

          Returns void

    • Optional scriptId: string

      defines the id of the script element

    Returns void

Static LoadScriptAsyncSearch playground for LoadScriptAsync

  • LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>
  • Load an asynchronous script (identified by an url). When the url returns, the content of this file is added into a new script element, attached to the DOM (body element)

    Parameters

    • scriptUrl: string

      defines the url of the script to laod

    • Optional scriptId: string

      defines the id of the script element

    Returns Promise<void>

    a promise request object

Static LogSearch playground for Log

  • Log(message: string): void
  • Log a message to the console

    Parameters

    • message: string

      defines the message to log

    Returns void

Static MakeArraySearch playground for MakeArray

  • MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>
  • Returns an array if obj is not an array

    Parameters

    • obj: any

      defines the object to evaluate as an array

    • Optional allowsNullUndefined: boolean

      defines a boolean indicating if obj is allowed to be null or undefined

    Returns Nullable<Array<any>>

    either obj directly if obj is an array or a new array containing obj

Static MixSearch playground for Mix

  • Mix(a: number, b: number, alpha: number): number
  • Interpolates between a and b via alpha

    Parameters

    • a: number

      The lower value (returned when alpha = 0)

    • b: number

      The upper value (returned when alpha = 1)

    • alpha: number

      The interpolation-factor

    Returns number

    The mixed value

Static RandomIdSearch playground for RandomId

  • RandomId(): string

Static ReadFileSearch playground for ReadFile

  • ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest
  • Reads a file from a File object

    Parameters

    • file: File

      defines the file to load

    • onSuccess: (data: any) => void

      defines the callback to call when data is loaded

        • (data: any): void
        • Parameters

          • data: any

          Returns void

    • Optional onProgress: (ev: ProgressEvent) => any

      defines the callback to call during loading process

        • (ev: ProgressEvent): any
        • Parameters

          • ev: ProgressEvent

          Returns any

    • Optional useArrayBuffer: boolean

      defines a boolean indicating that data must be returned as an ArrayBuffer

    • Optional onError: (error: ReadFileError) => void

      defines the callback to call when an error occurs

        • (error: ReadFileError): void
        • Parameters

          • error: ReadFileError

          Returns void

    Returns IFileRequest

    a file request object

Static ReadFileAsDataURLSearch playground for ReadFileAsDataURL

  • ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest
  • Loads a file from a blob

    Parameters

    • fileToLoad: Blob

      defines the blob to use

    • callback: (data: any) => void

      defines the callback to call when data is loaded

        • (data: any): void
        • Parameters

          • data: any

          Returns void

    • progressCallback: (ev: ProgressEvent) => any

      defines the callback to call during loading process

        • (ev: ProgressEvent): any
        • Parameters

          • ev: ProgressEvent

          Returns any

    Returns IFileRequest

    a file request object

Static RegisterTopRootEventsSearch playground for RegisterTopRootEvents

  • RegisterTopRootEvents(windowElement: Window, events: { handler: Nullable<(e: FocusEvent) => any>; name: string }[]): void
  • Function used to register events at window level

    Parameters

    • windowElement: Window

      defines the Window object to use

    • events: { handler: Nullable<(e: FocusEvent) => any>; name: string }[]

      defines the events to register

    Returns void

Static SetCorsBehaviorSearch playground for SetCorsBehavior

  • SetCorsBehavior(url: string | string[], element: { crossOrigin: string | null }): void
  • Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.

    Parameters

    • url: string | string[]

      define the url we are trying

    • element: { crossOrigin: string | null }

      define the dom element where to configure the cors policy

      • crossOrigin: string | null

    Returns void

Static SetImmediateSearch playground for SetImmediate

  • SetImmediate(action: () => void): void
  • Polyfill for setImmediate

    Parameters

    • action: () => void

      defines the action to execute after the current execution block

        • (): void
        • Returns void

    Returns void

Static SliceSearch playground for Slice

  • Slice<T>(data: T, start?: number, end?: number): T
  • Provides a slice function that will work even on IE

    Type parameters

    • T

    Parameters

    • data: T

      defines the array to slice

    • Optional start: number

      defines the start of the data (optional)

    • Optional end: number

      defines the end of the data (optional)

    Returns T

    the new sliced array

Static SliceToArraySearch playground for SliceToArray

  • SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>
  • Provides a slice function that will work even on IE The difference between this and Slice is that this will force-convert to array

    Type parameters

    • T

    • P

    Parameters

    • data: T

      defines the array to slice

    • Optional start: number

      defines the start of the data (optional)

    • Optional end: number

      defines the end of the data (optional)

    Returns Array<P>

    the new sliced array

Static ToBlobSearch playground for ToBlob

  • Converts the canvas data to blob. This acts as a polyfill for browsers not supporting the to blob function.

    Parameters

    • canvas: HTMLCanvasElement

      Defines the canvas to extract the data from

    • successCallback: (blob: Nullable<Blob>) => void

      Defines the callback triggered once the data are available

    • Optional mimeType: string

      Defines the mime type of the result

    Returns void

Static ToDegreesSearch playground for ToDegrees

  • ToDegrees(angle: number): number
  • Convert an angle in radians to degrees

    Parameters

    • angle: number

      defines the angle to convert

    Returns number

    the angle in degrees

Static ToRadiansSearch playground for ToRadians

  • ToRadians(angle: number): number
  • Convert an angle in degrees to radians

    Parameters

    • angle: number

      defines the angle to convert

    Returns number

    the angle in radians

Static UnregisterTopRootEventsSearch playground for UnregisterTopRootEvents

  • UnregisterTopRootEvents(windowElement: Window, events: { handler: Nullable<(e: FocusEvent) => any>; name: string }[]): void
  • Function used to unregister events from window level

    Parameters

    • windowElement: Window

      defines the Window object to use

    • events: { handler: Nullable<(e: FocusEvent) => any>; name: string }[]

      defines the events to unregister

    Returns void

Static WarnSearch playground for Warn

  • Warn(message: string): void
  • Write a warning message to the console

    Parameters

    • message: string

      defines the message to log

    Returns void

Static getFullClassNameSearch playground for getFullClassName

  • getFullClassName(object: any, isType?: boolean): Nullable<string>
  • This method will return the name of the full name of the class, including its owning module (if any). It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator or implementing a method getClassName():string (in which case the module won't be specified).

    ignorenaming

    Parameters

    • object: any

      the object to get the class name from

    • Optional isType: boolean

      defines if the object is actually a type

    Returns Nullable<string>

    a string that can have two forms: "moduleName.className" if module was specified when the class' Name was registered or "className" if there was not module specified.

Legend

  • Constructor
  • Property
  • Method
  • Property
  • Method
  • Inherited property
  • Inherited method
  • Static property
  • Static method