浏览代码

Merge pull request #21130 from Mugen87/dev51

CubeTexturePass: Minor fixes.
Mr.doob 4 年之前
父节点
当前提交
a2766486cf
共有 2 个文件被更改,包括 6 次插入3 次删除
  1. 2 1
      examples/js/postprocessing/CubeTexturePass.js
  2. 4 2
      examples/jsm/postprocessing/CubeTexturePass.js

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

@@ -10,7 +10,7 @@ THREE.CubeTexturePass = function ( camera, envMap, opacity ) {
 	this.cubeMesh = new THREE.Mesh(
 		new THREE.BoxGeometry( 10, 10, 10 ),
 		new THREE.ShaderMaterial( {
-			uniforms: this.cubeShader.uniforms,
+			uniforms: THREE.UniformsUtils.clone( this.cubeShader.uniforms ),
 			vertexShader: this.cubeShader.vertexShader,
 			fragmentShader: this.cubeShader.fragmentShader,
 			depthTest: false,
@@ -51,6 +51,7 @@ THREE.CubeTexturePass.prototype = Object.assign( Object.create( THREE.Pass.proto
 		this.cubeCamera.quaternion.setFromRotationMatrix( this.camera.matrixWorld );
 
 		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.transparent = ( this.opacity < 1.0 );
 

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

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