kick.core.Util Class
Utility class for miscellaneous functions. The class is static and is shared between multiple instances.
Item Index
Methods
- applyConfig static
- componentToJSON
- contains static
- convertSubMeshesToTriangleIndices static
- convertToTriangleIndices static
- copyStaticPropertiesToObject static
- deepCopy
- deserializeConfig
- fail static
- getJSONReference
- getParameter static
- getParameterInt static
- getParameterInt static
- hasProperty static
- insertSorted static
- isPowerOfTwo static
- nextHighestPowerOfTwo static
- numberSortFunction static
- removeAllProperties static
- removeElementFromArray static
- removeElementsFromArray static
- scaleImage static
- toCamelCase
- typedArrayToArray static
- uint32ToVec4 static
- utf8Decode static
- utf8Encode static
- vec4ToUint32 static
- vec4uint8ToUint32 static
- warn static
Methods
applyConfig
-
object
-
config
-
excludeFilter
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
Parameters:
-
component
kick.scene.Component -
componentType=component.constructor.name
String
Returns:
contains
-
array
-
element
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:
array contains element
convertSubMeshesToTriangleIndices
-
subMeshes
-
primitiveType
-
removeDegenerate
Parameters:
-
subMeshes
Arrayarray of array of indices
-
primitiveType
Numbersuch as Constants.GL_TRIANGLES or Constants.GL_TRIANGLE_STRIP
-
removeDegenerate
Booleanremove degenerate triangles
Returns:
triangleIndices or null if not possible to convert
convertToTriangleIndices
-
indices
-
primitiveType
-
removeDegenerate
Parameters:
-
indices
Arrayindex array
-
primitiveType
Numbersuch as Constants.GL_TRIANGLES or Constants.GL_TRIANGLE_STRIP
-
removeDegenerate
Booleanremove degenerate triangles
Returns:
triangleIndices or null if not possible to convert
copyStaticPropertiesToObject
-
object
-
type
Parameters:
-
object
Object -
type
Functionconstructor function
deepCopy
-
src
-
passthroughClasses=null
Parameters:
-
src
Object -
passthroughClasses=null
Array_ClassesDon'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.Sceneused for looking up references to gameObjects and components
fail
()
static
Invokes debugger and logs an error
getJSONReference
-
object
Parameters:
-
object
Object
Returns:
getParameter
-
url
-
parameterName
Reads a parameter from a url string.
Parameters:
-
url
String -
parameterName
String
Returns:
parameter value or null if not found.
getParameterInt
-
url
-
parameterName
Reads a int parameter from a url string.
Parameters:
-
url
String -
parameterName
String
Returns:
parameter value or null if not found.
getParameterInt
-
url
-
parameterName
Reads a float parameter from a url string.
Parameters:
-
url
String -
parameterName
String
Returns:
parameter value or null if not found.
hasProperty
-
obj
-
prop
Parameters:
-
obj
Object -
prop
String
Returns:
insertSorted
-
element
-
sortedArray
-
[sortFunc=kick.core.Util.numberSortFunction]
Insert the element into a sorted array
Parameters:
-
element
Object -
sortedArray
Array -
[sortFunc=kick.core.Util.numberSortFunction]
Function optionalhas the signature foo(obj1,obj2) returns Number.
isPowerOfTwo
-
x
Parameters:
-
x
Numbervalue
Returns:
nextHighestPowerOfTwo
-
x
Parameters:
-
x
Numbervalue
Returns:
numberSortFunction
-
a
-
b
Returns a-b
Parameters:
-
a
Number -
b
Number
Returns:
a-b
removeAllProperties
-
obj
Removes all properties (methods and attributes) of an object
Parameters:
-
obj
Object
removeElementFromArray
-
array
-
removeValue
-
deleteAll
Remove one element from an array - either the first instance or all instances
Parameters:
-
array
Array -
removeValue
Objectvalue to be deleted
-
deleteAll
BooleandeletaAll objects (or exit function after first deletion)
Returns:
elementRemoved
removeElementsFromArray
-
array
-
removeValues
Removes all values from one array in another array
Parameters:
-
array
Array -
removeValues
Objectvalue to be deleted
scaleImage
-
imageObj
-
newWidth
-
newHeight
Scales the image by drawing the image on a canvas object.
Parameters:
-
imageObj
Image -
newWidth
Number -
newHeight
Number
Returns:
return a Canvas object (acts as a image)
toCamelCase
-
str
-
[wordSeparator=""]
Parameters:
-
str
String -
[wordSeparator=""]
String optional
typedArrayToArray
-
typedArray
Converts a typed array to a number array
Parameters:
-
typedArray
TypedArray
Returns:
uint32ToVec4
-
uint32
-
dest
Packs a Uint32 into a kick.math.Vec4
Parameters:
-
uint32
Number -
dest
kick.math.Vec4
Returns:
utf8Decode
-
bytes
Supports up to 3 byte UTF-8 encoding (including Basic Multilingual Plane)
Parameters:
-
bytes
Uint8Array
Returns:
String
utf8Encode
-
str
Supports up to 3 byte UTF-8 encoding (including Basic Multilingual Plane)
Parameters:
-
str
String
Returns:
Uint8Array
vec4uint8ToUint32
-
vec4uint8
Unpacks an array of uint8 into a Uint32
Parameters:
-
vec4uint8
Array_Number
warn
()
static
Invokes debugger and logs a warning