We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 578978c commit a1d4a3aCopy full SHA for a1d4a3a
src/math/Vector3.js
@@ -594,23 +594,13 @@ THREE.Vector3.prototype = {
594
595
},
596
597
- projectOnVector: function () {
+ projectOnVector: function ( vector ) {
598
599
- var v1, dot;
600
-
601
- return function projectOnVector( vector ) {
602
603
- if ( v1 === undefined ) v1 = new THREE.Vector3();
604
605
- v1.copy( vector ).normalize();
606
607
- dot = this.dot( v1 );
608
609
- return this.copy( v1 ).multiplyScalar( dot );
610
611
- };
612
613
- }(),
+ var scalar = vector.dot( this ) / vector.lengthSq();
+
+ return this.copy( vector ).multiplyScalar( scalar );
+ },
614
615
projectOnPlane: function () {
616
0 commit comments