Explorar o código

WebGLBackground: Create normalized box.

Mr.doob %!s(int64=8) %!d(string=hai) anos
pai
achega
0738904d24
Modificáronse 1 ficheiros con 4 adicións e 3 borrados
  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 );

粤ICP备19079148号