1 | import { Color } from "@pixi/color";
|
2 | import { MSAA_QUALITY, MIPMAP_MODES } from "@pixi/constants";
|
3 | import { Framebuffer } from "../framebuffer/Framebuffer.mjs";
|
4 | import { BaseTexture } from "../textures/BaseTexture.mjs";
|
5 | class BaseRenderTexture extends BaseTexture {
|
6 | |
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | constructor(options = {}) {
|
17 | if (typeof options == "number") {
|
18 | const width = arguments[0], height = arguments[1], scaleMode = arguments[2], resolution = arguments[3];
|
19 | options = { width, height, scaleMode, resolution };
|
20 | }
|
21 | options.width = options.width ?? 100, options.height = options.height ?? 100, options.multisample ?? (options.multisample = MSAA_QUALITY.NONE), super(null, options), this.mipmap = MIPMAP_MODES.OFF, this.valid = !0, this._clear = new Color([0, 0, 0, 0]), this.framebuffer = new Framebuffer(this.realWidth, this.realHeight).addColorTexture(0, this), this.framebuffer.multisample = options.multisample, this.maskStack = [], this.filterStack = [{}];
|
22 | }
|
23 |
|
24 | set clearColor(value) {
|
25 | this._clear.setValue(value);
|
26 | }
|
27 | get clearColor() {
|
28 | return this._clear.value;
|
29 | }
|
30 | |
31 |
|
32 |
|
33 |
|
34 |
|
35 | get clear() {
|
36 | return this._clear;
|
37 | }
|
38 | |
39 |
|
40 |
|
41 |
|
42 | get multisample() {
|
43 | return this.framebuffer.multisample;
|
44 | }
|
45 | set multisample(value) {
|
46 | this.framebuffer.multisample = value;
|
47 | }
|
48 | |
49 |
|
50 |
|
51 |
|
52 |
|
53 | resize(desiredWidth, desiredHeight) {
|
54 | this.framebuffer.resize(desiredWidth * this.resolution, desiredHeight * this.resolution), this.setRealSize(this.framebuffer.width, this.framebuffer.height);
|
55 | }
|
56 | |
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 | dispose() {
|
63 | this.framebuffer.dispose(), super.dispose();
|
64 | }
|
65 |
|
66 | destroy() {
|
67 | super.destroy(), this.framebuffer.destroyDepthTexture(), this.framebuffer = null;
|
68 | }
|
69 | }
|
70 | export {
|
71 | BaseRenderTexture
|
72 | };
|
73 |
|