Repository

Function

Static Public Summary
public

clamp(value: Number, min: Number, max: Number): *

Clamp a value between a minimum and a maximum

public

cloneObject(object: *): *

public

degToRad(val: float): *

Converts degrees to radians

public

dist(x1: float, y1: float, x2: float, y2: float): *

Calculates the distance between two 2D points

public

encode64(inputStr: *): *

Method to convert a string to Base64.

public
public

getElementPosition(el: Element): Object

Get an element's position within the document taking into account the scroll positions

public

getFileExtension(url: *): *

public

Extract the MimeType from the URL string of image files.

public

getUrlParameter(sParam: *): String

function to get the parameters of the url

public

info()

public

intersectionPoint(line1: Array, line2: Array): {"x": *, "y": *}

Intersection Point between 2 points

public

isObject(item: any): boolean

Simple object check.

public

lerp(value: float, dest: float, amount: float): *

Lerps a value to the destination value with the given amount

public

log()

public

map(value: float, low1: float, high1: float, low2: float, high2: float): *

Maps a number between 2 sets of float values

public

A function that return null as a value

public

pointIsInside(x: Number, y: Number, points: Vector2 Array): *

Finds if a point is inside an array of vertices

public

radToDeg(val: float): *

Converts radians to degrees

public

randomFromTo(from: float, to: float): *

Generates a random number between 2 float values

public

Converts a DOMString to an ArrayBuffer (raw data binary).

public

throttle(fn: Function, threshhold: Number, scope: Object): Function

Returns a throttled version of a function The returned function will only call the original function at most once per the specified threshhold

public

uuid(len: Integer, radix: Integer): String

Generate a random uuid

public

warn()

Static Public

public clamp(value: Number, min: Number, max: Number): * source

Clamp a value between a minimum and a maximum

Params:

NameTypeAttributeDescription
valueNumber
minNumber
maxNumber

Return:

*

public cloneObject(object: *): * source

Params:

NameTypeAttributeDescription
object*

Return:

*

public degToRad(val: float): * source

Converts degrees to radians

Params:

NameTypeAttributeDescription
valfloat

Return:

*

public dist(x1: float, y1: float, x2: float, y2: float): * source

Calculates the distance between two 2D points

Params:

NameTypeAttributeDescription
x1float
y1float
x2float
y2float

Return:

*

public encode64(inputStr: *): * source

Method to convert a string to Base64. Used internally to convert loaded raw data to img. Wrote by phil@philten.com - http://www.philten.com

Params:

NameTypeAttributeDescription
inputStr*

the string to encode

Return:

*

public getElementPosition(el: Element): Object source

import {getElementPosition} from '@mobilizing/library/js/Mobilizing/core/util/Dom.js'

Get an element's position within the document taking into account the scroll positions

Params:

NameTypeAttributeDescription
elElement

The DOM element

Return:

Object

the position of the element as {x, y}

public getFileExtension(url: *): * source

Params:

NameTypeAttributeDescription
url*

Return:

*

public getMimeType(url: String): String source

Extract the MimeType from the URL string of image files. Used internally for texture loading

Params:

NameTypeAttributeDescription
urlString

Return:

String

mimeType from the url

public getUrlParameter(sParam: *): String source

function to get the parameters of the url

Params:

NameTypeAttributeDescription
sParam*

the string of the parameter to get from the url

Return:

String

the parameter if found, undefined elsewhere

public intersectionPoint(line1: Array, line2: Array): {"x": *, "y": *} source

import {intersectionPoint} from '@mobilizing/library/js/Mobilizing/core/util/Math.js'

Intersection Point between 2 points

Params:

NameTypeAttributeDescription
line1Array

as [{x,y}, {x,y}]

line2Array

as [{x,y}, {x,y}]

Return:

{"x": *, "y": *}

public isObject(item: any): boolean source

Simple object check.

Params:

NameTypeAttributeDescription
itemany

The item

Return:

boolean

True if object, false otherwise.

public lerp(value: float, dest: float, amount: float): * source

Lerps a value to the destination value with the given amount

Params:

NameTypeAttributeDescription
valuefloat
destfloat
amountfloat

Return:

*

public map(value: float, low1: float, high1: float, low2: float, high2: float): * source

Maps a number between 2 sets of float values

Params:

NameTypeAttributeDescription
valuefloat

the value to map

low1float

the 1st origin value

high1float

the 2nd destination value

low2float

the 1st destination value

high2float

Return:

*

public noop(): null source

A function that return null as a value

Return:

null

null

public pointIsInside(x: Number, y: Number, points: Vector2 Array): * source

Finds if a point is inside an array of vertices

Params:

NameTypeAttributeDescription
xNumber
yNumber
pointsVector2 Array

vertices {x,y}

Return:

*

public radToDeg(val: float): * source

Converts radians to degrees

Params:

NameTypeAttributeDescription
valfloat

Return:

*

public randomFromTo(from: float, to: float): * source

Generates a random number between 2 float values

Params:

NameTypeAttributeDescription
fromfloat
tofloat

Return:

*

public stringToArrayBuffer(str: DOMString): ArrayBuffer source

import {stringToArrayBuffer} from '@mobilizing/library/js/Mobilizing/core/util/Misc.js'

Converts a DOMString to an ArrayBuffer (raw data binary).

Params:

NameTypeAttributeDescription
strDOMString

a string returned by a XMLHTTPRequest (responseText)

Return:

ArrayBuffer

the resulting ArrayBuffer

public throttle(fn: Function, threshhold: Number, scope: Object): Function source

Returns a throttled version of a function The returned function will only call the original function at most once per the specified threshhold

Params:

NameTypeAttributeDescription
fnFunction

The function to throttle

threshholdNumber

The threshhold in milliseconds

scopeObject

The scope in which the original function will be called

Return:

Function

The throttled function

public uuid(len: Integer, radix: Integer): String source

Generate a random uuid

Params:

NameTypeAttributeDescription
lenInteger
  • optional

The desired number of characters

radixInteger
  • optional

The number of allowable values for each character

Return:

String

The generated uuid

Example:

   let id = uuid();
   // "66209871-857D-4A12-AC7E-E9EEBC2A6AC3"
   let id = uuid(5);
   // "kryIh"
   let id = uuid(5, 2);
   // "10100"