1 | ;
|
2 | var Texture = require("../textures/Texture.js"), BaseRenderTexture = require("./BaseRenderTexture.js");
|
3 | class RenderTexture extends Texture.Texture {
|
4 | /**
|
5 | * @param baseRenderTexture - The base texture object that this texture uses.
|
6 | * @param frame - The rectangle frame of the texture to show.
|
7 | */
|
8 | constructor(baseRenderTexture, frame) {
|
9 | super(baseRenderTexture, frame), this.valid = !0, this.filterFrame = null, this.filterPoolKey = null, this.updateUvs();
|
10 | }
|
11 | /**
|
12 | * Shortcut to `this.baseTexture.framebuffer`, saves baseTexture cast.
|
13 | * @readonly
|
14 | */
|
15 | get framebuffer() {
|
16 | return this.baseTexture.framebuffer;
|
17 | }
|
18 | /**
|
19 | * Shortcut to `this.framebuffer.multisample`.
|
20 | * @default PIXI.MSAA_QUALITY.NONE
|
21 | */
|
22 | get multisample() {
|
23 | return this.framebuffer.multisample;
|
24 | }
|
25 | set multisample(value) {
|
26 | this.framebuffer.multisample = value;
|
27 | }
|
28 | /**
|
29 | * Resizes the RenderTexture.
|
30 | * @param desiredWidth - The desired width to resize to.
|
31 | * @param desiredHeight - The desired height to resize to.
|
32 | * @param resizeBaseTexture - Should the baseTexture.width and height values be resized as well?
|
33 | */
|
34 | resize(desiredWidth, desiredHeight, resizeBaseTexture = !0) {
|
35 | const resolution = this.baseTexture.resolution, width = Math.round(desiredWidth * resolution) / resolution, height = Math.round(desiredHeight * resolution) / resolution;
|
36 | this.valid = width > 0 && height > 0, this._frame.width = this.orig.width = width, this._frame.height = this.orig.height = height, resizeBaseTexture && this.baseTexture.resize(width, height), this.updateUvs();
|
37 | }
|
38 | /**
|
39 | * Changes the resolution of baseTexture, but does not change framebuffer size.
|
40 | * @param resolution - The new resolution to apply to RenderTexture
|
41 | */
|
42 | setResolution(resolution) {
|
43 | const { baseTexture } = this;
|
44 | baseTexture.resolution !== resolution && (baseTexture.setResolution(resolution), this.resize(baseTexture.width, baseTexture.height, !1));
|
45 | }
|
46 | /**
|
47 | * A short hand way of creating a render texture.
|
48 | * @param options - Options
|
49 | * @param {number} [options.width=100] - The width of the render texture
|
50 | * @param {number} [options.height=100] - The height of the render texture
|
51 | * @param {PIXI.SCALE_MODES} [options.scaleMode=PIXI.BaseTexture.defaultOptions.scaleMode] - See {@link PIXI.SCALE_MODES}
|
52 | * for possible values
|
53 | * @param {number} [options.resolution=PIXI.settings.RESOLUTION] - The resolution / device pixel ratio of the texture
|
54 | * being generated
|
55 | * @param {PIXI.MSAA_QUALITY} [options.multisample=PIXI.MSAA_QUALITY.NONE] - The number of samples of the frame buffer
|
56 | * @returns The new render texture
|
57 | */
|
58 | static create(options) {
|
59 | return new RenderTexture(new BaseRenderTexture.BaseRenderTexture(options));
|
60 | }
|
61 | }
|
62 | exports.RenderTexture = RenderTexture;
|
63 | //# sourceMappingURL=RenderTexture.js.map
|