Capítulo 227 de 859

Chapter 227: FramebufferTexture

Core Idea

This class can only be used in combination with copyFramebufferToTexture() methods of renderers. It extracts the contents of the current bound framebuffer and provides it as a texture for further usage.

Key Concepts

  • generateMipmaps : boolean: Whether to generate mipmaps (if possible) for a texture.
  • isFramebufferTexture : boolean (readonly): This flag can be used for type testing.
  • magFilter : NearestFilter | NearestMipmapNearestFilter | NearestMipmapLinearFilter | LinearFilter | LinearMipmapNearestFilter | LinearMipmapLinearFilter: How the texture is sampled when a texel covers more than one pixel.
  • minFilter : NearestFilter | NearestMipmapNearestFilter | NearestMipmapLinearFilter | LinearFilter | LinearMipmapNearestFilter | LinearMipmapLinearFilter: How the texture is sampled when a texel covers less than one pixel.

Code Examples

const pixelRatio = window.devicePixelRatio;
const textureSize = 128 * pixelRatio;
const frameTexture = new FramebufferTexture( textureSize, textureSize );
// calculate start position for copying part of the frame data
const vector = new Vector2();
vector.x = ( window.innerWidth * pixelRatio / 2 ) - ( textureSize / 2 );
vector.y = ( window.innerHeight * pixelRatio / 2 ) - ( textureSize / 2 );
renderer.render( scene, camera );
// copy part of the rendered frame into the framebuffer texture
renderer.copyFramebufferToTexture( frameTexture, vector );
  • What it demonstrates: Typical usage of FramebufferTexture.

Reference Tables

Constructor

Signature
new FramebufferTexture( width : number, height : number )

Properties

PropertyDescription
.generateMipmaps : booleanWhether to generate mipmaps (if possible) for a texture.
.isFramebufferTexture : boolean (readonly)This flag can be used for type testing.
`.magFilter : NearestFilterNearestMipmapNearestFilter
`.minFilter : NearestFilterNearestMipmapNearestFilter

Key Takeaways

  1. FramebufferTexture extends: EventDispatcher → Texture
  2. Most relevant properties: generateMipmaps, isFramebufferTexture, magFilter, minFilter.

Connects To