瀏覽代碼

Merge pull request #15784 from maccesch/dev

Fixed anaglyph and multi sample render target examples
Mr.doob 6 年之前
父節點
當前提交
48272588f1
共有 3 個文件被更改,包括 14 次插入6 次删除
  1. 2 0
      examples/js/effects/AnaglyphEffect.js
  2. 8 2
      src/renderers/WebGLRenderer.d.ts
  3. 4 4
      src/renderers/WebGLRenderer.js

+ 2 - 0
examples/js/effects/AnaglyphEffect.js

@@ -145,6 +145,8 @@ THREE.AnaglyphEffect = function ( renderer, width, height ) {
 		renderer.setRenderTarget( _renderTargetR );
 		renderer.clear();
 		renderer.render( scene, _stereo.cameraR );
+
+		renderer.setRenderTarget( null );
 		renderer.render( _scene, _camera );
 
 		renderer.setRenderTarget( currentRenderTarget );

+ 8 - 2
src/renderers/WebGLRenderer.d.ts

@@ -310,8 +310,14 @@ export class WebGLRenderer implements Renderer {
 
   /**
    * Render a scene using a camera.
-   * The render is done to the renderTarget (if specified) or to the canvas as usual.
-   * If forceClear is true, the canvas will be cleared before rendering, even if the renderer's autoClear property is false.
+   * The render is done to a previously specified {@link WebGLRenderTarget#renderTarget .renderTarget} set by calling 
+   * {@link WebGLRenderer#setRenderTarget .setRenderTarget} or to the canvas as usual.
+   * 
+   * By default render buffers are cleared before rendering but you can prevent this by setting the property 
+   * {@link WebGLRenderer#autoClear autoClear} to false. If you want to prevent only certain buffers being cleared 
+   * you can set either the {@link WebGLRenderer#autoClearColor autoClearColor}, 
+   * {@link WebGLRenderer#autoClearStencil autoClearStencil} or {@link WebGLRenderer#autoClearDepth autoClearDepth} 
+   * properties to false. To forcibly clear one ore more buffers call {@link WebGLRenderer#clear .clear}.
    */
   render(
     scene: Scene,

+ 4 - 4
src/renderers/WebGLRenderer.js

@@ -1103,7 +1103,7 @@ function WebGLRenderer( parameters ) {
 		currentRenderState = renderStates.get( scene, camera );
 		currentRenderState.init();
 
-		scene.onBeforeRender( _this, scene, camera, renderTarget );
+		scene.onBeforeRender( _this, scene, camera, renderTarget || _currentRenderTarget );
 
 		_projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
 		_frustum.setFromMatrix( _projScreenMatrix );
@@ -1174,15 +1174,15 @@ function WebGLRenderer( parameters ) {
 
 		//
 
-		if ( renderTarget !== undefined ) {
+		if ( _currentRenderTarget !== null ) {
 
 			// Generate mipmap if we're using any kind of mipmap filtering
 
-			textures.updateRenderTargetMipmap( renderTarget );
+			textures.updateRenderTargetMipmap( _currentRenderTarget );
 
 			// resolve multisample renderbuffers to a single-sample texture if necessary
 
-			textures.updateMultisampleRenderTarget( renderTarget );
+			textures.updateMultisampleRenderTarget( _currentRenderTarget );
 
 		}