MCPcopy
hub / github.com/mrdoob/three.js / projectOnVector

Method projectOnVector

src/math/Vector3.js:889–899  ·  view source on GitHub ↗

* Projects this vector onto the given one. * * @param {Vector3} v - The vector to project to. * @return {Vector3} A reference to this vector.

( v )

Source from the content-addressed store, hash-verified

887 * @return {Vector3} A reference to this vector.
888 */
889 projectOnVector( v ) {
890
891 const denominator = v.lengthSq();
892
893 if ( denominator === 0 ) return this.set( 0, 0, 0 );
894
895 const scalar = v.dot( this ) / denominator;
896
897 return this.copy( v ).multiplyScalar( scalar );
898
899 }
900
901 /**
902 * Projects this vector onto a plane by subtracting this

Callers 2

Vector3.tests.jsFile · 0.80
projectOnPlaneMethod · 0.80

Calls 5

setMethod · 0.95
copyMethod · 0.95
lengthSqMethod · 0.45
dotMethod · 0.45
multiplyScalarMethod · 0.45

Tested by

no test coverage detected