UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

30 lines (29 loc) 829 B
"use strict"; import { RENDER_TARGET_DEFAULT_SIZE, renderTargetType, renderTargetFormat } from "./Common"; import { WebGLRenderTarget } from "three"; export class RenderTargetPair { constructor() { this.pingPong = false; this.RT1 = new WebGLRenderTarget(RENDER_TARGET_DEFAULT_SIZE, RENDER_TARGET_DEFAULT_SIZE, { type: renderTargetType, format: renderTargetFormat }); this.RT2 = new WebGLRenderTarget(RENDER_TARGET_DEFAULT_SIZE, RENDER_TARGET_DEFAULT_SIZE, { type: renderTargetType, format: renderTargetFormat }); } setSize(x, w) { this.RT1.setSize(x, w); this.RT2.setSize(x, w); } toggle() { this.pingPong = !this.pingPong; } previous() { return this.pingPong ? this.RT1 : this.RT2; } current() { return this.pingPong ? this.RT2 : this.RT1; } }