Utils Class
Misc utility functions
Constructor
Utils
()
Item Index
Methods
- appendArray static
- defaults static
- extend static
- splice static
Properties
- ARRAY_TYPE static
Methods
appendArray
(
static
-
a -
b
Append the values in array b to the array a. See this for an explanation.
Parameters:
-
aArray -
bArray
defaults
(
Object
static
-
options -
defaults
Extend an options object with default values.
Parameters:
-
optionsObjectThe options object. May be falsy: in this case, a new object is created and returned.
-
defaultsObjectAn object containing default values.
Returns:
Object:
The modified options object.
extend
(
static
-
a -
b
Extend an object with the properties of another
Parameters:
-
aObject -
bObject
splice
(
static
-
array -
index -
howmany
Garbage free Array.splice(). Does not allocate a new array.
Parameters:
-
arrayArray -
indexNumber -
howmanyNumber
Properties
ARRAY_TYPE
Function
static
The array type to use for internal numeric computations throughout the library. Float32Array is used if it is available, but falls back on Array. If you want to set array type manually, inject it via the global variable P2_ARRAY_TYPE. See example below.
Example:
<script>
<!-- Inject your preferred array type before loading p2.js -->
P2_ARRAY_TYPE = Array;
</script>
<script src="p2.js"></script>
