|
14656 | 14656 | boxMesh.material.uniforms.tCube.value = ( background.isWebGLRenderTargetCube ) ? background.texture : background; |
14657 | 14657 | boxMesh.material.uniforms.tFlip.value = ( background.isWebGLRenderTargetCube ) ? 1 : - 1; |
14658 | 14658 |
|
| 14659 | + // push to the pre-sorted opaque render list |
14659 | 14660 | renderList.push( boxMesh, boxMesh.geometry, boxMesh.material, 0, null ); |
14660 | 14661 |
|
14661 | 14662 | } else if ( background && background.isTexture ) { |
|
14683 | 14684 |
|
14684 | 14685 | planeMesh.material.uniforms.t2D.value = background; |
14685 | 14686 |
|
| 14687 | + // push to the pre-sorted opaque render list |
14686 | 14688 | renderList.push( planeMesh, planeMesh.geometry, planeMesh.material, 0, null ); |
14687 | 14689 |
|
14688 | 14690 | } |
@@ -21262,72 +21264,73 @@ |
21262 | 21264 |
|
21263 | 21265 | constructor: ArrayCamera, |
21264 | 21266 |
|
21265 | | - isArrayCamera: true, |
| 21267 | + isArrayCamera: true |
21266 | 21268 |
|
21267 | | - /** |
21268 | | - * Assumes 2 cameras that are perpendicular and share an X-axis, and that |
21269 | | - * the cameras' projection and world matrices have already been set. |
21270 | | - * And that near and far planes are identical for both cameras. |
21271 | | - */ |
21272 | | - setProjectionFromUnion: function () { |
21273 | | - |
21274 | | - var cameraLPos = new Vector3(); |
21275 | | - var cameraRPos = new Vector3(); |
21276 | | - |
21277 | | - return function () { |
21278 | | - |
21279 | | - cameraLPos.setFromMatrixPosition( this.cameras[ 0 ].matrixWorld ); |
21280 | | - cameraRPos.setFromMatrixPosition( this.cameras[ 1 ].matrixWorld ); |
21281 | | - |
21282 | | - var ipd = cameraLPos.distanceTo( cameraRPos ); |
21283 | | - |
21284 | | - var projL = this.cameras[ 0 ].projectionMatrix; |
21285 | | - var projR = this.cameras[ 1 ].projectionMatrix; |
21286 | | - |
21287 | | - // VR systems will have identical far and near planes, and |
21288 | | - // most likely identical top and bottom frustum extents. |
21289 | | - // via: https://computergraphics.stackexchange.com/a/4765 |
21290 | | - var near = projL[ 14 ] / ( projL[ 10 ] - 1 ); |
21291 | | - var far = projL[ 14 ] / ( projL[ 10 ] + 1 ); |
21292 | | - |
21293 | | - var leftFovL = ( projL[ 8 ] - 1 ) / projL[ 0 ]; |
21294 | | - var rightFovR = ( projR[ 8 ] + 1 ) / projR[ 0 ]; |
21295 | | - var leftL = leftFovL * near; |
21296 | | - var rightR = rightFovR * near; |
21297 | | - var topL = near * ( projL[ 9 ] + 1 ) / projL[ 5 ]; |
21298 | | - var topR = near * ( projR[ 9 ] + 1 ) / projR[ 5 ]; |
21299 | | - var bottomL = near * ( projL[ 9 ] - 1 ) / projL[ 5 ]; |
21300 | | - var bottomR = near * ( projR[ 9 ] - 1 ) / projR[ 5 ]; |
21301 | | - |
21302 | | - // Calculate the new camera's position offset from the |
21303 | | - // left camera. |
21304 | | - var zOffset = ipd / ( leftFovL + rightFovR ); |
21305 | | - var xOffset = zOffset * leftFovL; |
21306 | | - |
21307 | | - // TODO: Better way to apply this offset? |
21308 | | - this.cameras[ 0 ].matrixWorld.decompose( this.position, this.quaternion, this.scale ); |
21309 | | - this.translateX( xOffset ); |
21310 | | - this.translateZ( - zOffset ); |
21311 | | - this.matrixWorld.compose( this.position, this.quaternion, this.scale ); |
21312 | | - this.matrixWorldInverse.getInverse( this.matrixWorld ); |
21313 | | - |
21314 | | - // Find the union of the frustum values of the cameras and scale |
21315 | | - // the values so that the near plane's position does not change in world space, |
21316 | | - // although must now be relative to the new union camera. |
21317 | | - var near2 = near + zOffset; |
21318 | | - var far2 = far + zOffset; |
21319 | | - var left = leftL - xOffset; |
21320 | | - var right = rightR + ( ipd - xOffset ); |
21321 | | - var top = Math.max( topL, topR ); |
21322 | | - var bottom = Math.min( bottomL, bottomR ); |
21323 | | - |
21324 | | - this.projectionMatrix.makePerspective( left, right, top, bottom, near2, far2 ); |
| 21269 | + } ); |
21325 | 21270 |
|
21326 | | - }; |
| 21271 | + /** |
| 21272 | + * @author jsantell / https://www.jsantell.com/ |
| 21273 | + * @author mrdoob / http://mrdoob.com/ |
| 21274 | + */ |
21327 | 21275 |
|
21328 | | - }(), |
| 21276 | + var cameraLPos = new Vector3(); |
| 21277 | + var cameraRPos = new Vector3(); |
21329 | 21278 |
|
21330 | | - } ); |
| 21279 | + /** |
| 21280 | + * Assumes 2 cameras that are perpendicular and share an X-axis, and that |
| 21281 | + * the cameras' projection and world matrices have already been set. |
| 21282 | + * And that near and far planes are identical for both cameras. |
| 21283 | + */ |
| 21284 | + function setProjectionFromUnion( camera, cameraL, cameraR ) { |
| 21285 | + |
| 21286 | + cameraLPos.setFromMatrixPosition( cameraL.matrixWorld ); |
| 21287 | + cameraRPos.setFromMatrixPosition( cameraR.matrixWorld ); |
| 21288 | + |
| 21289 | + var ipd = cameraLPos.distanceTo( cameraRPos ); |
| 21290 | + |
| 21291 | + var projL = cameraL.projectionMatrix; |
| 21292 | + var projR = cameraR.projectionMatrix; |
| 21293 | + |
| 21294 | + // VR systems will have identical far and near planes, and |
| 21295 | + // most likely identical top and bottom frustum extents. |
| 21296 | + // via: https://computergraphics.stackexchange.com/a/4765 |
| 21297 | + var near = projL[ 14 ] / ( projL[ 10 ] - 1 ); |
| 21298 | + var far = projL[ 14 ] / ( projL[ 10 ] + 1 ); |
| 21299 | + |
| 21300 | + var leftFovL = ( projL[ 8 ] - 1 ) / projL[ 0 ]; |
| 21301 | + var rightFovR = ( projR[ 8 ] + 1 ) / projR[ 0 ]; |
| 21302 | + var leftL = leftFovL * near; |
| 21303 | + var rightR = rightFovR * near; |
| 21304 | + var topL = near * ( projL[ 9 ] + 1 ) / projL[ 5 ]; |
| 21305 | + var topR = near * ( projR[ 9 ] + 1 ) / projR[ 5 ]; |
| 21306 | + var bottomL = near * ( projL[ 9 ] - 1 ) / projL[ 5 ]; |
| 21307 | + var bottomR = near * ( projR[ 9 ] - 1 ) / projR[ 5 ]; |
| 21308 | + |
| 21309 | + // Calculate the new camera's position offset from the |
| 21310 | + // left camera. |
| 21311 | + var zOffset = ipd / ( leftFovL + rightFovR ); |
| 21312 | + var xOffset = zOffset * leftFovL; |
| 21313 | + |
| 21314 | + // TODO: Better way to apply this offset? |
| 21315 | + cameraL.matrixWorld.decompose( camera.position, camera.quaternion, camera.scale ); |
| 21316 | + camera.translateX( xOffset ); |
| 21317 | + camera.translateZ( - zOffset ); |
| 21318 | + camera.matrixWorld.compose( camera.position, camera.quaternion, camera.scale ); |
| 21319 | + camera.matrixWorldInverse.getInverse( camera.matrixWorld ); |
| 21320 | + |
| 21321 | + // Find the union of the frustum values of the cameras and scale |
| 21322 | + // the values so that the near plane's position does not change in world space, |
| 21323 | + // although must now be relative to the new union camera. |
| 21324 | + var near2 = near + zOffset; |
| 21325 | + var far2 = far + zOffset; |
| 21326 | + var left = leftL - xOffset; |
| 21327 | + var right = rightR + ( ipd - xOffset ); |
| 21328 | + var top = Math.max( topL, topR ); |
| 21329 | + var bottom = Math.min( bottomL, bottomR ); |
| 21330 | + |
| 21331 | + camera.projectionMatrix.makePerspective( left, right, top, bottom, near2, far2 ); |
| 21332 | + |
| 21333 | + } |
21331 | 21334 |
|
21332 | 21335 | /** |
21333 | 21336 | * @author mrdoob / http://mrdoob.com/ |
|
21645 | 21648 | cameraL.projectionMatrix.fromArray( frameData.leftProjectionMatrix ); |
21646 | 21649 | cameraR.projectionMatrix.fromArray( frameData.rightProjectionMatrix ); |
21647 | 21650 |
|
21648 | | - cameraVR.setProjectionFromUnion(); |
| 21651 | + setProjectionFromUnion( cameraVR, cameraL, cameraR ); |
21649 | 21652 |
|
21650 | 21653 | // |
21651 | 21654 |
|
|
21888 | 21891 |
|
21889 | 21892 | } |
21890 | 21893 |
|
21891 | | - cameraVR.setProjectionFromUnion(); |
| 21894 | + setProjectionFromUnion( cameraVR, cameraL, cameraR ); |
21892 | 21895 |
|
21893 | 21896 | return cameraVR; |
21894 | 21897 |
|
|
0 commit comments