File tree Expand file tree Collapse file tree 2 files changed +4
-16
lines changed Expand file tree Collapse file tree 2 files changed +4
-16
lines changed Original file line number Diff line number Diff line change @@ -292,15 +292,9 @@ THREE.Vector2.prototype = {
292
292
293
293
clampLength : function ( min , max ) {
294
294
295
- var oldLength = this . length ( ) ;
296
-
297
- var newLength = ( oldLength < min ) ? min : ( ( oldLength > max ) ? max : oldLength ) ;
298
-
299
- if ( oldLength !== 0 && newLength !== oldLength ) {
295
+ var length = this . length ( ) ;
300
296
301
- this . multiplyScalar ( newLength / oldLength ) ;
302
-
303
- }
297
+ this . multiplyScalar ( Math . max ( min , Math . min ( max , length ) ) / length ) ;
304
298
305
299
return this ;
306
300
Original file line number Diff line number Diff line change @@ -522,15 +522,9 @@ THREE.Vector3.prototype = {
522
522
523
523
clampLength : function ( min , max ) {
524
524
525
- var oldLength = this . length ( ) ;
526
-
527
- var newLength = ( oldLength < min ) ? min : ( ( oldLength > max ) ? max : oldLength ) ;
528
-
529
- if ( oldLength !== 0 && newLength !== oldLength ) {
525
+ var length = this . length ( ) ;
530
526
531
- this . multiplyScalar ( newLength / oldLength ) ;
532
-
533
- }
527
+ this . multiplyScalar ( Math . max ( min , Math . min ( max , length ) ) / length ) ;
534
528
535
529
return this ;
536
530
You can’t perform that action at this time.
0 commit comments