UNPKG

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