Browse Source

Merge pull request #11850 from WestLangley/dev-cubeCamera

Added CubeCamera.clear()
Mr.doob 8 years ago
parent
commit
ba8f97f10f

+ 8 - 2
docs/api/cameras/CubeCamera.html

@@ -32,7 +32,7 @@
 		//Update the render target cube
 		car.setVisible( false );
 		cubeCamera.position.copy( car.position );
-		cubeCamera.updateCubeMap( renderer, scene );
+		cubeCamera.update( renderer, scene );
 
 		//Render the scene
 		car.setVisible( true );
@@ -67,7 +67,7 @@
 		<div>See the base [page:Object3D] class for common methods.</div>
 
 
-		<h3>[method:null updateCubeMap]( [page:WebGLRenderer renderer], [page:Scene scene] )</h3>
+		<h3>[method:null update]( [page:WebGLRenderer renderer], [page:Scene scene] )</h3>
 		<div>
 		renderer -- The current WebGL renderer <br />
 		scene -- The current scene
@@ -76,6 +76,12 @@
 		Call this to update the [page:CubeCamera.renderTarget renderTarget].
 		</div>
 
+		<h3>[method:null clear]( [page:Boolean color], [page:Boolean depth], [page:Boolean stencil] )</h3>
+		<div>
+		Call this to clear the [page:CubeCamera.renderTarget renderTarget] color, depth, and/or stencil buffers.
+		The color buffer is set to the renderer's current clear color. Arguments default to *true*.
+		</div>
+
 		<h2>Source</h2>
 
 		[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]

+ 1 - 1
examples/webgl_materials_cubemap_dynamic.html

@@ -961,7 +961,7 @@
 					cubeCamera.position.copy( currentCar.root.position );
 
 					renderer.autoClear = true;
-					cubeCamera.updateCubeMap( renderer, scene );
+					cubeCamera.update( renderer, scene );
 
 					veyron.setVisible( true );
 					gallardo.setVisible( true );

+ 2 - 2
examples/webgl_materials_cubemap_dynamic2.html

@@ -191,12 +191,12 @@
 				if ( count % 2 === 0 ) {
 
 					material.envMap = cubeCamera1.renderTarget.texture;
-					cubeCamera2.updateCubeMap( renderer, scene );
+					cubeCamera2.update( renderer, scene );
 
 				} else {
 
 					material.envMap = cubeCamera2.renderTarget.texture;
-					cubeCamera1.updateCubeMap( renderer, scene );
+					cubeCamera1.update( renderer, scene );
 
 				}
 

+ 1 - 1
examples/webgl_shading_physical.html

@@ -392,7 +392,7 @@
 				// render cube map
 
 				mesh.visible = false;
-				cubeCamera.updateCubeMap( renderer, scene );
+				cubeCamera.update( renderer, scene );
 				mesh.visible = true;
 
 				// render scene

+ 10 - 0
src/Three.Legacy.js

@@ -66,6 +66,7 @@ import { WebGLRenderer } from './renderers/WebGLRenderer.js';
 import { WebGLRenderTarget } from './renderers/WebGLRenderTarget.js';
 import { WebGLShadowMap } from './renderers/webgl/WebGLShadowMap.js';
 import { Shape } from './extras/core/Shape.js';
+import { CubeCamera } from './cameras/CubeCamera.js';
 
 export { BoxGeometry as CubeGeometry };
 
@@ -1426,6 +1427,15 @@ AudioAnalyser.prototype.getData = function () {
 
 //
 
+CubeCamera.prototype.updateCubeMap = function ( renderer, scene ) {
+
+	console.warn( 'THREE.CubeCamera: .updateCubeMap() is now .update().' );
+	return this.update( renderer, scene );
+
+};
+
+//
+
 export var GeometryUtils = {
 
 	merge: function ( geometry1, geometry2, materialIndexOffset ) {

+ 18 - 1
src/cameras/CubeCamera.js

@@ -54,7 +54,7 @@ function CubeCamera( near, far, cubeResolution ) {
 	this.renderTarget = new WebGLRenderTargetCube( cubeResolution, cubeResolution, options );
 	this.renderTarget.texture.name = "CubeCamera";
 
-	this.updateCubeMap = function ( renderer, scene ) {
+	this.update = function ( renderer, scene ) {
 
 		if ( this.parent === null ) this.updateMatrixWorld();
 
@@ -87,6 +87,23 @@ function CubeCamera( near, far, cubeResolution ) {
 
 	};
 
+	this.clear = function ( color, depth, stencil ) {
+
+		var renderTarget = this.renderTarget;
+
+		for ( var i = 0; i < 6; i ++ ) {
+
+			renderTarget.activeCubeFace = i;
+			renderer.setRenderTarget( renderTarget );
+
+			renderer.clear( color, depth, stencil );
+
+		}
+
+		renderer.setRenderTarget( null );
+
+	}
+
 }
 
 CubeCamera.prototype = Object.create( Object3D.prototype );