File tree Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Original file line number Diff line number Diff line change 66 */
77
88import { _Math } from './Math.js' ;
9- import { Vector3 } from './Vector3.js' ;
109
1110function Quaternion ( x , y , z , w ) {
1211
@@ -354,15 +353,12 @@ Object.assign( Quaternion.prototype, {
354353
355354 // assumes direction vectors vFrom and vTo are normalized
356355
357- var v1 = new Vector3 ( ) ;
358356 var r ;
359357
360358 var EPS = 0.000001 ;
361359
362360 return function setFromUnitVectors ( vFrom , vTo ) {
363361
364- if ( v1 === undefined ) v1 = new Vector3 ( ) ;
365-
366362 r = vFrom . dot ( vTo ) + 1 ;
367363
368364 if ( r < EPS ) {
@@ -371,24 +367,30 @@ Object.assign( Quaternion.prototype, {
371367
372368 if ( Math . abs ( vFrom . x ) > Math . abs ( vFrom . z ) ) {
373369
374- v1 . set ( - vFrom . y , vFrom . x , 0 ) ;
370+ this . _x = - vFrom . y ;
371+ this . _y = vFrom . x ;
372+ this . _z = 0 ;
373+ this . _w = r ;
375374
376375 } else {
377376
378- v1 . set ( 0 , - vFrom . z , vFrom . y ) ;
377+ this . _x = 0 ;
378+ this . _y = - vFrom . z ;
379+ this . _z = vFrom . y ;
380+ this . _w = r ;
379381
380382 }
381383
382384 } else {
383385
384- v1 . crossVectors ( vFrom , vTo ) ;
386+ // crossVectors( vFrom, vTo ); // inlined to avoid cyclic dependency on Vector3
385387
386- }
388+ this . _x = vFrom . y * vTo . z - vFrom . z * vTo . y ;
389+ this . _y = vFrom . z * vTo . x - vFrom . x * vTo . z ;
390+ this . _z = vFrom . x * vTo . y - vFrom . y * vTo . x ;
391+ this . _w = r ;
387392
388- this . _x = v1 . x ;
389- this . _y = v1 . y ;
390- this . _z = v1 . z ;
391- this . _w = r ;
393+ }
392394
393395 return this . normalize ( ) ;
394396
You can’t perform that action at this time.
0 commit comments