Skip to content

Commit 67a4893

Browse files
authored
Merge pull request #14685 from WestLangley/dev-camera_pmi
Camera: added projectionMatrixInverse property
2 parents 9739866 + 085a6a7 commit 67a4893

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

docs/api/cameras/Camera.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ <h3>[property:Matrix4 matrixWorldInverse]</h3>
5555
<h3>[property:Matrix4 projectionMatrix]</h3>
5656
<p>This is the matrix which contains the projection.</p>
5757

58+
<h3>[property:Matrix4 projectionMatrixInverse]</h3>
59+
<p>The inverse of projectionMatrix.</p>
60+
5861

5962
<h2>Methods</h2>
6063
<p>See the base [page:Object3D] class for common methods.</p>

src/cameras/Camera.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ function Camera() {
1515
this.type = 'Camera';
1616

1717
this.matrixWorldInverse = new Matrix4();
18+
1819
this.projectionMatrix = new Matrix4();
20+
this.projectionMatrixInverse = new Matrix4();
1921

2022
}
2123

@@ -30,7 +32,9 @@ Camera.prototype = Object.assign( Object.create( Object3D.prototype ), {
3032
Object3D.prototype.copy.call( this, source, recursive );
3133

3234
this.matrixWorldInverse.copy( source.matrixWorldInverse );
35+
3336
this.projectionMatrix.copy( source.projectionMatrix );
37+
this.projectionMatrixInverse.copy( source.projectionMatrixInverse );
3438

3539
return this;
3640

src/cameras/OrthographicCamera.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ OrthographicCamera.prototype = Object.assign( Object.create( Camera.prototype ),
119119

120120
this.projectionMatrix.makeOrthographic( left, right, top, bottom, this.near, this.far );
121121

122+
this.projectionMatrixInverse.getInverse( this.projectionMatrix );
123+
122124
},
123125

124126
toJSON: function ( meta ) {

src/cameras/PerspectiveCamera.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ PerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ),
189189
updateProjectionMatrix: function () {
190190

191191
var near = this.near,
192-
top = near * Math.tan(
193-
_Math.DEG2RAD * 0.5 * this.fov ) / this.zoom,
192+
top = near * Math.tan( _Math.DEG2RAD * 0.5 * this.fov ) / this.zoom,
194193
height = 2 * top,
195194
width = this.aspect * height,
196195
left = - 0.5 * width,
@@ -213,6 +212,8 @@ PerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ),
213212

214213
this.projectionMatrix.makePerspective( left, left + width, top, top - height, near, this.far );
215214

215+
this.projectionMatrixInverse.getInverse( this.projectionMatrix );
216+
216217
},
217218

218219
toJSON: function ( meta ) {

0 commit comments

Comments
 (0)