CLASSES
TagsA - Z

Tools

Tools

Description

class Tools

Members

static BaseUrl : string

static CorsBehavior : any

static UseFallbackTexture : boolean

static RegisteredExternalClasses : { [key: string]: Object }

Use this object to register external classes like custom textures or material

to allow the laoders to instantiate them

static PreprocessUrl : string) => string

static errorsCount : number

static OnNewCacheEntry : string) => void

static NoneLogLevel : number

static MessageLogLevel : number

static WarningLogLevel : number

static ErrorLogLevel : number

static AllLogLevel : number

static Log : string) => void

static Warn : string) => void

static Error : string) => void

static LogCache : string

static LogLevels : number

static PerformanceNoneLogLevel : number

static PerformanceUserMarkLogLevel : number

static PerformanceConsoleLogLevel : number

static PerformanceLogLevel : number

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

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

static Now : number

Methods

static Mix(a, b, alpha) number

Interpolates between a and b via alpha

@return The mixed value

Parameters

Name Type Description
a number The lower value (returned when alpha = 0)
b number The upper value (returned when alpha = 1)
alpha number The interpolation-factor

static Instantiate(className) any

Parameters

Name Type Description
className string

static SetImmediate(action) void

Parameters

Name Type Description
action () => void

static IsExponentOfTwo(value) boolean

Parameters

Name Type Description
value number

static CeilingPOT(x) number

Find the next highest power of two.

@return Next highest power of two.

Parameters

Name Type Description
x number Number to start search from.

static FloorPOT(x) number

Find the next lowest power of two.

@return Next lowest power of two.

Parameters

Name Type Description
x number Number to start search from.

static NearestPOT(x) number

Find the nearest power of two.

@return Next nearest power of two.

Parameters

Name Type Description
x number Number to start search from.

static GetExponentOfTwo(value, max, mode) number

Parameters

Name Type Description
value number
max number
optional mode number

static GetFilename(path) string

Parameters

Name Type Description
path string

static GetDOMTextContent(element) string

Parameters

Name Type Description
element HTMLElement

static ToDegrees(angle) number

Parameters

Name Type Description
angle number

static ToRadians(angle) number

Parameters

Name Type Description
angle number

static EncodeArrayBufferTobase64(buffer) string

Parameters

Name Type Description
buffer ArrayBuffer

static ExtractMinAndMaxIndexed(positions, : Vector3 }

Parameters

Name Type Description
positions number[] or Float32Array
indices IndicesArray
indexStart number
indexCount number

static ExtractMinAndMax(positions, : Vector3 }

Parameters

Name Type Description
positions number[] or Float32Array
start number
count number
optional bias Nullable<Vector2>

static Vector2ArrayFeeder(array, : number) => Nullable<Vector2>

Parameters

Name Type Description
array Array<Vector2> or Float32Array

static ExtractMinAndMaxVector2(feeder, : Vector2 }

Parameters

Name Type Description
feeder (index: number) => Vector2
optional bias Nullable<Vector2>

static MakeArray(obj, allowsNullUndefined) Nullable<Array<any>>

Parameters

Name Type Description
obj any
optional allowsNullUndefined boolean

static GetPointerPrefix() string

static QueueNewFrame(func, requester) number

Parameters

Name Type Description
func () => void - the function to be called
optional requester any - the object that will request the next frame. Falls back to window.

static RequestFullscreen(element) void

Parameters

Name Type Description
element HTMLElement

static ExitFullscreen() void

static SetCorsBehavior(url, img) void

Parameters

Name Type Description
url string
img HTMLImageElement

static CleanUrl(url) string

Parameters

Name Type Description
url string

static LoadImage(url, onLoad, onError, database) HTMLImageElement

Parameters

Name Type Description
url any
onLoad (img: HTMLImageElement) => void
onError (message: string, exception: any) => void

static LoadFile(url, callback, progressCallBack, database, useArrayBuffer, onError) XMLHttpRequest

Parameters

Name Type Description
url string
callback (data: any) => void
optional progressCallBack (data: any) => void
optional database Database
optional useArrayBuffer boolean

static LoadScript(scriptUrl, onSuccess, onError) 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

Name Type Description
scriptUrl string
onSuccess () => void
optional onError (message: string, exception: any) => void

static ReadFileAsDataURL(fileToLoad, callback, progressCallback, MSBaseReader, ev) (fileToLoad, callback, progressCallback, MSBaseReader, ev)

Parameters

Name Type Description
fileToLoad Blob
callback (data: any) => void
progressCallback () => or MSBaseReader

static ReadFile(fileToLoad, callback, progressCallBack, MSBaseReader, ev) (fileToLoad, callback, progressCallBack, MSBaseReader, ev)

Parameters

Name Type Description
fileToLoad File
callback (data: any) => void
optional progressCallBack () => or MSBaseReader

static FileAsURL(content) string

Parameters

Name Type Description
content string

static Format(value, decimals) string

Parameters

Name Type Description
value number
optional decimals number

static CheckExtends(v, min, max) void

Parameters

Name Type Description
v Vector3
min Vector3
max Vector3

static DeepCopy(source, destination, doNotCopyList, mustCopyList) void

Parameters

Name Type Description
source any
destination any
optional doNotCopyList string[]

static IsEmpty(obj) boolean

Parameters

Name Type Description
obj any

static RegisterTopRootEvents(events) void

Parameters

Name Type Description
events { name: string, handler: EventListener }[]

static UnregisterTopRootEvents(events) void

Parameters

Name Type Description
events { name: string, handler: EventListener }[]

static DumpFramebuffer(width, height, engine, successCallback, mimeType) void

Parameters

Name Type Description
width number
height number
engine Engine
optional successCallback (data: string) => void

static EncodeScreenshotCanvasData(successCallback, mimeType) void

Parameters

Name Type Description
optional successCallback (data: string) => void
optional mimeType string

static CreateScreenshot(engine, camera, size, successCallback, mimeType) void

Parameters

Name Type Description
engine Engine
camera Camera
size any
optional successCallback (data: string) => void

static CreateScreenshotUsingRenderTarget(engine, camera, size, successCallback, mimeType, samples) void

Parameters

Name Type Description
engine Engine
camera Camera
size any
optional successCallback (data: string) => void
optional mimeType string

static ValidateXHRData(xhr, dataType) boolean

Parameters

Name Type Description
xhr XMLHttpRequest
optional dataType number

static RandomId() string

Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523

Be aware Math.random() could cause collisions, but:

"All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"

static ClearLogCache() void

static IsWindowObjectExist() boolean

static GetClassName(object, isType) 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.

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

Parameters

Name Type Description
object any the object to get the class name from
optional isType boolean

static First(array, predicate) Nullable<T>

Parameters

Name Type Description
array Array<T>
predicate (item: T) => boolean

static getFullClassName(object, isType) 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).

@return 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.

Parameters

Name Type Description
object any the object to get the class name from
optional isType boolean

static arrayOrStringFeeder(array) : number) => number

This method can be used with hashCodeFromStream when your input is an array of values that are either: number, string, boolean or custom type implementing the getHashCode():number method.

Parameters

Name Type Description
array any

static hashCodeFromStream(feeder) number

Compute the hashCode of a stream of number

To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.

@return the hash code computed

Parameters

Name Type Description
feeder (index: number) => number a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.