API Reference

Class List

pc.RenderTarget

A render target is a rectangular rendering surface.

// Create a 512x512x24-bit render target with a depth buffer
var colorBuffer = new pc.Texture(graphicsDevice, {
    width: 512,
    height: 512,
    format: pc.PIXELFORMAT_R8_G8_B8
});
var renderTarget = new pc.RenderTarget(graphicsDevice, colorBuffer, {
    depth: true
});

// Set the render target on an entity's camera component
entity.camera.renderTarget = renderTarget;

Summary

Properties

colorBufferColor buffer set up on the render target.[read only]
faceIf the render target is bound to a cubemap, this property specifies which face of the cubemap is rendered to.[read only]
heightHeight of the render target in pixels.[read only]
widthWidth of the render target in pixels.[read only]

Methods

destroyFrees resources associated with this render target.

Details

Constructor

RenderTarget(graphicsDevice, colorBuffer, options)

Creates a new render target.

// Create a 512x512x24-bit render target with a depth buffer
var colorBuffer = new pc.Texture(graphicsDevice, {
    width: 512,
    height: 512,
    format: pc.PIXELFORMAT_R8_G8_B8
});
var renderTarget = new pc.RenderTarget(graphicsDevice, colorBuffer, {
    depth: true
});

// Set the render target on an entity's camera component
entity.camera.renderTarget = renderTarget;

Parameters

graphicsDevicepc.GraphicsDeviceThe graphics device used to manage this frame buffer.
colorBufferpc.TextureThe texture that this render target will treat as a rendering surface.
optionsObjectObject for passing optional arguments.
options.depthBooleanTrue if the render target is to include a depth buffer and false otherwise (default is true).
options.stencilBooleanTrue if the render target is to include a stencil buffer and false otherwise (default is false). Requires depth buffer. Defaults to true.
options.faceNumberIf the colorBuffer parameter is a cubemap, use this option to specify the face of the cubemap to render to. Can be:
  • pc.CUBEFACE_POSX
  • pc.CUBEFACE_NEGX
  • pc.CUBEFACE_POSY
  • pc.CUBEFACE_NEGY
  • pc.CUBEFACE_POSZ
  • pc.CUBEFACE_NEGZ
Defaults to pc.CUBEFACE_POSX.

Properties

pc.TexturecolorBuffer

Color buffer set up on the render target.[read only]

Numberface

If the render target is bound to a cubemap, this property specifies which face of the cubemap is rendered to. Can be:

  • pc.CUBEFACE_POSX
  • pc.CUBEFACE_NEGX
  • pc.CUBEFACE_POSY
  • pc.CUBEFACE_NEGY
  • pc.CUBEFACE_POSZ
  • pc.CUBEFACE_NEGZ
[read only]

Numberheight

Height of the render target in pixels.[read only]

Numberwidth

Width of the render target in pixels.[read only]

Methods

destroy()

Frees resources associated with this render target.