|
@@ -293,32 +293,15 @@ Vector3.prototype = {
|
|
|
|
|
|
applyMatrix4: function ( m ) {
|
|
|
|
|
|
- // input: THREE.Matrix4 affine matrix
|
|
|
-
|
|
|
var x = this.x, y = this.y, z = this.z;
|
|
|
var e = m.elements;
|
|
|
|
|
|
this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ];
|
|
|
this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ];
|
|
|
this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ];
|
|
|
+ var w = e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ];
|
|
|
|
|
|
- return this;
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- applyProjection: function ( m ) {
|
|
|
-
|
|
|
- // input: THREE.Matrix4 projection matrix
|
|
|
-
|
|
|
- var x = this.x, y = this.y, z = this.z;
|
|
|
- var e = m.elements;
|
|
|
- var d = 1 / ( e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] ); // perspective divide
|
|
|
-
|
|
|
- this.x = ( e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] ) * d;
|
|
|
- this.y = ( e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] ) * d;
|
|
|
- this.z = ( e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] ) * d;
|
|
|
-
|
|
|
- return this;
|
|
|
+ return this.divideScalar( w );
|
|
|
|
|
|
},
|
|
|
|
|
@@ -353,7 +336,7 @@ Vector3.prototype = {
|
|
|
if ( matrix === undefined ) matrix = new Matrix4();
|
|
|
|
|
|
matrix.multiplyMatrices( camera.projectionMatrix, matrix.getInverse( camera.matrixWorld ) );
|
|
|
- return this.applyProjection( matrix );
|
|
|
+ return this.applyMatrix4( matrix );
|
|
|
|
|
|
};
|
|
|
|
|
@@ -368,7 +351,7 @@ Vector3.prototype = {
|
|
|
if ( matrix === undefined ) matrix = new Matrix4();
|
|
|
|
|
|
matrix.multiplyMatrices( camera.matrixWorld, matrix.getInverse( camera.projectionMatrix ) );
|
|
|
- return this.applyProjection( matrix );
|
|
|
+ return this.applyMatrix4( matrix );
|
|
|
|
|
|
};
|
|
|
|