@galacean/engine-math 2.0.0-alpha.47 → 2.0.0-alpha.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +6 -3
- package/dist/main.js.map +1 -1
- package/dist/module.js +6 -3
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
- package/types/Vector3.d.ts +2 -1
package/dist/main.js
CHANGED
|
@@ -469,13 +469,16 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
469
469
|
* Converts the vector into a unit vector.
|
|
470
470
|
* @param a - The vector to normalize
|
|
471
471
|
* @param out - The normalized vector
|
|
472
|
+
* @returns True if the vector has a unit form, otherwise false and `out` is left untouched
|
|
472
473
|
*/ Vector3.normalize = function normalize(a, out) {
|
|
473
474
|
var _x = a._x, _y = a._y, _z = a._z;
|
|
474
475
|
var len = Math.sqrt(_x * _x + _y * _y + _z * _z);
|
|
475
|
-
if (len > MathUtil.zeroTolerance) {
|
|
476
|
-
|
|
477
|
-
out.set(_x *
|
|
476
|
+
if (len > MathUtil.zeroTolerance && Number.isFinite(len)) {
|
|
477
|
+
var inv = 1 / len;
|
|
478
|
+
out.set(_x * inv, _y * inv, _z * inv);
|
|
479
|
+
return true;
|
|
478
480
|
}
|
|
481
|
+
return false;
|
|
479
482
|
};
|
|
480
483
|
/**
|
|
481
484
|
* Scale a vector by the given value.
|