80 lines
4.0 KiB
JavaScript
80 lines
4.0 KiB
JavaScript
shadow$provide.module$node_modules$pixi_DOT_js$lib$rendering$renderers$shared$renderTarget$RenderTarget = function(global, require, module, exports) {
|
|
var uid = require("module$node_modules$pixi_DOT_js$lib$utils$data$uid"), TextureSource = require("module$node_modules$pixi_DOT_js$lib$rendering$renderers$shared$texture$sources$TextureSource"), Texture = require("module$node_modules$pixi_DOT_js$lib$rendering$renderers$shared$texture$Texture");
|
|
"use strict";
|
|
const node_modules$pixi_DOT_js$lib$rendering$renderers$shared$renderTarget$RenderTarget$classdecl$var21 = class {
|
|
constructor(descriptor = {}) {
|
|
this.uid = uid.uid("renderTarget");
|
|
this.colorTextures = [];
|
|
this.dirtyId = 0;
|
|
this.isRoot = !1;
|
|
this._size = new Float32Array(2);
|
|
this._managedColorTextures = !1;
|
|
descriptor = {...node_modules$pixi_DOT_js$lib$rendering$renderers$shared$renderTarget$RenderTarget$classdecl$var21.defaultOptions, ...descriptor};
|
|
this.stencil = descriptor.stencil;
|
|
this.depth = descriptor.depth;
|
|
this.isRoot = descriptor.isRoot;
|
|
if ("number" === typeof descriptor.colorTextures) {
|
|
this._managedColorTextures = !0;
|
|
for (var i = 0; i < descriptor.colorTextures; i++) {
|
|
this.colorTextures.push(new TextureSource.TextureSource({width:descriptor.width, height:descriptor.height, resolution:descriptor.resolution, antialias:descriptor.antialias}));
|
|
}
|
|
} else {
|
|
this.colorTextures = [...descriptor.colorTextures.map(texture => texture.source)], i = this.colorTexture.source, this.resize(i.width, i.height, i._resolution);
|
|
}
|
|
this.colorTexture.source.on("resize", this.onSourceResize, this);
|
|
if (descriptor.depthStencilTexture || this.stencil) {
|
|
descriptor.depthStencilTexture instanceof Texture.Texture || descriptor.depthStencilTexture instanceof TextureSource.TextureSource ? this.depthStencilTexture = descriptor.depthStencilTexture.source : this.ensureDepthStencilTexture();
|
|
}
|
|
}
|
|
get size() {
|
|
const _size = this._size;
|
|
_size[0] = this.pixelWidth;
|
|
_size[1] = this.pixelHeight;
|
|
return _size;
|
|
}
|
|
get width() {
|
|
return this.colorTexture.source.width;
|
|
}
|
|
get height() {
|
|
return this.colorTexture.source.height;
|
|
}
|
|
get pixelWidth() {
|
|
return this.colorTexture.source.pixelWidth;
|
|
}
|
|
get pixelHeight() {
|
|
return this.colorTexture.source.pixelHeight;
|
|
}
|
|
get resolution() {
|
|
return this.colorTexture.source._resolution;
|
|
}
|
|
get colorTexture() {
|
|
return this.colorTextures[0];
|
|
}
|
|
onSourceResize(source) {
|
|
this.resize(source.width, source.height, source._resolution, !0);
|
|
}
|
|
ensureDepthStencilTexture() {
|
|
this.depthStencilTexture || (this.depthStencilTexture = new TextureSource.TextureSource({width:this.width, height:this.height, resolution:this.resolution, format:"depth24plus-stencil8", autoGenerateMipmaps:!1, antialias:!1, mipLevelCount:1}));
|
|
}
|
|
resize(width, height, resolution = this.resolution, skipColorTexture = !1) {
|
|
this.dirtyId++;
|
|
this.colorTextures.forEach((colorTexture, i) => {
|
|
skipColorTexture && 0 === i || colorTexture.source.resize(width, height, resolution);
|
|
});
|
|
this.depthStencilTexture && this.depthStencilTexture.source.resize(width, height, resolution);
|
|
}
|
|
destroy() {
|
|
this.colorTexture.source.off("resize", this.onSourceResize, this);
|
|
this._managedColorTextures && this.colorTextures.forEach(texture => {
|
|
texture.destroy();
|
|
});
|
|
this.depthStencilTexture && (this.depthStencilTexture.destroy(), delete this.depthStencilTexture);
|
|
}
|
|
};
|
|
global = node_modules$pixi_DOT_js$lib$rendering$renderers$shared$renderTarget$RenderTarget$classdecl$var21;
|
|
global.defaultOptions = {width:0, height:0, resolution:1, colorTextures:1, stencil:!1, depth:!1, antialias:!1, isRoot:!1};
|
|
exports.RenderTarget = global;
|
|
};
|
|
|
|
//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$rendering$renderers$shared$renderTarget$RenderTarget.js.map
|