Constructor
new MathUtils()
Methods
(static) clamp(value, min, max) → {number}
Clamps the value to be between min and max.
Name | Type | Description |
---|---|---|
value | number | Value to be clamped. |
min | number | The minimum value. |
max | number | The maximum value. |
- The clamped value.
- Type:
- number
(static) denormalize(value, array) → {number}
Denormalizes a value based on the type of the provided array.
Name | Type | Description |
---|---|---|
value | number | The value to be denormalized. |
array | TypedArray | The typed array to determine the normalization factor. |
- Throws an error if the array type is invalid.
- Type
- Error
- The denormalized value.
- Type:
- number
(static) euclideanModulo(n, m) → {number}
Compute euclidean modulo of m % n. Refer to: https://en.wikipedia.org/wiki/Modulo_operation
Name | Type | Description |
---|---|---|
n | number | The dividend. |
m | number | The divisor. |
- The result of the modulo operation.
- Type:
- number
(static) fromHalfFloat(val) → {number}
Converts half float to float.
Name | Type | Description |
---|---|---|
val | number | The half float value. |
- The float value.
- Type:
- number
(static) generateUUID() → {string}
Method for generate uuid. http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
- The uuid.
- Type:
- string
(static) isPowerOfTwo(value) → {boolean}
Is this number a power of two.
Name | Type | Description |
---|---|---|
value | number | The input number. |
- Is this number a power of two.
- Type:
- boolean
(static) lerp(x, y, t) → {number}
Returns a value linearly interpolated from two known points based on the given interval - t = 0 will return x and t = 1 will return y.
Name | Type | Description |
---|---|---|
x | number | The first value. |
y | number | The second value. |
t | number | The interpolation factor. |
- The interpolated value.
- Type:
- number
(static) nearestPowerOfTwo(value) → {number}
Return the nearest power of two number of this number.
Name | Type | Description |
---|---|---|
value | number | The input number. |
- The result number.
- Type:
- number
(static) nextPowerOfTwo(value) → {number}
Return the next power of two number of this number.
Name | Type | Description |
---|---|---|
value | number | The input number. |
- The result number.
- Type:
- number
(static) nextPowerOfTwoSquareSize(value) → {number}
Return the next power of two square size of this number. This method is usually used to calculate the minimum 2d texture size based on the pixel length.
Name | Type | Description |
---|---|---|
value | number | The input number. |
- The result size.
- Type:
- number
(static) normalize(value, array) → {number}
Normalizes a value based on the type of the provided array.
Name | Type | Description |
---|---|---|
value | number | The value to be normalized. |
array | TypedArray | The typed array to determine the normalization factor. |
- Throws an error if the array type is invalid.
- Type
- Error
- The normalized value.
- Type:
- number
(static) toHalfFloat(val) → {number}
Converts float to half float.
Name | Type | Description |
---|---|---|
val | number | The float value. |
- The half float value.
- Type:
- number