@galacean/engine-xr-webxr 2.0.0-alpha.46 → 2.0.0-alpha.48

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/browser.js CHANGED
@@ -2099,13 +2099,16 @@
2099
2099
  * Converts the vector into a unit vector.
2100
2100
  * @param a - The vector to normalize
2101
2101
  * @param out - The normalized vector
2102
+ * @returns True if the vector has a unit form, otherwise false and `out` is left untouched
2102
2103
  */ Vector3.normalize = function normalize(a, out) {
2103
2104
  var _x = a._x, _y = a._y, _z = a._z;
2104
2105
  var len = Math.sqrt(_x * _x + _y * _y + _z * _z);
2105
- if (len > MathUtil.zeroTolerance) {
2106
- len = 1 / len;
2107
- out.set(_x * len, _y * len, _z * len);
2106
+ if (len > MathUtil.zeroTolerance && Number.isFinite(len)) {
2107
+ var inv = 1 / len;
2108
+ out.set(_x * inv, _y * inv, _z * inv);
2109
+ return true;
2108
2110
  }
2111
+ return false;
2109
2112
  };
2110
2113
  /**
2111
2114
  * Scale a vector by the given value.