Browse Source

CubeTexturePass: Minor fixes.

Mugen87 4 years ago
parent
commit
4eba3f53a5

+ 2 - 1
examples/js/postprocessing/CubeTexturePass.js

@@ -10,7 +10,7 @@ THREE.CubeTexturePass = function ( camera, envMap, opacity ) {
 	this.cubeMesh = new THREE.Mesh(
 	this.cubeMesh = new THREE.Mesh(
 		new THREE.BoxGeometry( 10, 10, 10 ),
 		new THREE.BoxGeometry( 10, 10, 10 ),
 		new THREE.ShaderMaterial( {
 		new THREE.ShaderMaterial( {
-			uniforms: this.cubeShader.uniforms,
+			uniforms: THREE.UniformsUtils.clone( this.cubeShader.uniforms ),
 			vertexShader: this.cubeShader.vertexShader,
 			vertexShader: this.cubeShader.vertexShader,
 			fragmentShader: this.cubeShader.fragmentShader,
 			fragmentShader: this.cubeShader.fragmentShader,
 			depthTest: false,
 			depthTest: false,
@@ -51,6 +51,7 @@ THREE.CubeTexturePass.prototype = Object.assign( Object.create( THREE.Pass.proto
 		this.cubeCamera.quaternion.setFromRotationMatrix( this.camera.matrixWorld );
 		this.cubeCamera.quaternion.setFromRotationMatrix( this.camera.matrixWorld );
 
 
 		this.cubeMesh.material.uniforms.envMap.value = this.envMap;
 		this.cubeMesh.material.uniforms.envMap.value = this.envMap;
+		this.cubeMesh.material.uniforms.flipEnvMap.value = ( this.envMap.isCubeTexture && this.envMap._needsFlipEnvMap ) ? - 1 : 1;
 		this.cubeMesh.material.uniforms.opacity.value = this.opacity;
 		this.cubeMesh.material.uniforms.opacity.value = this.opacity;
 		this.cubeMesh.material.transparent = ( this.opacity < 1.0 );
 		this.cubeMesh.material.transparent = ( this.opacity < 1.0 );
 
 

+ 4 - 2
examples/jsm/postprocessing/CubeTexturePass.js

@@ -5,7 +5,8 @@ import {
 	PerspectiveCamera,
 	PerspectiveCamera,
 	Scene,
 	Scene,
 	ShaderLib,
 	ShaderLib,
-	ShaderMaterial
+	ShaderMaterial,
+	UniformsUtils
 } from '../../../build/three.module.js';
 } from '../../../build/three.module.js';
 import { Pass } from '../postprocessing/Pass.js';
 import { Pass } from '../postprocessing/Pass.js';
 
 
@@ -21,7 +22,7 @@ var CubeTexturePass = function ( camera, envMap, opacity ) {
 	this.cubeMesh = new Mesh(
 	this.cubeMesh = new Mesh(
 		new BoxGeometry( 10, 10, 10 ),
 		new BoxGeometry( 10, 10, 10 ),
 		new ShaderMaterial( {
 		new ShaderMaterial( {
-			uniforms: this.cubeShader.uniforms,
+			uniforms: UniformsUtils.clone( this.cubeShader.uniforms ),
 			vertexShader: this.cubeShader.vertexShader,
 			vertexShader: this.cubeShader.vertexShader,
 			fragmentShader: this.cubeShader.fragmentShader,
 			fragmentShader: this.cubeShader.fragmentShader,
 			depthTest: false,
 			depthTest: false,
@@ -62,6 +63,7 @@ CubeTexturePass.prototype = Object.assign( Object.create( Pass.prototype ), {
 		this.cubeCamera.quaternion.setFromRotationMatrix( this.camera.matrixWorld );
 		this.cubeCamera.quaternion.setFromRotationMatrix( this.camera.matrixWorld );
 
 
 		this.cubeMesh.material.uniforms.envMap.value = this.envMap;
 		this.cubeMesh.material.uniforms.envMap.value = this.envMap;
+		this.cubeMesh.material.uniforms.flipEnvMap.value = ( this.envMap.isCubeTexture && this.envMap._needsFlipEnvMap ) ? - 1 : 1;
 		this.cubeMesh.material.uniforms.opacity.value = this.opacity;
 		this.cubeMesh.material.uniforms.opacity.value = this.opacity;
 		this.cubeMesh.material.transparent = ( this.opacity < 1.0 );
 		this.cubeMesh.material.transparent = ( this.opacity < 1.0 );