|
@@ -297,25 +297,8 @@ function WebGLRenderer( parameters ) {
|
|
|
|
|
|
//
|
|
|
|
|
|
- var backgroundCamera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
|
|
|
- var backgroundCamera2 = new PerspectiveCamera();
|
|
|
- var backgroundPlaneMesh = new Mesh(
|
|
|
- new PlaneBufferGeometry( 2, 2 ),
|
|
|
- new MeshBasicMaterial( { depthTest: false, depthWrite: false, fog: false } )
|
|
|
- );
|
|
|
- var backgroundBoxShader = ShaderLib[ 'cube' ];
|
|
|
- var backgroundBoxMesh = new Mesh(
|
|
|
- new BoxBufferGeometry( 5, 5, 5 ),
|
|
|
- new ShaderMaterial( {
|
|
|
- uniforms: backgroundBoxShader.uniforms,
|
|
|
- vertexShader: backgroundBoxShader.vertexShader,
|
|
|
- fragmentShader: backgroundBoxShader.fragmentShader,
|
|
|
- side: BackSide,
|
|
|
- depthTest: false,
|
|
|
- depthWrite: false,
|
|
|
- fog: false
|
|
|
- } )
|
|
|
- );
|
|
|
+ var backgroundPlaneCamera, backgroundPlaneMesh;
|
|
|
+ var backgroundBoxCamera, backgroundBoxMesh;
|
|
|
|
|
|
//
|
|
|
|
|
@@ -1186,25 +1169,56 @@ function WebGLRenderer( parameters ) {
|
|
|
|
|
|
if ( background && background.isCubeTexture ) {
|
|
|
|
|
|
- backgroundCamera2.projectionMatrix.copy( camera.projectionMatrix );
|
|
|
+ if ( backgroundBoxCamera === undefined ) {
|
|
|
+
|
|
|
+ backgroundBoxCamera = new PerspectiveCamera();
|
|
|
+
|
|
|
+ backgroundBoxMesh = new Mesh(
|
|
|
+ new BoxBufferGeometry( 5, 5, 5 ),
|
|
|
+ new ShaderMaterial( {
|
|
|
+ uniforms: ShaderLib.cube.uniforms,
|
|
|
+ vertexShader: ShaderLib.cube.vertexShader,
|
|
|
+ fragmentShader: ShaderLib.cube.fragmentShader,
|
|
|
+ side: BackSide,
|
|
|
+ depthTest: false,
|
|
|
+ depthWrite: false,
|
|
|
+ fog: false
|
|
|
+ } )
|
|
|
+ );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ backgroundBoxCamera.projectionMatrix.copy( camera.projectionMatrix );
|
|
|
+
|
|
|
+ backgroundBoxCamera.matrixWorld.extractRotation( camera.matrixWorld );
|
|
|
+ backgroundBoxCamera.matrixWorldInverse.getInverse( backgroundBoxCamera.matrixWorld );
|
|
|
|
|
|
- backgroundCamera2.matrixWorld.extractRotation( camera.matrixWorld );
|
|
|
- backgroundCamera2.matrixWorldInverse.getInverse( backgroundCamera2.matrixWorld );
|
|
|
|
|
|
backgroundBoxMesh.material.uniforms[ "tCube" ].value = background;
|
|
|
- backgroundBoxMesh.modelViewMatrix.multiplyMatrices( backgroundCamera2.matrixWorldInverse, backgroundBoxMesh.matrixWorld );
|
|
|
+ backgroundBoxMesh.modelViewMatrix.multiplyMatrices( backgroundBoxCamera.matrixWorldInverse, backgroundBoxMesh.matrixWorld );
|
|
|
|
|
|
objects.update( backgroundBoxMesh );
|
|
|
|
|
|
- _this.renderBufferDirect( backgroundCamera2, null, backgroundBoxMesh.geometry, backgroundBoxMesh.material, backgroundBoxMesh, null );
|
|
|
+ _this.renderBufferDirect( backgroundBoxCamera, null, backgroundBoxMesh.geometry, backgroundBoxMesh.material, backgroundBoxMesh, null );
|
|
|
|
|
|
} else if ( background && background.isTexture ) {
|
|
|
|
|
|
+ if ( backgroundPlaneCamera === undefined ) {
|
|
|
+
|
|
|
+ backgroundPlaneCamera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
|
|
|
+
|
|
|
+ backgroundPlaneMesh = new Mesh(
|
|
|
+ new PlaneBufferGeometry( 2, 2 ),
|
|
|
+ new MeshBasicMaterial( { depthTest: false, depthWrite: false, fog: false } )
|
|
|
+ );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
backgroundPlaneMesh.material.map = background;
|
|
|
|
|
|
objects.update( backgroundPlaneMesh );
|
|
|
|
|
|
- _this.renderBufferDirect( backgroundCamera, null, backgroundPlaneMesh.geometry, backgroundPlaneMesh.material, backgroundPlaneMesh, null );
|
|
|
+ _this.renderBufferDirect( backgroundPlaneCamera, null, backgroundPlaneMesh.geometry, backgroundPlaneMesh.material, backgroundPlaneMesh, null );
|
|
|
|
|
|
}
|
|
|
|