Browse Source

WebGLBackground: Use onBeforeRender() to align boxMesh to ArrayCamera sub cameras. See e908eeea116dc67341b849c5036608fdcce3ba58

Mr.doob 8 years ago
parent
commit
b23c781ca2
2 changed files with 14 additions and 7 deletions
  1. 9 5
      src/renderers/webgl/WebGLBackground.js
  2. 5 2
      src/renderers/webvr/WebVRManager.js

+ 9 - 5
src/renderers/webgl/WebGLBackground.js

@@ -61,17 +61,21 @@ function WebGLBackground( renderer, state, geometries, premultipliedAlpha ) {
 					} )
 					} )
 				);
 				);
 
 
+				boxMesh.onBeforeRender = function ( renderer, scene, camera ) {
+
+					var scale = camera.far / 1.732; // distance from 0,0,0 to 1,1,1
+
+					this.matrixWorld.makeScale( scale, scale, scale );
+					this.matrixWorld.copyPosition( camera.matrixWorld );
+
+				};
+
 				geometries.update( boxMesh.geometry );
 				geometries.update( boxMesh.geometry );
 
 
 			}
 			}
 
 
 			boxMesh.material.uniforms.tCube.value = background;
 			boxMesh.material.uniforms.tCube.value = background;
 
 
-			var scale = camera.far / 1.732; // distance from 0,0,0 to 1,1,1
-
-			boxMesh.matrixWorld.makeScale( scale, scale, scale );
-			boxMesh.matrixWorld.copyPosition( camera.matrixWorld );
-
 			renderList.push( boxMesh, boxMesh.geometry, boxMesh.material, 0, null );
 			renderList.push( boxMesh, boxMesh.geometry, boxMesh.material, 0, null );
 
 
 		} else if ( background && background.isTexture ) {
 		} else if ( background && background.isTexture ) {

+ 5 - 2
src/renderers/webvr/WebVRManager.js

@@ -128,8 +128,11 @@ function WebVRManager( renderer ) {
 
 
 		//
 		//
 
 
-		cameraVR.near = camera.near;
-		cameraVR.far = camera.far;
+		cameraL.near = camera.near;
+		cameraR.near = camera.near;
+
+		cameraL.far = camera.far;
+		cameraR.far = camera.far;
 
 
 		cameraVR.matrixWorld.copy( camera.matrixWorld );
 		cameraVR.matrixWorld.copy( camera.matrixWorld );
 		cameraVR.matrixWorldInverse.copy( camera.matrixWorldInverse );
 		cameraVR.matrixWorldInverse.copy( camera.matrixWorldInverse );