File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -290,6 +290,28 @@ THREE.Vector2.prototype = {
290
290
291
291
} ( ) ,
292
292
293
+ clampLength : function ( ) {
294
+
295
+ var oldLength , newLength ;
296
+
297
+ return function clampLength ( min , max ) {
298
+
299
+ oldLength = this . length ( ) ;
300
+
301
+ newLength = ( oldLength < min ) ? min : ( ( oldLength > max ) ? max : oldLength ) ;
302
+
303
+ if ( newLength !== oldLength ) {
304
+
305
+ this . multiplyScalar ( newLength / oldLength ) ;
306
+
307
+ }
308
+
309
+ return this ;
310
+
311
+ } ;
312
+
313
+ } ( ) ,
314
+
293
315
floor : function ( ) {
294
316
295
317
this . x = Math . floor ( this . x ) ;
Original file line number Diff line number Diff line change @@ -520,6 +520,28 @@ THREE.Vector3.prototype = {
520
520
521
521
} ( ) ,
522
522
523
+ clampLength : function ( ) {
524
+
525
+ var oldLength , newLength ;
526
+
527
+ return function clampLength ( min , max ) {
528
+
529
+ oldLength = this . length ( ) ;
530
+
531
+ newLength = ( oldLength < min ) ? min : ( ( oldLength > max ) ? max : oldLength ) ;
532
+
533
+ if ( newLength !== oldLength ) {
534
+
535
+ this . multiplyScalar ( newLength / oldLength ) ;
536
+
537
+ }
538
+
539
+ return this ;
540
+
541
+ } ;
542
+
543
+ } ( ) ,
544
+
523
545
floor : function ( ) {
524
546
525
547
this . x = Math . floor ( this . x ) ;
You can’t perform that action at this time.
0 commit comments