API Docs for: 0.5.5
Show:

kick.core.Util Class

Defined in: kick/core/Util.js:12
Module: kick.core

Utility class for miscellaneous functions. The class is static and is shared between multiple instances.

Methods

applyConfig

(
  • object
  • config
  • excludeFilter
)
static

For each non function attribute in config, set the attribute on object.

Parameters:

  • object Object
  • config Object
  • excludeFilter Array_String

componentToJSON

(
  • component
  • componentType=component.constructor.name
)
JSON

Parameters:

Returns:

JSON:

contains

(
  • array
  • element
)
Boolean static

Loops through array and return true if any array element strict equals the element. This uses the === to compare the two elements.

Parameters:

  • array Array
  • element Object

Returns:

Boolean:

array contains element

convertSubMeshesToTriangleIndices

(
  • subMeshes
  • primitiveType
  • removeDegenerate
)
Array | Null static

Parameters:

  • subMeshes Array

    array of array of indices

  • primitiveType Number

    such as Constants.GL_TRIANGLES or Constants.GL_TRIANGLE_STRIP

  • removeDegenerate Boolean

    remove degenerate triangles

Returns:

Array | Null:

triangleIndices or null if not possible to convert

convertToTriangleIndices

(
  • indices
  • primitiveType
  • removeDegenerate
)
Array | Null static

Parameters:

  • indices Array

    index array

  • primitiveType Number

    such as Constants.GL_TRIANGLES or Constants.GL_TRIANGLE_STRIP

  • removeDegenerate Boolean

    remove degenerate triangles

Returns:

Array | Null:

triangleIndices or null if not possible to convert

copyStaticPropertiesToObject

(
  • object
  • type
)
static

Parameters:

  • object Object
  • type Function

    constructor function

deepCopy

(
  • src
  • passthroughClasses=null
)

Parameters:

  • src Object
  • passthroughClasses=null Array_Classes

    Don't attempt to clone object of these classes (uses instanceof operator)

Returns:

Object

deserializeConfig

(
  • config
  • scene
)

Used for deserializing a configuration (replaces reference objects with actual references)

Parameters:

  • config Object
  • scene kick.scene.Scene

    used for looking up references to gameObjects and components

fail

() static

Invokes debugger and logs an error

getJSONReference

(
  • object
)
JSON

Parameters:

  • object Object

Returns:

JSON:

getParameter

(
  • url
  • parameterName
)
String static

Reads a parameter from a url string.

Parameters:

  • url String
  • parameterName String

Returns:

String:

parameter value or null if not found.

getParameterInt

(
  • url
  • parameterName
)
String static

Reads a int parameter from a url string.

Parameters:

  • url String
  • parameterName String

Returns:

String:

parameter value or null if not found.

getParameterInt

(
  • url
  • parameterName
)
String static

Reads a float parameter from a url string.

Parameters:

  • url String
  • parameterName String

Returns:

String:

parameter value or null if not found.

hasProperty

(
  • obj
  • prop
)
Boolean static

Parameters:

  • obj Object
  • prop String

Returns:

Boolean:

insertSorted

(
  • element
  • sortedArray
  • [sortFunc=kick.core.Util.numberSortFunction]
)
static

Insert the element into a sorted array

Parameters:

  • element Object
  • sortedArray Array
  • [sortFunc=kick.core.Util.numberSortFunction] Function optional

    has the signature foo(obj1,obj2) returns Number.

isPowerOfTwo

(
  • x
)
Number static

Parameters:

  • x Number

    value

Returns:

Number:

nextHighestPowerOfTwo

(
  • x
)
Number static

Parameters:

  • x Number

    value

Returns:

Number:

numberSortFunction

(
  • a
  • b
)
Number static

Returns a-b

Parameters:

  • a Number
  • b Number

Returns:

Number:

a-b

removeAllProperties

(
  • obj
)
static

Removes all properties (methods and attributes) of an object

Parameters:

  • obj Object

removeElementFromArray

(
  • array
  • removeValue
  • deleteAll
)
Boolean static

Remove one element from an array - either the first instance or all instances

Parameters:

  • array Array
  • removeValue Object

    value to be deleted

  • deleteAll Boolean

    deletaAll objects (or exit function after first deletion)

Returns:

Boolean:

elementRemoved

removeElementsFromArray

(
  • array
  • removeValues
)
static

Removes all values from one array in another array

Parameters:

  • array Array
  • removeValues Object

    value to be deleted

scaleImage

(
  • imageObj
  • newWidth
  • newHeight
)
Canvas static

Scales the image by drawing the image on a canvas object.

Parameters:

  • imageObj Image
  • newWidth Number
  • newHeight Number

Returns:

Canvas:

return a Canvas object (acts as a image)

toCamelCase

(
  • str
  • [wordSeparator=""]
)

Parameters:

  • str String
  • [wordSeparator=""] String optional

typedArrayToArray

(
  • typedArray
)
Array_Number static

Converts a typed array to a number array

Parameters:

  • typedArray TypedArray

Returns:

Array_Number:

uint32ToVec4

(
  • uint32
  • dest
)
kick.math.Vec4 static

Packs a Uint32 into a kick.math.Vec4

Parameters:

Returns:

utf8Decode

(
  • bytes
)
static

Supports up to 3 byte UTF-8 encoding (including Basic Multilingual Plane)

Parameters:

  • bytes Uint8Array

Returns:

String

utf8Encode

(
  • str
)
static

Supports up to 3 byte UTF-8 encoding (including Basic Multilingual Plane)

Parameters:

  • str String

Returns:

Uint8Array

vec4ToUint32

(
  • vec4
)
static

Unpacks a kick.math.Vec4 into a Uint32

Parameters:

vec4uint8ToUint32

(
  • vec4uint8
)
static

Unpacks an array of uint8 into a Uint32

Parameters:

  • vec4uint8 Array_Number

warn

() static

Invokes debugger and logs a warning