Jelajahi Sumber

Merge pull request #14628 from yaoyao-cn/dev

remove unnecessary calculation in Vector3.project
Mr.doob 7 tahun lalu
induk
melakukan
e6fb40d480
1 mengubah file dengan 4 tambahan dan 12 penghapusan
  1. 4 12
      src/math/Vector3.js

+ 4 - 12
src/math/Vector3.js

@@ -312,18 +312,11 @@ Object.assign( Vector3.prototype, {
 
 	},
 
-	project: function () {
+	project: function ( camera ) {
 
-		var matrix = new Matrix4();
-
-		return function project( camera ) {
+		return this.applyMatrix4( camera.matrixWorldInverse ).applyMatrix4( camera.projectionMatrix );
 
-			matrix.multiplyMatrices( camera.projectionMatrix, matrix.getInverse( camera.matrixWorld ) );
-			return this.applyMatrix4( matrix );
-
-		};
-
-	}(),
+	},
 
 	unproject: function () {
 
@@ -331,8 +324,7 @@ Object.assign( Vector3.prototype, {
 
 		return function unproject( camera ) {
 
-			matrix.multiplyMatrices( camera.matrixWorld, matrix.getInverse( camera.projectionMatrix ) );
-			return this.applyMatrix4( matrix );
+			return this.applyMatrix4( matrix.getInverse( camera.projectionMatrix ) ).applyMatrix4( camera.matrixWorld );
 
 		};