File tree 3 files changed +34
-70
lines changed
3 files changed +34
-70
lines changed Original file line number Diff line number Diff line change @@ -174,10 +174,15 @@ THREE.Vector2.prototype = {
174
174
175
175
} ,
176
176
177
- multiplyScalar : function ( s ) {
177
+ multiplyScalar : function ( scalar ) {
178
178
179
- this . x *= s ;
180
- this . y *= s ;
179
+ if ( isFinite ( scalar ) ) {
180
+ this . x *= scalar ;
181
+ this . y *= scalar ;
182
+ } else {
183
+ this . x = 0 ;
184
+ this . y = 0 ;
185
+ }
181
186
182
187
return this ;
183
188
@@ -194,21 +199,7 @@ THREE.Vector2.prototype = {
194
199
195
200
divideScalar : function ( scalar ) {
196
201
197
- if ( scalar !== 0 ) {
198
-
199
- var invScalar = 1 / scalar ;
200
-
201
- this . x *= invScalar ;
202
- this . y *= invScalar ;
203
-
204
- } else {
205
-
206
- this . x = 0 ;
207
- this . y = 0 ;
208
-
209
- }
210
-
211
- return this ;
202
+ return this . multiplyScalar ( 1 / scalar ) ;
212
203
213
204
} ,
214
205
@@ -363,9 +354,7 @@ THREE.Vector2.prototype = {
363
354
364
355
setLength : function ( length ) {
365
356
366
- this . multiplyScalar ( length / this . length ( ) ) ;
367
-
368
- return this ;
357
+ return this . multiplyScalar ( length / this . length ( ) ) ;
369
358
370
359
} ,
371
360
Original file line number Diff line number Diff line change @@ -198,9 +198,15 @@ THREE.Vector3.prototype = {
198
198
199
199
multiplyScalar : function ( scalar ) {
200
200
201
- this . x *= scalar ;
202
- this . y *= scalar ;
203
- this . z *= scalar ;
201
+ if ( isFinite ( scalar ) ) {
202
+ this . x *= scalar ;
203
+ this . y *= scalar ;
204
+ this . z *= scalar ;
205
+ } else {
206
+ this . x = 0 ;
207
+ this . y = 0 ;
208
+ this . z = 0 ;
209
+ }
204
210
205
211
return this ;
206
212
@@ -392,23 +398,7 @@ THREE.Vector3.prototype = {
392
398
393
399
divideScalar : function ( scalar ) {
394
400
395
- if ( scalar !== 0 ) {
396
-
397
- var invScalar = 1 / scalar ;
398
-
399
- this . x *= invScalar ;
400
- this . y *= invScalar ;
401
- this . z *= invScalar ;
402
-
403
- } else {
404
-
405
- this . x = 0 ;
406
- this . y = 0 ;
407
- this . z = 0 ;
408
-
409
- }
410
-
411
- return this ;
401
+ return this . multiplyScalar ( 1 / scalar ) ;
412
402
413
403
} ,
414
404
@@ -558,9 +548,7 @@ THREE.Vector3.prototype = {
558
548
559
549
setLength : function ( length ) {
560
550
561
- this . multiplyScalar ( length / this . length ( ) ) ;
562
-
563
- return this ;
551
+ return this . multiplyScalar ( length / this . length ( ) ) ;
564
552
565
553
} ,
566
554
Original file line number Diff line number Diff line change @@ -200,10 +200,17 @@ THREE.Vector4.prototype = {
200
200
201
201
multiplyScalar : function ( scalar ) {
202
202
203
- this . x *= scalar ;
204
- this . y *= scalar ;
205
- this . z *= scalar ;
206
- this . w *= scalar ;
203
+ if ( isFinite ( scalar ) ) {
204
+ this . x *= scalar ;
205
+ this . y *= scalar ;
206
+ this . z *= scalar ;
207
+ this . w *= scalar ;
208
+ } else {
209
+ this . x = 0 ;
210
+ this . y = 0 ;
211
+ this . z = 0 ;
212
+ this . w = 1 ;
213
+ }
207
214
208
215
return this ;
209
216
@@ -229,25 +236,7 @@ THREE.Vector4.prototype = {
229
236
230
237
divideScalar : function ( scalar ) {
231
238
232
- if ( scalar !== 0 ) {
233
-
234
- var invScalar = 1 / scalar ;
235
-
236
- this . x *= invScalar ;
237
- this . y *= invScalar ;
238
- this . z *= invScalar ;
239
- this . w *= invScalar ;
240
-
241
- } else {
242
-
243
- this . x = 0 ;
244
- this . y = 0 ;
245
- this . z = 0 ;
246
- this . w = 1 ;
247
-
248
- }
249
-
250
- return this ;
239
+ return this . multiplyScalar ( 1 / scalar ) ;
251
240
252
241
} ,
253
242
@@ -553,9 +542,7 @@ THREE.Vector4.prototype = {
553
542
554
543
setLength : function ( length ) {
555
544
556
- this . multiplyScalar ( length / this . length ( ) ) ;
557
-
558
- return this ;
545
+ return this . multiplyScalar ( length / this . length ( ) ) ;
559
546
560
547
} ,
561
548
You can’t perform that action at this time.
0 commit comments