UNPKG

@pixi/core

Version:
70 lines (69 loc) 3.06 kB
"use strict"; var color = require("@pixi/color"), constants = require("@pixi/constants"), Framebuffer = require("../framebuffer/Framebuffer.js"), BaseTexture = require("../textures/BaseTexture.js"); class BaseRenderTexture extends BaseTexture.BaseTexture { /** * @param options * @param {number} [options.width=100] - The width of the base render texture. * @param {number} [options.height=100] - The height of the base render texture. * @param {PIXI.SCALE_MODES} [options.scaleMode=PIXI.BaseTexture.defaultOptions.scaleMode] - See {@link PIXI.SCALE_MODES} * for possible values. * @param {number} [options.resolution=PIXI.settings.RESOLUTION] - The resolution / device pixel ratio * of the texture being generated. * @param {PIXI.MSAA_QUALITY} [options.multisample=PIXI.MSAA_QUALITY.NONE] - The number of samples of the frame buffer. */ constructor(options = {}) { if (typeof options == "number") { const width = arguments[0], height = arguments[1], scaleMode = arguments[2], resolution = arguments[3]; options = { width, height, scaleMode, resolution }; } options.width = options.width ?? 100, options.height = options.height ?? 100, options.multisample ?? (options.multisample = constants.MSAA_QUALITY.NONE), super(null, options), this.mipmap = constants.MIPMAP_MODES.OFF, this.valid = !0, this._clear = new color.Color([0, 0, 0, 0]), this.framebuffer = new Framebuffer.Framebuffer(this.realWidth, this.realHeight).addColorTexture(0, this), this.framebuffer.multisample = options.multisample, this.maskStack = [], this.filterStack = [{}]; } /** Color when clearning the texture. */ set clearColor(value) { this._clear.setValue(value); } get clearColor() { return this._clear.value; } /** * Color object when clearning the texture. * @readonly * @since 7.2.0 */ get clear() { return this._clear; } /** * Shortcut to `this.framebuffer.multisample`. * @default PIXI.MSAA_QUALITY.NONE */ get multisample() { return this.framebuffer.multisample; } set multisample(value) { this.framebuffer.multisample = value; } /** * Resizes the BaseRenderTexture. * @param desiredWidth - The desired width to resize to. * @param desiredHeight - The desired height to resize to. */ resize(desiredWidth, desiredHeight) { this.framebuffer.resize(desiredWidth * this.resolution, desiredHeight * this.resolution), this.setRealSize(this.framebuffer.width, this.framebuffer.height); } /** * Frees the texture and framebuffer from WebGL memory without destroying this texture object. * This means you can still use the texture later which will upload it to GPU * memory again. * @fires PIXI.BaseTexture#dispose */ dispose() { this.framebuffer.dispose(), super.dispose(); } /** Destroys this texture. */ destroy() { super.destroy(), this.framebuffer.destroyDepthTexture(), this.framebuffer = null; } } exports.BaseRenderTexture = BaseRenderTexture; //# sourceMappingURL=BaseRenderTexture.js.map