CLASSES
TagsA - Z

Tools

Tools

Description

class Tools

Members

static BaseUrl : string

static CorsBehavior : any

static UseFallbackTexture : boolean

static errorsCount : number

static OnNewCacheEntry : (entry: string) => void

static NoneLogLevel : number

static MessageLogLevel : number

static WarningLogLevel : number

static ErrorLogLevel : number

static AllLogLevel : number

static Log : (message: string) => void

static Warn : (message: string) => void

static Error : (message: 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 @param max
optional mode number

static GetFilename(path) → string

Gets the filename from a complete path name

Parameters

Name Type Description
path string @param path

static GetDOMTextContent(element) → string

Returns the DOM text content of the given element

Parameters

Name Type Description
element HTMLElement @param element

static ToDegrees(angle) → number

Converts an angle in radian to degrees

Parameters

Name Type Description
angle number The angle to convert

static ToRadians(angle) → number

Converts an angle in degrees to radian

Parameters

Name Type Description
angle number The angle to convert

static EncodeArrayBufferTobase64(buffer) → string

Parameters

Name Type Description
buffer ArrayBuffer

static ExtractMinAndMaxIndexed(positions, Float32Array, indices, indexStart, indexCount, bias) → { minimum: Vector3, maximum: Vector3 }

Parameters

Name Type Description
positions number[] or Float32Array A 1-dimension array containing the position to extract. Each position should have 3 coordinates
indices IndicesArray The indices
indexStart number The start index
indexCount number

static ExtractMinAndMax(positions, Float32Array, start, count, bias, stride) → { minimum: Vector3, maximum: Vector3 }

Parameters

Name Type Description
positions number[] or Float32Array A 1-dimension array containing the position to extract. Each position should have 3 coordinates
start number The start index
count number The number of position to browse.
optional bias Vector2

static Vector2ArrayFeeder(array, Float32Array) → (i: number) => Vector2

Parameters

Name Type Description
array Array<Vector2> or Float32Array

static ExtractMinAndMaxVector2(feeder, bias) → { minimum: Vector2, maximum: Vector2 }

Parameters

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

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

Make an array

Parameters

Name Type Description
obj any @param obj
optional allowsNullUndefined boolean @param allowsNullUndefined

static GetPointerPrefix() → string

Returns the pointer prefix Checks if hand.js is referenced in this project or if the browser natively supports pointer events.

static QueueNewFrame(func, requester) → void

Parameters

Name Type Description
func any - the function to be called - the function to be called @param func
optional requester any - the object that will request the next frame. Falls back to window. - the object that will request the next frame. Falls back to window.

static RequestFullscreen(element) → void

Parameters

Name Type Description
element any @param element

static ExitFullscreen() → void

Exit fullscreen

static SetCorsBehavior(url, img) → void

Parameters

Name Type Description
url string The url of this file
img HTMLImageElement

static CleanUrl(url) → string

Execute regex, and replace "#" to "%23" and return the new url.

Parameters

Name Type Description
url string The url of this file

static LoadImage(url, onload, onerror, database) → HTMLImageElement

Load the image described by its URL. Check first if this image is in the indexeDB if the parameter {database} is specified.

Parameters

Name Type Description
url any The url of this file
onload any Callback function to execute when the image is loaded
onerror any Callback function to execute when the image is on error

static LoadFile(url, callback, progressCallBack, database, useArrayBuffer, onError) → void

Load the file given by its URL. Check first if this file is in the indexeDB if the parameter {database} is specified. This file is loaded via an ajax call otherwise.

Parameters

Name Type Description
url string The url of this file
callback (data: any) => void Callback function called after the reading
optional progressCallBack (data: any) => void Callback function called during the reading
optional database any An indexeDB database.
optional useArrayBuffer boolean @param useArrayBuffer

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 () => void

static ReadFileAsDataURL(fileToLoad, callback, progressCallback) → void

Read the given file as data url

Parameters

Name Type Description
fileToLoad any The given file
callback any Callback function called after the reading
progressCallback any Callback function during after the reading

static ReadFile(fileToLoad, callback, progressCallBack, useArrayBuffer) → void

Read the given file

Parameters

Name Type Description
fileToLoad any The given file
callback any Callback function called after the reading
progressCallBack any Callback function called during the reading

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

Check extends

Parameters

Name Type Description
v Vector3 @param v
min Vector3 @param min
max Vector3 @param max

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

Parameters

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

static IsEmpty(obj) → boolean

Returns true if the given array is empty, false otherwise

Parameters

Name Type Description
obj any @param obj

static RegisterTopRootEvents(events) → void

;

Parameters

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

static UnregisterTopRootEvents(events) → void

;

Parameters

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

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

Parameters

Name Type Description
width number
height number
engine Engine The 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 The engine
camera Camera The camera
size any The size of the screenshot
optional successCallback (data: string) => void

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

Parameters

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

static ValidateXHRData(xhr, dataType) → boolean

Parameters

Name Type Description
xhr XMLHttpRequest The given xhr data
optional dataType number @param dataType

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 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 the object to get the class name from the object to get the class name from
optional isType boolean

static first(array, predicate) → T

Parameters

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

static getFullClassName(object, isType) → 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 the object to get the class name from the object to get the class name from
optional isType boolean

static arrayOrStringFeeder(array) → (i: 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. a callback that will be called until it returns null, each valid returned values will be used to compute the hash code. a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.