Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions src/math/Vector3.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,27 +312,19 @@ 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 );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure using camera.matrixWorldInverse is safe? I wonder if there are scenarios where this matrix might not be up to date (or in sync with camera.matrixWorld)...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, i am sure. camera.matrixWorldInverse was updated by the camera itself automatically in Camera.updateMatrixWorld. and it should be sync with camera.matrixWorld as the name implies.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


matrix.multiplyMatrices( camera.projectionMatrix, matrix.getInverse( camera.matrixWorld ) );
return this.applyMatrix4( matrix );

};

}(),
},

unproject: function () {

var matrix = new Matrix4();

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 );

};

Expand Down