Contains various utility methods for math, searching etc.
- Source:
Summary
Members
Methods
- angle_wrap_0_2pi(angle) → {number}
- angle_wrap_periodic(angle, from, to) → {number}
- assert(Boolean)
- cam_quat_to_mesh_quat(cam_quat, destopt) → {Quat}
- clamp(value, min, max) → {number}
- correct_cam_quat_up(quat, up_only)
- deg_to_rad(degrees) → {number}
- dir_to_quat(dir, ident, destopt) → {Quat}
- euler_to_quat(euler, quatopt) → {Quat}
- f32(param) → {Float32Array}
- gen_tbn_quats(normals, tangentsopt) → {Float32Array}
- ground_project_cam_quat(quat, destopt) → {Quat}
- is_ie11() → {boolean}
- is_vector(o, dimensionopt) → {boolean}
- keyfind(key, value, array) → {Array.<Object>}
- keysearch(key, value, array) → (nullable) {Object}
- lerp(t, from, to) → {number}
- matrix_to_quat(matrix) → {Quat}
- ordered_angles_to_quat(angles, order, quatopt) → {Quat}
- quat_project(quat, quat_ident_dir, plane, plane_ident_dir, destopt) → {Quat}
- quat_to_dir(quat, ident, destopt) → {Vec3}
- quat_to_euler(quat, euleropt) → {Euler}
- quat_to_ordered_angles(quat, order, anglesopt) → {Euler}
- rad_to_deg(radians) → {number}
- sign(value) → {number}
- smooth(curr, last, delta, period) → {number}
- smooth_step(t, min, max) → {number}
- smooth_v(curr, last, delta, period, destopt) → {Float32Array}
- trunc(value) → {number}
Type Definitions
Detailed Description
Members
AXIS_MX
AXIS_MY
AXIS_MZ
AXIS_X
AXIS_Y
AXIS_Z
XYX
XYZ
XZX
XZY
YXY
YXZ
YZX
YZY
ZXY
ZXZ
ZYX
ZYZ
Methods
angle_wrap_0_2pi(angle) → {number}
Convert radian angle into range [0, 2PI)
Parameters:
Name | Type | Description |
---|---|---|
angle |
number | Angle in radians |
Returns:
Converted angle
- Type
- number
- Source:
angle_wrap_periodic(angle, from, to) → {number}
Convert radian angle into custom range [from, to)
Parameters:
Name | Type | Description |
---|---|---|
angle |
number | Angle in radians |
from |
number | Value from in radians |
to |
number | Value to in radians |
Returns:
Converted angle
- Type
- number
- Source:
assert(Boolean)
Abort the program if assertion is false.
Parameters:
Name | Type | Description |
---|---|---|
Boolean |
boolean | expression result |
- Deprecated
- Do not use it anymore
- Source:
cam_quat_to_mesh_quat(cam_quat, destopt) → {Quat}
clamp(value, min, max) → {number}
Clamp the number.
Parameters:
Name | Type | Description |
---|---|---|
value |
number | Input value |
min |
number | Lower bound |
max |
number | Upper bound |
Returns:
Clamped value
- Type
- number
- Source:
correct_cam_quat_up(quat, up_only)
Correct the camera quaternion rotation.
Parameters:
Name | Type | Description |
---|---|---|
quat |
Quat | Quaternion to correct |
up_only |
boolean | Disable upside-down camera view |
- Source:
deg_to_rad(degrees) → {number}
Convert degrees to radians.
Parameters:
Name | Type | Description |
---|---|---|
degrees |
number | Angle in degrees. |
Returns:
Angle in radians.
- Type
- number
- Source:
dir_to_quat(dir, ident, destopt) → {Quat}
euler_to_quat(euler, quatopt) → {Quat}
Convert euler angles in the ZYX intrinsic system to quaternion.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
euler |
Euler | Euler angles. The angles order: an angle of the rotation around the x axis, an angle of the rotation around the y axis, an angle of the rotation around the z axis. | |
quat |
Quat |
<optional> |
Destination quaternion vector. |
Returns:
Quaternion vector.
- Type
- Quat
- Source:
f32(param) → {Float32Array}
Create a new Float32Array.
Parameters:
Name | Type | Description |
---|---|---|
param |
number | Array | TypedArray | Constructor param |
Returns:
New Float32Array.
- Type
- Float32Array
- Source:
gen_tbn_quats(normals, tangentsopt) → {Float32Array}
Generate flat array of TBN quaternions
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
normals |
Float32Array | Flat array of normals. | |
tangents |
Float32Array |
<optional> |
Flat array of tangents. |
Returns:
Flat array of quaternions.
- Type
- Float32Array
- Deprecated
- Do not use it anymore
- Source:
ground_project_cam_quat(quat, destopt) → {Quat}
is_ie11() → {boolean}
Check if Internet Explorer 11 is using.
Returns:
Check result.
- Type
- boolean
- Source:
is_vector(o, dimensionopt) → {boolean}
Check if object is a vector.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
o |
Object | Object | ||
dimension |
number |
<optional> |
0 | Dimension, allow any if not specified |
Returns:
Check result
- Type
- boolean
- Source:
keyfind(key, value, array) → {Array.<Object>}
Search for object in array.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | Key |
value |
* | Value |
array |
Array.<Object> | Array of objects. |
Returns:
Array of found objects.
- Type
- Array.<Object>
- Source:
keysearch(key, value, array) → (nullable) {Object}
Search for object in array.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | Key. |
value |
* | Value. |
array |
Array | Array of objects. |
Returns:
First found object or null.
- Type
- Object
- Source:
lerp(t, from, to) → {number}
Linear interpolation function.
Parameters:
Name | Type | Description |
---|---|---|
t |
number | Input value. |
from |
number | Start interpolation value. |
to |
number | End interpolation value. |
Returns:
Result value.
- Type
- number
- Source:
matrix_to_quat(matrix) → {Quat}
ordered_angles_to_quat(angles, order, quatopt) → {Quat}
Convert Euler angles in the ordered intrinsic system to quaternion.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
angles |
Euler | Ordered Euler angles. Euler angles have the same order as the intrinsic rotation sequence. | |
order |
RotationSequence | Intrinsic rotation sequence. | |
quat |
Quat |
<optional> |
Destination quaternion vector. |
Returns:
Quaternion vector.
- Type
- Quat
- Source:
quat_project(quat, quat_ident_dir, plane, plane_ident_dir, destopt) → {Quat}
Perform quaternion projection.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
quat |
Quat | Quaternion to project. | ||
quat_ident_dir |
Vec3 | Direction corresponding to the identity quaternion. | ||
plane |
Vec3 | Plane direction (normal). | ||
plane_ident_dir |
Vec3 | Direction corresponding to the identity quaternion in a plane. | ||
dest |
Quat |
<optional> |
quat.create() | Destination quaternion. |
Returns:
Destination quaternion.
- Type
- Quat
- Source:
quat_to_dir(quat, ident, destopt) → {Vec3}
quat_to_euler(quat, euleropt) → {Euler}
quat_to_ordered_angles(quat, order, anglesopt) → {Euler}
Convert quaternion to Euler angles in the ordered intrinsic system.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
quat |
Quat | Quaternion vector. | |
order |
RotationSequence | Intrinsic rotation sequence. | |
angles |
Euler |
<optional> |
Destination Euler angles vector. Euler angles have the same order as the intrinsic rotation sequence. |
Returns:
Euler angles vector.
- Type
- Euler
- Source:
rad_to_deg(radians) → {number}
Convert radians to degrees.
Parameters:
Name | Type | Description |
---|---|---|
radians |
number | Angle in radians. |
Returns:
Angle in degrees.
- Type
- number
- Source:
sign(value) → {number}
Get sign of the number.
Parameters:
Name | Type | Description |
---|---|---|
value |
number | Input value |
Returns:
-1,0,1 for negative, zero or positive number accordingly
- Type
- number
- Source:
smooth(curr, last, delta, period) → {number}
Perform exponential smoothing.
Parameters:
Name | Type | Description |
---|---|---|
curr |
number | Current value. |
last |
number | Last smoothed value. |
delta |
number | Time delta. |
period |
number | Mean lifetime for averaging. |
Returns:
Smoothed value
- Type
- number
- Source:
smooth_step(t, min, max) → {number}
Smooth step function.
Parameters:
Name | Type | Description |
---|---|---|
t |
number | Input value. |
min |
number | Min clamping value. |
max |
number | Max clamping value. |
Returns:
Result value.
- Type
- number
- Source:
smooth_v(curr, last, delta, period, destopt) → {Float32Array}
Perform exponential smoothing (vector form).
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
curr |
Float32Array | Current value. | |
last |
Float32Array | Last smoothed value. | |
delta |
Float32Array | Time delta. | |
period |
Float32Array | Mean lifetime for averaging. | |
dest |
Float32Array |
<optional> |
Smoothed value |
Returns:
Smoothed value
- Type
- Float32Array
- Source:
trunc(value) → {number}
Returns the integer part of the given number.
Parameters:
Name | Type | Description |
---|---|---|
value |
number | Original value. |
Returns:
Truncated value.
- Type
- number
- Source: