|
|
@@ -4,15 +4,17 @@ import { PlaneGeometry } from '../../geometries/PlaneGeometry.js';
|
|
|
import { ShaderMaterial } from '../../materials/ShaderMaterial.js';
|
|
|
import { Color } from '../../math/Color.js';
|
|
|
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
|
-import { Euler } from '../../math/Euler.js';
|
|
|
+import { Matrix3 } from '../../math/Matrix3.js';
|
|
|
import { Matrix4 } from '../../math/Matrix4.js';
|
|
|
import { Mesh } from '../../objects/Mesh.js';
|
|
|
import { ShaderLib } from '../shaders/ShaderLib.js';
|
|
|
import { cloneUniforms, getUnlitUniformColorSpace } from '../shaders/UniformsUtils.js';
|
|
|
|
|
|
const _rgb = { r: 0, b: 0, g: 0 };
|
|
|
-const _e1 = /*@__PURE__*/ new Euler();
|
|
|
const _m1 = /*@__PURE__*/ new Matrix4();
|
|
|
+const _m = /*@__PURE__*/ new Matrix3();
|
|
|
+
|
|
|
+_m.set( - 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 );
|
|
|
|
|
|
function WebGLBackground( renderer, environments, state, objects, alpha, premultipliedAlpha ) {
|
|
|
|
|
|
@@ -130,24 +132,22 @@ function WebGLBackground( renderer, environments, state, objects, alpha, premult
|
|
|
|
|
|
}
|
|
|
|
|
|
- _e1.copy( scene.backgroundRotation );
|
|
|
|
|
|
- // accommodate left-handed frame
|
|
|
- _e1.x *= - 1; _e1.y *= - 1; _e1.z *= - 1;
|
|
|
+ boxMesh.material.uniforms.envMap.value = background;
|
|
|
+ boxMesh.material.uniforms.backgroundBlurriness.value = scene.backgroundBlurriness;
|
|
|
+ boxMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
|
|
|
+
|
|
|
+
|
|
|
+ // note: since the matrix is orthonormal, we can use the more-efficient transpose() in lieu of invert()
|
|
|
+ boxMesh.material.uniforms.backgroundRotation.value.setFromMatrix4( _m1.makeRotationFromEuler( scene.backgroundRotation ) ).transpose();
|
|
|
|
|
|
if ( background.isCubeTexture && background.isRenderTargetTexture === false ) {
|
|
|
|
|
|
- // environment maps which are not cube render targets or PMREMs follow a different convention
|
|
|
- _e1.y *= - 1;
|
|
|
- _e1.z *= - 1;
|
|
|
+ boxMesh.material.uniforms.backgroundRotation.value.premultiply( _m );
|
|
|
|
|
|
}
|
|
|
|
|
|
- boxMesh.material.uniforms.envMap.value = background;
|
|
|
- boxMesh.material.uniforms.flipEnvMap.value = ( background.isCubeTexture && background.isRenderTargetTexture === false ) ? - 1 : 1;
|
|
|
- boxMesh.material.uniforms.backgroundBlurriness.value = scene.backgroundBlurriness;
|
|
|
- boxMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
|
|
|
- boxMesh.material.uniforms.backgroundRotation.value.setFromMatrix4( _m1.makeRotationFromEuler( _e1 ) );
|
|
|
+
|
|
|
boxMesh.material.toneMapped = ColorManagement.getTransfer( background.colorSpace ) !== SRGBTransfer;
|
|
|
|
|
|
if ( currentBackground !== background ||
|