浏览代码

fixed cubeShader examples

Emmett Lalish 5 年之前
父节点
当前提交
a276839984

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

@@ -44,8 +44,8 @@ THREE.CubeTexturePass.prototype = Object.assign( Object.create( THREE.Pass.proto
 		this.cubeCamera.projectionMatrix.copy( this.camera.projectionMatrix );
 		this.cubeCamera.projectionMatrix.copy( this.camera.projectionMatrix );
 		this.cubeCamera.quaternion.setFromRotationMatrix( this.camera.matrixWorld );
 		this.cubeCamera.quaternion.setFromRotationMatrix( this.camera.matrixWorld );
 
 
-		this.cubeMesh.material.uniforms[ "tCube" ].value = this.envMap;
-		this.cubeMesh.material.uniforms[ "opacity" ].value = this.opacity;
+		this.cubeMesh.material.envMap = this.envMap;
+		this.cubeMesh.material.opacity = this.opacity;
 		this.cubeMesh.material.transparent = ( this.opacity < 1.0 );
 		this.cubeMesh.material.transparent = ( this.opacity < 1.0 );
 
 
 		renderer.setRenderTarget( this.renderToScreen ? null : readBuffer );
 		renderer.setRenderTarget( this.renderToScreen ? null : readBuffer );

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

@@ -55,8 +55,8 @@ CubeTexturePass.prototype = Object.assign( Object.create( Pass.prototype ), {
 		this.cubeCamera.projectionMatrix.copy( this.camera.projectionMatrix );
 		this.cubeCamera.projectionMatrix.copy( this.camera.projectionMatrix );
 		this.cubeCamera.quaternion.setFromRotationMatrix( this.camera.matrixWorld );
 		this.cubeCamera.quaternion.setFromRotationMatrix( this.camera.matrixWorld );
 
 
-		this.cubeMesh.material.uniforms[ "tCube" ].value = this.envMap;
-		this.cubeMesh.material.uniforms[ "opacity" ].value = this.opacity;
+		this.cubeMesh.material.envMap = this.envMap;
+		this.cubeMesh.material.opacity = this.opacity;
 		this.cubeMesh.material.transparent = ( this.opacity < 1.0 );
 		this.cubeMesh.material.transparent = ( this.opacity < 1.0 );
 
 
 		renderer.setRenderTarget( this.renderToScreen ? null : readBuffer );
 		renderer.setRenderTarget( this.renderToScreen ? null : readBuffer );

+ 2 - 11
examples/webgl_materials_envmaps.html

@@ -105,17 +105,8 @@
 					side: THREE.BackSide
 					side: THREE.BackSide
 				} );
 				} );
 
 
-				cubeMaterial.uniforms[ "tCube" ].value = textureCube;
-				Object.defineProperty( cubeMaterial, 'map', {
-
-					get: function () {
-
-						return this.uniforms.tCube.value;
-
-					}
-
-				} );
-
+				cubeMaterial.envMap = textureCube;
+				
 				// Skybox
 				// Skybox
 
 
 				cubeMesh = new THREE.Mesh( new THREE.BoxBufferGeometry( 100, 100, 100 ), cubeMaterial );
 				cubeMesh = new THREE.Mesh( new THREE.BoxBufferGeometry( 100, 100, 100 ), cubeMaterial );

+ 7 - 5
examples/webgl_postprocessing_backgrounds.html

@@ -159,13 +159,13 @@
 
 
 				} );
 				} );
 
 
-				cubeTexturePassP = new CubeTexturePass( cameraP );
-				composer.addPass( cubeTexturePassP );
+				cubeTexturePassP = null;
 
 
 				var ldrUrls = genCubeUrls( "textures/cube/pisa/", ".png" );
 				var ldrUrls = genCubeUrls( "textures/cube/pisa/", ".png" );
 				new THREE.CubeTextureLoader().load( ldrUrls, function ( ldrCubeMap ) {
 				new THREE.CubeTextureLoader().load( ldrUrls, function ( ldrCubeMap ) {
 
 
-					cubeTexturePassP.envMap = ldrCubeMap;
+					cubeTexturePassP = new CubeTexturePass( cameraP, ldrCubeMap );
+					composer.insertPass( cubeTexturePassP, 2 );
 
 
 				} );
 				} );
 
 
@@ -222,8 +222,10 @@
 				texturePass.enabled = params.texturePass;
 				texturePass.enabled = params.texturePass;
 				texturePass.opacity = params.texturePassOpacity;
 				texturePass.opacity = params.texturePassOpacity;
 
 
-				cubeTexturePassP.enabled = params.cubeTexturePass;
-				cubeTexturePassP.opacity = params.cubeTexturePassOpacity;
+				if ( cubeTexturePassP != null ) {
+					cubeTexturePassP.enabled = params.cubeTexturePass;
+					cubeTexturePassP.opacity = params.cubeTexturePassOpacity;
+				}
 
 
 				renderPass.enabled = params.renderPass;
 				renderPass.enabled = params.renderPass;
 
 

+ 2 - 1
examples/webgl_postprocessing_dof2.html

@@ -86,7 +86,6 @@
 				textureCube.format = THREE.RGBFormat;
 				textureCube.format = THREE.RGBFormat;
 
 
 				var shader = THREE.ShaderLib[ 'cube' ];
 				var shader = THREE.ShaderLib[ 'cube' ];
-				shader.uniforms[ 'tCube' ].value = textureCube;
 
 
 				var skyMaterial = new THREE.ShaderMaterial( {
 				var skyMaterial = new THREE.ShaderMaterial( {
 
 
@@ -98,6 +97,8 @@
 
 
 				} );
 				} );
 
 
+				skyMaterial.envMap = textureCube;
+
 				var sky = new THREE.Mesh( new THREE.BoxBufferGeometry( 1000, 1000, 1000 ), skyMaterial );
 				var sky = new THREE.Mesh( new THREE.BoxBufferGeometry( 1000, 1000, 1000 ), skyMaterial );
 				scene.add( sky );
 				scene.add( sky );
 
 

+ 1 - 1
src/renderers/webgl/WebGLBackground.js

@@ -92,7 +92,7 @@ function WebGLBackground( renderer, state, objects, premultipliedAlpha ) {
 
 
 					get: function () {
 					get: function () {
 
 
-						return this.envMap.value;
+						return this.envMap;
 
 
 					}
 					}