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:
-
a
Array -
b
Array
defaults
(
Object
static
-
options
-
defaults
Extend an options object with default values.
Parameters:
-
options
ObjectThe options object. May be falsy: in this case, a new object is created and returned.
-
defaults
ObjectAn object containing default values.
Returns:
Object:
The modified options object.
extend
(
static
-
a
-
b
Extend an object with the properties of another
Parameters:
-
a
Object -
b
Object
splice
(
static
-
array
-
index
-
howmany
Garbage free Array.splice(). Does not allocate a new array.
Parameters:
-
array
Array -
index
Number -
howmany
Number
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>