API Docs for: 0.7.1
Show:

Utils Class

Defined in: src/utils/Utils.js:5

Misc utility functions

Constructor

Utils

()

Item Index

Methods

Properties

Methods

appendArray

(
  • a
  • b
)
static

Append the values in array b to the array a. See this for an explanation.

Parameters:

  • a Array
  • b Array

defaults

(
  • options
  • defaults
)
Object static

Extend an options object with default values.

Parameters:

  • options Object

    The options object. May be falsy: in this case, a new object is created and returned.

  • defaults Object

    An object containing default values.

Returns:

Object:

The modified options object.

extend

(
  • a
  • b
)
static

Extend an object with the properties of another

Parameters:

  • a Object
  • b Object

splice

(
  • array
  • index
  • howmany
)
static

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>