未验证 提交 33ebb86a 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #17747 from elalish/dev

fixed copyFramebufferToTexture
......@@ -19,6 +19,7 @@ import { WebVRManager } from '../renderers/webvr/WebVRManager';
import { RenderTarget } from './webgl/WebGLRenderLists';
import { Geometry } from './../core/Geometry';
import { BufferGeometry } from './../core/BufferGeometry';
import { Texture } from '../textures/Texture';
export interface Renderer {
domElement: HTMLCanvasElement;
......@@ -396,6 +397,26 @@ export class WebGLRenderer implements Renderer {
activeCubeFaceIndex?: number
): void;
/**
* Copies a region of the currently bound framebuffer into the selected mipmap level of the selected texture.
* This region is defined by the size of the destination texture's mip level, offset by the input position.
*
* @param position Specifies the pixel offset from which to copy out of the framebuffer.
* @param texture Specifies the destination texture.
* @param level Specifies the destination mipmap level of the texture.
*/
copyFramebufferToTexture( position: Vector2, texture: Texture, level?: number ): void;
/**
* Copies srcTexture to the specified level of dstTexture, offset by the input position.
*
* @param position Specifies the pixel offset into the dstTexture where the copy will occur.
* @param srcTexture Specifies the source texture.
* @param dstTexture Specifies the destination texture.
* @param level Specifies the destination mipmap level of the texture.
*/
copyTextureToTexture( position: Vector2, srcTexture: Texture, dstTexture: Texture, level?: number ): void;
/**
* @deprecated
*/
......
......@@ -2719,13 +2719,16 @@ function WebGLRenderer( parameters ) {
this.copyFramebufferToTexture = function ( position, texture, level ) {
var width = texture.image.width;
var height = texture.image.height;
if ( level === undefined ) level = 0;
var levelScale = Math.pow( 2, - level );
var width = Math.floor( texture.image.width * levelScale );
var height = Math.floor( texture.image.height * levelScale );
var glFormat = utils.convert( texture.format );
textures.setTexture2D( texture, 0 );
_gl.copyTexImage2D( _gl.TEXTURE_2D, level || 0, glFormat, position.x, position.y, width, height, 0 );
_gl.copyTexImage2D( _gl.TEXTURE_2D, level, glFormat, position.x, position.y, width, height, 0 );
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册