Browse Source

WebGLBackground: Create normalized box.

Mr.doob 8 years ago
parent
commit
0738904d24
1 changed files with 4 additions and 3 deletions
  1. 4 3
      src/renderers/webgl/WebGLBackground.js

+ 4 - 3
src/renderers/webgl/WebGLBackground.js

@@ -46,10 +46,11 @@ function WebGLBackground( renderer, state, geometries, premultipliedAlpha ) {
 
 			if ( boxMesh === undefined ) {
 
-				// TODO Adjust skybox to camera somehow
+				// Normalized box
+				// 1.1547 = (1,1,1).normalize() * 2.0
 
 				boxMesh = new Mesh(
-					new BoxBufferGeometry( 2, 2, 2 ),
+					new BoxBufferGeometry( 1.1547, 1.1547, 1.1547 ),
 					new ShaderMaterial( {
 						uniforms: ShaderLib.cube.uniforms,
 						vertexShader: ShaderLib.cube.vertexShader,
@@ -63,7 +64,7 @@ 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
+					var scale = camera.far;
 
 					this.matrixWorld.makeScale( scale, scale, scale );
 					this.matrixWorld.copyPosition( camera.matrixWorld );