1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | var Texture = require('../textures/Texture.js');
|
6 | var BaseRenderTexture = require('./BaseRenderTexture.js');
|
7 |
|
8 | class RenderTexture extends Texture.Texture {
|
9 | constructor(baseRenderTexture, frame) {
|
10 | super(baseRenderTexture, frame);
|
11 | this.valid = true;
|
12 | this.filterFrame = null;
|
13 | this.filterPoolKey = null;
|
14 | this.updateUvs();
|
15 | }
|
16 | get framebuffer() {
|
17 | return this.baseTexture.framebuffer;
|
18 | }
|
19 | get multisample() {
|
20 | return this.framebuffer.multisample;
|
21 | }
|
22 | set multisample(value) {
|
23 | this.framebuffer.multisample = value;
|
24 | }
|
25 | resize(desiredWidth, desiredHeight, resizeBaseTexture = true) {
|
26 | const resolution = this.baseTexture.resolution;
|
27 | const width = Math.round(desiredWidth * resolution) / resolution;
|
28 | const height = Math.round(desiredHeight * resolution) / resolution;
|
29 | this.valid = width > 0 && height > 0;
|
30 | this._frame.width = this.orig.width = width;
|
31 | this._frame.height = this.orig.height = height;
|
32 | if (resizeBaseTexture) {
|
33 | this.baseTexture.resize(width, height);
|
34 | }
|
35 | this.updateUvs();
|
36 | }
|
37 | setResolution(resolution) {
|
38 | const { baseTexture } = this;
|
39 | if (baseTexture.resolution === resolution) {
|
40 | return;
|
41 | }
|
42 | baseTexture.setResolution(resolution);
|
43 | this.resize(baseTexture.width, baseTexture.height, false);
|
44 | }
|
45 | static create(options) {
|
46 | return new RenderTexture(new BaseRenderTexture.BaseRenderTexture(options));
|
47 | }
|
48 | }
|
49 |
|
50 | exports.RenderTexture = RenderTexture;
|
51 |
|