From 15687ff4dc93145401e4e0344711cbd5c7d5e986 Mon Sep 17 00:00:00 2001 From: Yehor <20585619+satelllte@users.noreply.github.com> Date: Tue, 5 Nov 2024 16:01:24 +0200 Subject: [PATCH] Vector3: consume MathUtils.clamp internally --- src/math/Vector3.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/math/Vector3.js b/src/math/Vector3.js index 303276b4856b90..8a6caf5c3d5f59 100644 --- a/src/math/Vector3.js +++ b/src/math/Vector3.js @@ -338,9 +338,9 @@ class Vector3 { // assumes min < max, componentwise - this.x = Math.max( min.x, Math.min( max.x, this.x ) ); - this.y = Math.max( min.y, Math.min( max.y, this.y ) ); - this.z = Math.max( min.z, Math.min( max.z, this.z ) ); + this.x = MathUtils.clamp( this.x, min.x, max.x ); + this.y = MathUtils.clamp( this.y, min.y, max.y ); + this.z = MathUtils.clamp( this.z, min.z, max.z ); return this; @@ -348,9 +348,9 @@ class Vector3 { clampScalar( minVal, maxVal ) { - this.x = Math.max( minVal, Math.min( maxVal, this.x ) ); - this.y = Math.max( minVal, Math.min( maxVal, this.y ) ); - this.z = Math.max( minVal, Math.min( maxVal, this.z ) ); + this.x = MathUtils.clamp( this.x, minVal, maxVal ); + this.y = MathUtils.clamp( this.y, minVal, maxVal ); + this.z = MathUtils.clamp( this.z, minVal, maxVal ); return this; @@ -360,7 +360,7 @@ class Vector3 { const length = this.length(); - return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) ); + return this.divideScalar( length || 1 ).multiplyScalar( MathUtils.clamp( length, min, max ) ); }